xiph / vorbis-tools

Command-line tools for creating and playing Ogg Vorbis files.
GNU General Public License v2.0
73 stars 28 forks source link

ogg123: --random/--repeat: endless loop if audio device disappears #45

Closed sdaoden closed 4 months ago

sdaoden commented 5 months ago

Hello! Thanks for the much beloved ogg/vorbis stuff that i use for over two decades i think. I have spent years of my life with this format / software (i wrote a little pretty borked OGG player thing for MacOS in 2010, but 'am back to FreeBSD/Linux and thus ogg123 for very long)! (Only a bit disappointed that integer-only tremor disappeared; i have a copy.. but maybe will never use it, and THUS .. 'NUFF said.)

So i do have a problem with ogg123 in that it often plays all day long and i have a bluetooth thing that is addressed via BlueAlsa; the actual device is borked though, and so it happens that the device disappears. If ogg123 is at that time running in --random or --repeat mode, it enters an endless loop that drives the CPU to maximum.

Wouldn't it make sense to add an error counter and reset it when anything can be written successfully, and otherwise bail out after XY errors? Or sleep a bit instead of busy-endless-looping if there was an error? Would it make sense to write a patch and create a pull request?

Thanks for ogg/vorbis people! Thanks. Ciao from Germany,

rillian commented 5 months ago

Hmm. It looks like ogg123 doesn't check for error after submitting audio for playback, and so repeat mode might keep decoding over and over again without noticing the audio is going nowhere.

sdaoden commented 5 months ago

I see. I never looked into this, actually; if it happens i see the "ERROR: buffer write failed." error, so whereas your thing also very much looks like a bug, the loop in main() seems to have no exit clause at all; however the play() it calls will react, but only on sig_request.exit, not on any I/O error. What'ya say?

sdaoden commented 4 months ago

Ah yes, some good aspects there are with github! I have really opened

https://github.com/xiph/vorbis-tools/pull/47

which contains a possible solution!