09-10-2022, 11:26 PM
(09-10-2022, 07:10 PM)a740g Wrote:(09-08-2022, 10:01 AM)Stuart Wrote: I ran into a problem with sound files not being played as expected and found this to be the problem :
The old audio backend would return 0 if the sound couldn't be loaded.
The new audio backend will return -1 if the sound can't be loaded.
This wouldn't be a major problem since the check for a valid handle could simply be changed to "IF h& > 0 THEN _SNDPLAY h&" -- however, any programs that were written with the previous (shorter) syntax of "IF h& THEN..." won't work like they used to.
It might be a good idea to make the new audio backend _also_ return a 0 instead of -1.
Also, in the Help File and/or Wiki :
under _SNDOPEN it says "Returns a LONG soundHandle& value to the sound file in memory. A value less than one means the sound could not be loaded". (This could mean 0 _or_ -1.)
Later it says "Always check the handle value returned is greater than zero before attempting to play the sound".
under _SNDPLAY it says "Make sure that the handle& value is not 0 before attempting to play it."
In the example code for checking a handle before playing is : "IF h& THEN _SNDPLAY h&"
This would need to be edited if an invalid handle returns -1 instead of 0.
Thank you for checking and reporting. This issue has been corrected in the latest QB64-PE commits. The next release of QB64-PE will include these fixes. The Wiki too will be updated and fixed soon.
You're welcome, and thanks for checking into it and letting me know the result/outcome @a740g.