[A5] audio stream empty on completion of playback
I'm not sure if this is by design or a bug, but I can't seem to play a stream again once it has finished playing the ogg file.
This is roughly my code for playing the ogg files which works well:
I can stop and restart this stream/audio track at any time during playback with a call to:
.. and that works well too.
However the problem arises when the ogg file finishes playing. When that happens, I can't start playback again using the ALLEGRO_AUDIO_STREAM object, all I get is silence.
Is this by design i.e. stream reaches end of file and is now finished? Is there a way to reset the stream to the start of the file when it reaches the end without destroying and recreating the stream?
Reading up on ALLEGRO_AUDIO_STREAM, it says
you must periodically fill fragments with new audio data. To know when a new fragment is ready to be filled, you can either directly check with al_get_available_audio_stream_fragments, or listen to events from the stream
Maybe this is the cause of it stopping. If you just want to play, stop, and loop an ogg, you can easily do this with ALLEGRO_SAMPLE.
Thread #612639. Printed from Allegro.cc
No, if you create the stream yourself that's correct but if you load it from a file Allegro handles the streaming of the chunks and this works. I think it simply purges the stream on reaching the end of the file or there is a bug in Allegro. Either way, when the stream ends I just destroy it and recreate it when the audio needs to be played again.