love2d / love

LÖVE is an awesome 2D game framework for Lua.
https://love2d.org
Other
5.06k stars 401 forks source link

A looping source stops after ~3 minutes of looping #222

Closed slime73 closed 13 years ago

slime73 commented 13 years ago

Original report by Danny Fritz (Bitbucket: dannyfritz, GitHub: dannyfritz).


I made that annoying nyancat program, and I loop a 24 second clip. The loop stops about 3 minutes in for me and the game becomes silent.

slime73 commented 13 years ago

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


Just run the right version next time :P. (Found out he was using 0.7.0 on irc.)

slime73 commented 13 years ago

Original comment by Boolsheet (Bitbucket: Boolsheet, GitHub: Boolsheet).


I think this is a valid bug. I get it on Windows with mp3 and wav sources too, vorbis seems to be working.

Edit: Happened on ubuntu too.

slime73 commented 13 years ago

Original comment by Danny Fritz (Bitbucket: dannyfritz, GitHub: dannyfritz).


Wasn't happening on my Ubuntu machine with 0.7.1.

slime73 commented 13 years ago

Original comment by Jorge Canha (Bitbucket: Canha, GitHub: Canha).


Can we specify the version for this problem?

slime73 commented 13 years ago

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


Boolsheet: I'm 100% sure the original bug report is invalid.

slime73 commented 13 years ago

Original comment by Boolsheet (Bitbucket: Boolsheet, GitHub: Boolsheet).


The original bug report says a looping source stops looping after a while. This holds true for me.

slime73 commented 13 years ago

Original comment by Linus (Bitbucket: thelinx, GitHub: thelinx).


I'm fairly certain I've had this issue as well. Confirming...

slime73 commented 13 years ago

Original comment by Linus (Bitbucket: thelinx, GitHub: thelinx).


Confirmed. I've attached a .love I had lying around that could be used to test this issue.

slime73 commented 13 years ago

Original comment by Danny Fritz (Bitbucket: dannyfritz, GitHub: dannyfritz).


I have the problem on rescue.love with 0.7.1 Windows 7 x64

slime73 commented 13 years ago

Original comment by Boolsheet (Bitbucket: Boolsheet, GitHub: Boolsheet).


I've found some things that could be a problem in the openal code. Looking some more into it to be sure what exactly is relevant to this issue.\ There's also a bug in the Mpg123Decoder.cpp which has probably a part in all this, but it's not the main cause: https://bitbucket.org/rude/love/src/0aa215028607/src/modules/sound/lullaby/Mpg123Decoder.cpp#cl-130 \\In case of MPG123_NEED_MORE the decoder may have decoded some data and the code does not respect this. numbytes should be added to size.

(Oh, I just realised that this is the bug that causes the click and popping with mp3s)

slime73 commented 13 years ago

Original comment by Boolsheet (Bitbucket: Boolsheet, GitHub: Boolsheet).


Turns out the code in Source.cpp may leak a OpenAL buffer if Decoder::decode() returns 0. This is possible on eof or on decoding error maybe. anjo already made some changes to the function that leaks for 0.8.0, but it looks like it still will leak. \Also noticed 2 decoder bugs. The mpg123 noted above and one in the VorbisDecoder that sets eof too early. \\ Please don't apply the patch. I just added it to show what I mean in code form.

slime73 commented 13 years ago

Original comment by Bart van Strien (Bitbucket: bartbes, GitHub: bartbes).


I implemented some of these changes. Can anyone confirm this bug is fixed. (Hard for me, since I never had it.)

slime73 commented 13 years ago

Original comment by Boolsheet (Bitbucket: Boolsheet, GitHub: Boolsheet).


Yes, that fixed some of it.\ Now looping sources keep looping, mp3 plays without the clicking and vorbis does not cut off the end. \\ Unfortuantely Source::isStopped() relies on the fact that OpenAL stops a source if it runs out of buffers and that's exactly what Source::update() used to do if the decoder is done. isStopped() will now always return false if the Source is not stopped manually. I noticed this when I poked around with the FLAC decoder.\ Source::update() or Source::streamAtomic() probably need to check for Decoder->isFinished() and stop the non-looping source. \\ There's another problem with Source::streamAtomic(). Because the code now always queues the unqueued buffer right away it has to update the buffer even if there's no new data. streamAtomic() currently only updates the buffer if it has at least 1 byte of data. OpenAL will loop the last buffer(s) repeatedly at the end with non-looping sources.\ I think you could just drop the if on line 466, since passing a 0 size buffer seems to be a valid operation in OpenAL.

slime73 commented 13 years ago

Original comment by Boolsheet (Bitbucket: Boolsheet, GitHub: Boolsheet).


Disregard the part about 'check for eof and stop'. Of course you can't know where OpenAL currently plays and I guess you have to let it run out of buffers.

slime73 commented 13 years ago

Original comment by Boolsheet (Bitbucket: Boolsheet, GitHub: Boolsheet).


bartbes pushed another fix that took care of it and it works now as expected. Everyone is invited to test it! ;)