SDL_GetAudioRecordingDevices(3)

πŸ’– SDL_GetAudioRecordingDevices πŸ’–

okay bestie, welcome to the SDL3 functions corner of the manual, this one's all about SDL_GetAudioRecordingDevices and it's literally the glow-up your mic setup has been waiting for ✨


🌸 NAME 🌸

SDL_GetAudioRecordingDevices β€” get a list of currently-connected audio recording devices. yes, ALL of them. the whole roster. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_audio.h>

SDL_AudioDeviceID * SDL_GetAudioRecordingDevices(int *count);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea: this function hands you a list of every available device that records audio β€” think microphones, headsets, that one USB thing you bought at 2am, all of them. in SDL-speak these are called "recording" devices 🎀

if what you actually want is the stuff that plays sound β€” speakers, headphones, the vibe-makers β€” then you want SDL_GetAudioPlaybackDevices() instead. different function, different list, don't mix them up bestie πŸ™ˆ

also important, no cap: this only returns a list of physical devices. it will not include any of the device IDs that came out of SDL_OpenAudioDevice(). those are yours, not the system's, iykyk.

and if this function returns NULL, which is how it signals an error, then *count will be set to zero. zero. nada. the vibe check failed 😭


✨ FUNCTION PARAMETERS ✨

  • count β€” a pointer that gets filled in with the number of devices returned. it may be NULL, so if you truly don't care how many there are, you can just... not ask 🫢

πŸ‘‘ RETURN VALUE πŸ‘‘

returns a 0 terminated array of device instance IDs, or NULL on failure. if it's NULL you should call SDL_GetError() for more info β€” that's where the actual explanation lives.

and listen, this is the part everyone forgets: when you're done with it, free it with SDL_free(). it is not going to clean itself up. main character energy does not extend to memory management πŸ’€


🌈 THREAD SAFETY 🌈

it is safe to call this function from any thread. go off, multithreaded queen πŸ‘‘


⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0. so if you're on something older... no it isn't, babe πŸ’–


πŸ“ SEE ALSO πŸ“


and that's the whole page!! brought to you by Simple Directmedia Layer, running SDL 3.4.18 β€” mwah, free the array, call SDL_GetError(), and stay iconic πŸ§šπŸ’œ

πŸ“¦ where this page comes from