Wiki Page Content

Differences between revisions 5 and 7 (spanning 2 versions)
Revision 5 as of 2011-01-04 19:18:10
Size: 1064
Editor: SheenaSmith
Comment: minor change for consistency
Revision 7 as of 2013-08-08 04:55:41
Size: 917
Editor: RyanGordon
Comment: tweaks
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
||<tablewidth="100%"style="color: rgb(255, 0, 0); text-align: center;">DRAFT||
Line 12: Line 11:
SDL_audiostatus SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev) SDL_AudioStatus SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev)
Line 16: Line 15:
||'''dev'''||the ID of ,,the,, ^an^ audio device ^previously opened with [[SDL_OpenAudioDevice]]()^||

<<Color2(green,Should SDL_Audio``DeviceID be specifically mentioned like a struct would be although it is a typedef? It has no page.)>>
||'''dev'''||the ID of an audio device previously opened with [[SDL_OpenAudioDevice]]()||
Line 21: Line 18:
Returns the status of the specified audio device which may be one of the following: Returns the [[SDL_AudioStatus]] of the specified audio device which may be one of the following:
Line 25: Line 22:
{{{#!highlight cpp
You can add your code example here
}}}
<<Include(SDL_AudioStatus, , , from="== Code Examples ==", to="== Remarks ==")>>
Line 30: Line 25:
''You can add useful comments here'' <<Include(SDL_AudioStatus, , , from="== Remarks ==", to="== Related Functions ==")>>
Line 33: Line 28:
 .[[SDL_GetAudioStatus]]  .[[SDL_PauseAudioDevice]]

SDL_GetAudioDeviceStatus

Use this function to get the current audio state of an audio device.

Syntax

SDL_AudioStatus SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev)

Function Parameters

dev

the ID of an audio device previously opened with SDL_OpenAudioDevice()

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(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 or unknown device ID will report STOPPED.


CategoryAPI, CategoryAudio

None: SDL_GetAudioDeviceStatus (last edited 2013-08-08 04:55:41 by RyanGordon)

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