al_get_aud...m_fragment(3)
π NAME π
al_get_audio_stream_fragment β the Allegro 5 API function that hands you a fresh buffer to fill, bestie π
(this page lives in the Allegro reference manual, and heads up, its short name is literally al_get_aud...m_fragment, iconic truncation β¨)
πΈ SYNOPSIS πΈ
#include <allegro5/allegro_audio.h>
void *al_get_audio_stream_fragment(const ALLEGRO_AUDIO_STREAM *stream)
π¦ DESCRIPTION π¦
okay so β when you're doing Allegro's audio streaming, this function is the one you'll be calling over and over to keep feeding new sample data into a stream. Like, continuously. It's giving "refill the snack bowl" energy π
If the stream is ready for new data, it returns the address of an internal buffer that you fill up with audio data. The length and format of that buffer are set by al_create_audio_stream(3), or you can query them with the various functions described here. Once you've filled the buffer, you must signal that back to Allegro by passing the buffer to al_set_audio_stream_fragment(3) π«Ά
If the stream is not ready for new data, it just returns NULL. no drama, no buffer, just NULL π
Note: if you listen to events from the stream, anALLEGRO_EVENT_AUDIO_STREAM_FRAGMENT(3)event gets generated whenever a new fragment is ready. BUT β and this is the part people miss β getting that event is not a guarantee thatal_get_audio_stream_fragment(3)won't returnNULL, so you still have to check for it. fr fr, always check π
β SEE ALSO β
al_set_audio_stream_fragment(3)al_get_audio_stream_event_source(3)al_get_audio_stream_frequency(3)al_get_audio_stream_channels(3)al_get_audio_stream_depth(3)al_get_audio_stream_length(3)
that's the whole page, bestie π go forth and fill your buffers π β with love from the Allegro reference manual π
π¦ where this page comes from
- arch rolling: allegro 5.2.11.3-2 Β· Zlib AND BSD-3-Clause AND OFL-1.1 AND LicenseRef-Custom
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms