Wiki Page Content

SDL_GetAudioStatus

This function is a legacy means of querying the audio device. New programs might want to use SDL_GetAudioDeviceStatus() instead.

Syntax

SDL_AudioStatus SDL_GetAudioStatus(void)

Return Value

Returns the SDL_AudioStatus of the specified audio device which may be one of the following:

SDL_AUDIO_STOPPED

audio device is stopped

SDL_AUDIO_PLAYING

audio device is playing

SDL_AUDIO_PAUSED

audio device is paused

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"
}

Remarks

This function is equivalent to calling

SDL_GetAudioDeviceStatus(1);

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


CategoryAPI, CategoryAudio

None: SDL_GetAudioStatus (last edited 2013-08-10 18:59:47 by PhilippWiesemann)

Feedback
Please include your contact information if you'd like to receive a reply.
Submit