Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Playing audio stream in loop without playmode

This thread is locked; no one can reply to it. rss feed Print
Playing audio stream in loop without playmode
archlinka
Member #17,215
December 2019

Hi,

I would like to play audio stream in loop but without using loop playmode.

What I do know is (pseudocode):
1) al_load_audio_stream
2) wait for ALLEGRO_EVENT_AUDIO_STREAM_FINISHED
3) al_rewind_audio_stream
4) al_set_audio_stream_playing(true)

I correctly got the event but the stream won't play again. Is it right approach or I do something wrong?

I could destroy stream and load it again but I would like avoid unnecessary disk operations.

Thanks for answers.

Niunio
Member #1,975
March 2002
avatar

archlinka said:

I could destroy stream and load it again but I would like avoid unnecessary disk operations.

Do you know that streams don't load all the sound in to memory but loads chunks as it need it, don't you? So it is doing disk operations most of the time.

Anyway, why don't you want to use loop playmode? It was created just to do what you want to do. ???

-----------------
Current projects: Allegro.pas | MinGRo

archlinka
Member #17,215
December 2019

Yes I know that, but still moving "pointer" to zero will be cheaper that reading file descriptor.

The reason I do not want to use play mode is because I need event when the stream finish (or finish loop) but in loop playmode this event never come.

Niunio
Member #1,975
March 2002
avatar

Then play in normal mode, then use al_get_audio_stream_playing to know if it finished and restart it.

The other way is to write your own stream loader.

-----------------
Current projects: Allegro.pas | MinGRo

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Go to: