Page 1 of 1

[startTime commit] OpenAL error with looping 0-length sound

PostPosted: Mon Jun 01, 2020 1:00 pm
by Edward-san
If a looping sound with playable length 0 is played, openal throws the following error:

Code: Select allExpand view
>>>>>>>>>>>> Received AL error Invalid Value (0xa003), oalsound.cpp:1439


which corresponds to this code.

this happens because of this line (confirmed by calling GetALError right after that line). It seems 'st' results NaN and is propagated from 'startTime' being NaN, but then this happened because of this code, due to the fact that GSnd->GetMSLength(sfx->data) is 0 and the 'fmod' operation returns NaN under such case.

In order to reproduce this, load the attached pk3 with Doom2 wad and summon the actor 'TestError' and see the error twice in the console.

I'm not sure, but I suppose the implementation of startTime in A_StartSound did not take this situation into account. What should it happen under such case?

This was found out when the DRPGCrates actors from DoomRPG SE mod are loaded.

Re: [startTime commit] OpenAL error with looping 0-length so

PostPosted: Mon Jun 01, 2020 6:00 pm
by Chris
A 0 length sound probably shouldn't be flagged to loop. I'm not even sure 0 length sounds should be allowed to begin with, since they don't have anything to play.

From my point of view, trying to play a 0 length sound should be an error. Alternatively, a non-looping 0 length sound should be treated as completing immediately, while a looping 0 length sound could be replaced with a short sound containing silence. Although it could be confusing to callers that the sound has a non-0 offset despite being 0 length (but then, a 0 offset with 0 length isn't good either, since the offset should be in the range [0, length), which makes no sense when length=0). For OpenAL Soft's part, it immediately stops a source that tries to play a 0 length buffer, even if it's set to looping (it might make sense to make this an invalid operation error).

Re: [startTime commit] OpenAL error with looping 0-length so

PostPosted: Wed Jun 03, 2020 6:42 am
by Edward-san
For the time being, this PR should fix the regression. Is the duplicate code I touched in both the functions intended?

Re: [startTime commit] OpenAL error with looping 0-length so

PostPosted: Wed Jun 03, 2020 7:28 am
by Graf Zahl
The code got this much duplication only by progressive feature addition. Of course it has reached a point now where a separate function makes sense.