#include <allegro5/allegro_audio.h>


An ALLEGRO_AUDIO_STREAM object is used to stream generated audio to the sound device, in real-time. This is done by reading from a buffer, which is split into a number of fragments. Whenever a fragment has finished playing, the user can refill it with new data.

As with ALLEGRO_SAMPLE_INSTANCE(3alleg5) objects, streams store information necessary for playback, so you may not play the same stream multiple times simultaneously. Streams also need to be attached to an ALLEGRO_VOICE(3alleg5) object, or to an ALLEGRO_MIXER(3alleg5) object which, eventually, reaches an ALLEGRO_VOICE object.

While playing, 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(3alleg5), or listen to events from the stream.

You can register an audio stream event source to an event queue; see al_get_audio_stream_event_source(3alleg5). An ALLEGRO_EVENT_AUDIO_STREAM_FRAGMENT event is generated whenever a new fragment is ready. When you receive an event, use al_get_audio_stream_fragment(3alleg5) to obtain a pointer to the fragment to be filled. The size and format are determined by the parameters passed to al_create_audio_stream(3alleg5).

If you[aq]re late with supplying new data, the stream will be silent until new data is provided. You must call al_drain_audio_stream(3alleg5) when you[aq]re finished with supplying data to the stream.

If the stream is created by al_load_audio_stream(3alleg5) then it can also generate an ALLEGRO_EVENT_AUDIO_STREAM_FINISHED event if it reaches the end of the file and is not set to loop.

Latest Tech News
Your Notes

Sign in/Sign up

Signing in to our system allows you to post your contributions and vote on the contributions of others. It will also allow you to get extra perts like having your favorites in the cloud and having your persistent personal notes wherever you go. More will be added as we scale up our services.

By signing in to our system, you agree our Member Terms and Conditions

with one of the following services

Almost finished!

Please select a screen name for NET SOUP.

 Please send me news and special offers from NET SOUP.

 I have read and accept the Terms of Use.


We have no example yet for this entry

Your Name

Community Contributions and Discussions

Modify your search

View Documentation

Jobs from Indeed