coreaudio: Add support for SDL_GetDefaultAudioInfo (#6277)

Co-authored-by: Ethan Lee <flibitijibibo@gmail.com>
Co-authored-by: Ozkan Sezer <sezeroz@gmail.com>
This commit is contained in:
Jarod Hillman
2022-09-29 10:33:07 -04:00
committed by Ethan Lee
parent 69bbe4ce7d
commit 40893821f2
2 changed files with 159 additions and 0 deletions

View File

@@ -40,6 +40,8 @@ print_devices(int iscapture)
int
main(int argc, char **argv)
{
char *deviceName;
SDL_AudioSpec spec;
int n;
/* Enable standard application logging */
@@ -69,6 +71,27 @@ main(int argc, char **argv)
print_devices(0);
print_devices(1);
if (SDL_GetDefaultAudioInfo(&deviceName, &spec, 0) < 0) {
SDL_Log("Error when calling SDL_GetDefaultAudioInfo: %s\n", SDL_GetError());
} else {
SDL_Log("Default Output Name: %s\n", deviceName != NULL ? deviceName : "unknown");
SDL_free(deviceName);
SDL_Log("Sampling Rate: %d\n", spec.freq);
SDL_Log("Number of Channels: %d\n", spec.channels);
SDL_Log("Audio Format: %d\n", spec.format);
}
if (SDL_GetDefaultAudioInfo(&deviceName, &spec, 1) < 0) {
SDL_Log("Error when calling SDL_GetDefaultAudioInfo: %s\n", SDL_GetError());
} else {
SDL_Log("Default Capture Name: %s\n", deviceName != NULL ? deviceName : "unknown");
SDL_free(deviceName);
SDL_Log("Sampling Rate: %d\n", spec.freq);
SDL_Log("Number of Channels: %d\n", spec.channels);
SDL_Log("Audio Format: %d\n", spec.format);
}
SDL_Quit();
return 0;
}