Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Audio wont loop, audio freezes at end of stream (.ogg)

This thread is locked; no one can reply to it. rss feed Print
Audio wont loop, audio freezes at end of stream (.ogg)
TrieBr
Member #12,157
July 2010

I have some audio that is loaded from an .ogg file and played using loop mode. Here is my code that loads the audio and begins looping it:

al_restore_default_mixer();
    
    backgroundMusic = al_load_audio_stream_f(gameEngine::resources::audio.openSubFile(":mainMenu:BGMusic.ogg", false),".ogg",200,20);
    al_set_audio_stream_playmode(backgroundMusic,ALLEGRO_PLAYMODE_LOOP);
    al_attach_audio_stream_to_mixer(backgroundMusic,al_get_default_mixer());

It plays fine, but when it gets to the end of the audio it should loop back to the beginning. Instead it freezes and keeps repeating a small fragment of the audio (eg. a broken record player sound, or the sound you hear when a CD player freezes).

Does anyone know why it won't loop? I've also tried playing with the buffer count and samples on the al_load_audio_stream_f, but that didn't seem to change anything.

Go to: