SDL_HINT_AUDIO_CATEGORY(3)

πŸ’– SDL_HINT_AUDIO_CATEGORY πŸ’–

okay bestie, so this is a page from the SDL3 FUNCTIONS manual, and today's main character is SDL_HINT_AUDIO_CATEGORY β€” literally just a variable that controls the audio category on iOS and macOS. that's it. that's the whole vibe. πŸŽ€


✨ NAME ✨

SDL_HINT_AUDIO_CATEGORY β€” a variable controlling the audio category on iOS and macOS.


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_hints.h>

#define SDL_HINT_AUDIO_CATEGORY "SDL_AUDIO_CATEGORY"

like, that's the whole thing. one include, one define. slay. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so the variable can be set to the following values, and this is the part where you actually have to pay attention:

  • "ambient" β€” use the AVAudioSessionCategoryAmbient audio category. heads up: this one will be muted by the phone mute switch. also, it's the default. so if you don't set anything, this is what you get. πŸ™ˆ
  • "playback" β€” use the AVAudioSessionCategoryPlayback category. no mute switch shenanigans here, it's giving main character energy. πŸ”₯

if you want more info (and honestly, Apple's docs are right there), see Apple's documentation: https://developer.apple.com/library/content/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/AudioSessionCategoriesandModes/AudioSessionCategoriesandModes.html

⚠️ and this is the important one, bestie: this hint should be set before an audio device is opened. not after. before. set it late and the universe simply will not cooperate, no cap. 😭

πŸ‘‘ AVAILABILITY πŸ‘‘

this hint is available since SDL 3.2.0. so if you're on something older... yeah, you're not getting this one. πŸ’€


and that's the page!! you understood all of it, i'm so proud, fr fr. 🫢✨

sending you love from the Simple Directmedia Layer girlies β€” this is SDL 3.4.18, and yeah the manual page header said SDL_HINT_AUDIO_CATEGORY(3) on it too, iconic. bye bestie, go set your audio category BEFORE you open the device!! πŸŽ€πŸ’œπŸ¦‹

πŸ“¦ where this page comes from