1ALLEGRO_AUDIO_STREAM(3) ALLEGRO_AUDIO_STREAM(3)
2
3
4
6 ALLEGRO_AUDIO_STREAM - Allegro 5 API
7
9 #include <allegro5/allegro_audio.h>
10
11 typedef struct ALLEGRO_AUDIO_STREAM ALLEGRO_AUDIO_STREAM;
12
14 An ALLEGRO_AUDIO_STREAM object is used to stream generated audio to the
15 sound device, in real-time. This is done by reading from a buffer,
16 which is split into a number of fragments. Whenever a fragment has
17 finished playing, the user can refill it with new data.
18
19 As with ALLEGRO_SAMPLE_INSTANCE(3) objects, streams store information
20 necessary for playback, so you may not play the same stream multiple
21 times simultaneously. Streams also need to be attached to an ALLE‐
22 GRO_MIXER(3), which, eventually, reaches an ALLEGRO_VOICE(3) object.
23
24 While playing, you must periodically fill fragments with new audio da‐
25 ta. To know when a new fragment is ready to be filled, you can either
26 directly check with al_get_available_audio_stream_fragments(3), or lis‐
27 ten to events from the stream.
28
29 You can register an audio stream event source to an event queue; see
30 al_get_audio_stream_event_source(3). An ALLEGRO_EVENT_AU‐
31 DIO_STREAM_FRAGMENT(3) event is generated whenever a new fragment is
32 ready. When you receive an event, use al_get_audio_stream_fragment(3)
33 to obtain a pointer to the fragment to be filled. The size and format
34 are determined by the parameters passed to al_create_audio_stream(3).
35
36 If you're late with supplying new data, the stream will be silent until
37 new data is provided. You must call al_drain_audio_stream(3) when
38 you're finished with supplying data to the stream.
39
40 If the stream is created by al_load_audio_stream(3) then it will also
41 generate an ALLEGRO_EVENT_AUDIO_STREAM_FINISHED(3) event if it reaches
42 the end of the file and is not set to loop.
43
44
45
46Allegro reference manual ALLEGRO_AUDIO_STREAM(3)