Wiki Page Content

Differences between revisions 7 and 8
Revision 7 as of 2013-07-29 16:11:07
Size: 1344
Editor: RyanGordon
Comment: Added example code.
Revision 8 as of 2013-07-29 16:12:45
Size: 1489
Editor: RyanGordon
Comment: Added remarks.
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
An enumeration of audio device states. Opened devices are always PLAYING or PAUSED in normal circumstances. An enumeration of audio device states.
Line 43: Line 43:
''You can add useful comments here'' Opened devices are always PLAYING or PAUSED in normal circumstances. A failing device may change its status to STOPPED at any time, and closing a device will progress to STOPPED, too. Asking for the state on an unopened device ID will report STOPPED.

SDL_AudioStatus

An enumeration of audio device states.

Values

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(SDL_AudioDeviceID dev)
{
    switch (SDL_GetAudioDeviceStatus(dev))
    {
        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;
    }
}

// device starts paused
SDL_AudioDeviceID dev;
dev = SDL_OpenAudioDevice(NULL, 0, &desired, &obtained, 0);  
if (dev != 0)
{
     printStatus(dev);  // prints "paused"
     SDL_PauseAudioDevice(dev, 0);
     printStatus(dev);  // prints "playing"
     SDL_PauseAudioDevice(dev, 1);
     printStatus(dev);  // prints "paused"
     SDL_CloseAudioDevice(dev);
     printStatus(dev);  // prints "stopped"
}

Remarks

Opened devices are always PLAYING or PAUSED in normal circumstances. A failing device may change its status to STOPPED at any time, and closing a device will progress to STOPPED, too. Asking for the state on an unopened device ID will report STOPPED.


CategoryEnum, CategoryAudio

None: SDL_AudioStatus (last edited 2013-09-16 19:04:47 by PhilippWiesemann)

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