Playing audio stream in loop without playmode
archlinka

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
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. ???

archlinka

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

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.

Edgar Reynaldo

Allegro 5 needs proper audio events. If it's not super hard, I might investigate a little.

Thread #618092. Printed from Allegro.cc