SDL_BindAudioStreams(3)

โœจ SDL_BindAudioStreams โ€” the girlies are getting bound ๐Ÿ’–

okay bestie, welcome to the SDL3 FUNCTIONS</p> corner of the man pages. today's main character is SDL_BindAudioStreams, and she is literally about to marry a whole list of audio streams to one audio device. periodt.


๐ŸŒธ NAME ๐ŸŒธ

SDL_BindAudioStreams โ€” bind a list of audio streams to an audio device. no cap, that's the whole job.


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

#include <SDL3/SDL_audio.h>

bool SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream * const *streams, int num_streams);

like. look at her. three little args and she's changing lives ๐Ÿ’…


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so here's the tea, bestie. once streams are bound, audio data will flow through any of them. and it depends on what kind of device you're working with:

  • for a playback device, data for all bound streams gets mixed together and fed to the device. it's giving group project but everyone actually shows up. ๐Ÿ”ฅ
  • for a recording device, a copy of the recorded data is handed to each bound stream. everyone gets their own lil slice, no fighting. ๐Ÿ“

also important: audio streams can only be bound to an open device. and this operation is atomic โ€” every stream bound in the same call starts processing at the same time, so they can stay in sync (iykyk, sync is everything). and the atomic thing means: either all streams get bound, or none of them do. it's all or nothing, babe. ๐Ÿ’€

โš ๏ธ it is an error to bind an already-bound stream. you must explicitly unbind it first. do not try to double-book her, she will not allow it.

binding a stream to a device will set its output format for playback devices, and its input format for recording devices, so they match the device's settings. but here's the fun part โ€” the caller is totally welcome to change the other end of the stream's format at any time with SDL_SetAudioStreamFormat(). slay, you have options. โœจ

and if the other end of the stream's format has never been set (meaning the audio stream was created with a NULL audio spec), this function will set it to match the device end's format. she'll just handle it for you, because she's thoughtful like that. ๐Ÿซถ


๐ŸŒˆ FUNCTION PARAMETERS ๐ŸŒˆ

  • devid โ€” an audio device to bind a stream to. the one, the only, the destination ๐Ÿ’–
  • streams โ€” an array of audio streams to bind. bring the whole squad.
  • num_streams โ€” number streams listed in the streams array. yes bestie, she's counting. ๐Ÿงฎ

โญ RETURN VALUE โญ

returns true on success or false on failure. and if it flops? call SDL_GetError() for more information, she'll tell you what went wrong. no secrets between us. ๐Ÿ˜ญ


๐Ÿ’œ THREAD SAFETY ๐Ÿ’œ

it is safe to call this function from any thread. go off, queen. run it everywhere. ๐Ÿ‘‘


๐ŸŒŸ AVAILABILITY ๐ŸŒŸ

this function is available since SDL 3.2.0. so if you're on something older... bestie, upgrade. it's giving ancient. ๐Ÿ’…


๐Ÿ’– SEE ALSO ๐Ÿ’–


okay that's the whole page, and that's the vibe check passed. ๐Ÿ’– this lil masterpiece comes to you straight from Simple Directmedia Layer, version SDL 3.4.18 โ€” go bind responsibly, bestie, and remember: all streams or none. periodt. ๐ŸŽ€โœจ๐Ÿฆ‹๐ŸŒธ๐Ÿซถ

๐Ÿ“ฆ where this page comes from