Wiki Page Content

Differences between revisions 2 and 3
Revision 2 as of 2009-11-15 02:35:24
Size: 1276
Editor: SheenaSmith
Comment: edit content
Revision 3 as of 2009-11-15 02:37:24
Size: 1277
Editor: ip68-4-123-62
Comment: Fixed typo in code example.
Deletions are marked like this. Additions are marked like this.
Line 25: Line 25:
    printf("Audio device %d: %s\n", i, SDL_GetAudioDeviceName(i, 0);     printf("Audio device %d: %s\n", i, SDL_GetAudioDeviceName(i, 0));
Line 32: Line 32:
Returning -1 is not an error. For example, if SDL is set up to talk to a remote audio server, it can't list every one available on the Internet, but it will still allow a specific host to be specified to [[SDL_OpenAudioDevice]](). Returning -1 is not an error. For example, if SDL is set up to talk to a remote audio server, it can't list every one available on the Internet, but it will still allow a specific host to be specified in [[SDL_OpenAudioDevice]]().

SDL_GetNumAudioDevices

Use this function to return the number of built in audio devices.

Syntax

int SDL_GetNumAudioDevices (int iscapture)

Function Parameters

iscapture

non-0 to specify a device that has recording capability

Return Value

The number of available devices exposed by the current driver or -1 if an explicit list of devices can't be determined.

Code Examples

int i, count = SDL_GetNumAudioDevices(0);

for ( i = 0; i < count; ++i ) {
    printf("Audio device %d: %s\n", i, SDL_GetAudioDeviceName(i, 0));
}

Remarks

This function is only valid after successfully initializing the audio subsystem.

Returning -1 is not an error. For example, if SDL is set up to talk to a remote audio server, it can't list every one available on the Internet, but it will still allow a specific host to be specified in SDL_OpenAudioDevice().

In many common cases, when this function returns a value <= 0, it can still successfully open the default device (NULL for first argument of SDL_OpenAudioDevice()).

None: SDL_GetNumAudioDevices (last edited 2016-05-14 22:17:17 by PhilippWiesemann)

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