GET_AUDIO_STREAM_BUFFER(3alleg4)

✨ get_audio_stream_buffer ✨

okay bestie, welcome to the Allegro manual page for get_audio_stream_buffer(3alleg4) πŸ’– this is the Allegro game programming library, and this little function is literally the vibe check for your audio stream. let's get into it πŸŽ€


🌸 SYNOPSIS 🌸

#include <allegro.h>

void *get_audio_stream_buffer(AUDIOSTREAM *stream);

πŸ’… DESCRIPTION πŸ’…

so here's the tea: while an audio stream is playing, you must call this function at regular intervals to hand over the next buffer of sample data. and no cap β€” the smaller your stream buffer size, the more often you gotta call it. like, tiny buffer = constant check-ins, it's giving clingy girlfriend energy πŸ™ˆ

🚨 not me forgetting to say this: this function should not be called from a timer handler. don't do it. periodt.

here's how it looks in the wild, iconic example incoming:

void *mem_chunk;
...
while (TRUE) {
   ...
   mem_chunk = get_audio_stream_buffer(buffer);
   if (mem_chunk != NULL) {
      /* Refill the stream buffer. */
   }
}

πŸ‘‘ RETURN VALUE πŸ‘‘

  • if it returns NULL β€” the stream is still playing the previous lot of data, so bestie you don't need to do anything. chill. do nothing. slay πŸ’…
  • if it returns a value β€” that's the location of the next buffer to be played, and you should load the appropriate number of samples into that address. and "appropriate number" means however many you specified when you created the stream, iykyk. for example, using an fread() from a disk file πŸ“
  • after you fill the buffer with data, call free_audio_stream_buffer() to indicate that the new data is now valid. don't skip this step, it's the whole point fr fr πŸ”₯

πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, no crumbs left ✨ Allegro version 4.4.3, written way back in the day, still out here feeding audio buffers. mwah. πŸ’– go refill your stream, main character πŸŽ€πŸ’