SDL Wiki
(This is the documentation for SDL3, which is under heavy development and the API is changing! SDL2 is the current stable version!)

SDL_GetAudioStatus

This function is a legacy means of querying the audio device.

Syntax

SDL_AudioStatus SDL_GetAudioStatus(void);

Return Value

Returns the SDL_AudioStatus of the audio device opened by SDL_OpenAudio().

Remarks

New programs might want to use SDL_GetAudioDeviceStatus() instead. This function is equivalent to calling...

SDL_GetAudioDeviceStatus(1);

...and is only useful if you used the legacy SDL_OpenAudio() function.

Version

This function is available since SDL 3.0.0.

Code Examples

void printStatus(void)
{
    switch (SDL_GetAudioStatus())
    {
        case SDL_AUDIO_STOPPED: printf("stopped\n"); break;
        case SDL_AUDIO_PLAYING: printf("playing\n"); break;
        case SDL_AUDIO_PAUSED: printf("paused\n"); break;
        default: printf("???"); break;
    }
}

extern SDL_AudioSpec desired;
extern SDL_AudioSpec obtained;

// device starts paused
if (SDL_OpenAudio(&desired, &obtained) == 0) {
     printStatus();  // prints "paused"
     SDL_PauseAudio(0);
     printStatus();  // prints "playing"
     SDL_PauseAudio(1);
     printStatus();  // prints "paused"
     SDL_CloseAudio();
     printStatus();  // prints "stopped"
}
SDL_GetAudioDeviceStatus

CategoryAPI, CategoryAudio


[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.