get_audio_stream_buffer(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

NAME πŸŽ€

get_audio_stream_buffer β€” the lil function that tells you if you need to fill the audiostream or not, bestie. Part of the Allegro game programming library. πŸ’–


✨ SYNOPSIS ✨

#include <allegro.h>

void *get_audio_stream_buffer(AUDIOSTREAM *stream);

πŸ’… DESCRIPTION πŸ’…

okay so. when your audio stream is playing, you have to call this function at regular intervals β€” like, on a schedule, no skipping β€” so it can hand you the next buffer of sample data to fill. 🫢

and the tea is: the smaller your stream buffer size, the more often you gotta call it. no cap. tiny buffer = needy buffer.

🚫 do NOT call this from a timer handler. literally just don't. it's giving chaos.

here's the vibe, in code form:

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 you genuinely don't need to do anything. relax, queen. πŸ’€
  • 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 (however many you specified when creating the stream, iykyk) right to that address β€” for example using an fread() from a disk file. πŸ“€

then, after you fill that buffer with data, you call free_audio_stream_buffer() to let it know the new data is now valid. periodt. πŸ‘‘


πŸ¦‹ SEE ALSO πŸ¦‹


and that's the whole page, bestie!! ✨ this was Allegro, version 4.4.3, and the page is get_audio_stream_buffer(3) β€” go stream something cute, mwah πŸ’–πŸŽ€πŸŒˆ

πŸ“¦ where this page comes from