SDL_SetAudioStreamFormat(3)
β¨ SDL_SetAudioStreamFormat β¨
okay so bestie, we're in the SDL3 FUNCTIONS section of the SDL_SetAudioStreamFormat(3) manual page and honestly? this one's a bop. it's all about changing the input and output formats of an audio stream. glow-up for your audio, fr fr π
πΈ NAME πΈ
SDL_SetAudioStreamFormat β change the input and output formats of an audio stream. that's it, that's the whole vibe. π
π¦ SYNOPSIS π¦
#include <SDL3/SDL_audio.h>
bool SDL_SetAudioStreamFormat(SDL_AudioStream *stream, const SDL_AudioSpec *src_spec, const SDL_AudioSpec *dst_spec);
like, look at her. she's giving main character energy and she takes three args. iconic. π
π DESCRIPTION π
so here's the tea β β future calls to SDL_GetAudioStreamAvailable and SDL_GetAudioStreamData will reflect the new format. and future calls to SDL_PutAudioStreamData must provide data in the new input formats. no cap.
but wait, there's more, and it's lowkey the best part: data that was previously queued in the stream will still be operated on in the format that was current when it was added. which is to say β and I'm literally quoting the energy here β you can put the end of a sound file in one format to a stream, change formats for the next sound file, and start putting that new data while the previous sound file is still queued, and everything will still play back correctly. obsessed. π«Ά
now for the serious bit, bestie, pay attention:
if a stream is bound to a device, then the format of the side of the stream bound to a device cannot be changed (src_specfor recording devices,dst_specfor playback devices). attempts to make a change to this side will be ignored, but this will not report an error. the other side's format can be changed.
read that again. no error, just silence on the change. it's giving "we're not mad, we're just not doing it" π
and! src_spec and dst_spec may each be NULL; a NULL spec signals not to change the current format for that side of the stream. so NULL = "leave her alone, she's fine" β¨
π FUNCTION PARAMETERS π
streamβ the stream the format is being changed. the girl we're editing πsrc_specβ the new format of the audio input; ifNULL, it is not changed.dst_specβ the new format of the audio output; ifNULL, it is not changed.
π RETURN VALUE π
returns true on success or false on failure β and if it fails, call SDL_GetError() for more information. that's your group chat when something goes wrong. text her, she'll tell you π
β THREAD SAFETY β
it is safe to call this function from any thread, because it holds a stream-specific mutex while running. multitasking queen. we love a function that locks her own stuff and doesn't bother anybody else π₯
π AVAILABILITY π
this function is available since SDL 3.2.0. so if you're on something older... bestie. update. π
π SEE ALSO π
and that's the whole page, no notes π this was served to you straight from the Simple Directmedia Layer collection, SDL 3.4.18, and yes she ate and left no crumbs. go format something gorgeous, bestie π§β¨π
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms