Mercurial > sdl-ios-xcode
diff src/audio/macosx/SDL_coreaudio.c @ 3790:8f8209f8da6d SDL-ryan-multiple-audio-device
Added audio device enumeration for 1.3.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 03 Oct 2006 20:07:50 +0000 |
parents | 7006b176ef4f |
children | 866c310e2cb5 |
line wrap: on
line diff
--- a/src/audio/macosx/SDL_coreaudio.c Tue Oct 03 20:05:33 2006 +0000 +++ b/src/audio/macosx/SDL_coreaudio.c Tue Oct 03 20:07:50 2006 +0000 @@ -29,7 +29,7 @@ #include "../SDL_sysaudio.h" #include "SDL_coreaudio.h" -#define DEBUG_COREAUDIO 1 +#define DEBUG_COREAUDIO 0 typedef struct COREAUDIO_DeviceList { @@ -169,6 +169,22 @@ } } +static inline void +build_device_lists(void) +{ + build_device_list(0, &outputDevices, &outputDeviceCount); + build_device_list(1, &inputDevices, &inputDeviceCount); +} + + +static inline void +free_device_lists(void) +{ + free_device_list(&outputDevices, &outputDeviceCount); + free_device_list(&inputDevices, &inputDeviceCount); +} + + static int find_device_id(const char *devname, int iscapture, AudioDeviceID *id) { @@ -188,6 +204,8 @@ /* Audio driver functions */ +static int COREAUDIO_DetectDevices(int iscapture); +static const char *COREAUDIO_GetAudioDevice(int index, int iscapture); static int COREAUDIO_OpenAudio(_THIS, const char *devname, int iscapture); static void COREAUDIO_WaitAudio(_THIS); static void COREAUDIO_PlayAudio(_THIS); @@ -206,11 +224,9 @@ static int COREAUDIO_Init(SDL_AudioDriverImpl *impl) { - /* !!! FIXME: should these _really_ be static? */ - build_device_list(0, &outputDevices, &outputDeviceCount); - build_device_list(1, &inputDevices, &inputDeviceCount); - /* Set the function pointers */ + impl->DetectDevices = COREAUDIO_DetectDevices; + impl->GetAudioDevice = COREAUDIO_GetAudioDevice; impl->OpenAudio = COREAUDIO_OpenAudio; impl->WaitAudio = COREAUDIO_WaitAudio; impl->PlayAudio = COREAUDIO_PlayAudio; @@ -227,11 +243,39 @@ }; +static int +COREAUDIO_DetectDevices(int iscapture) +{ + if (iscapture) { + build_device_list(1, &inputDevices, &inputDeviceCount); + return inputDeviceCount; + } else { + build_device_list(0, &outputDevices, &outputDeviceCount); + return outputDeviceCount; + } + + return 0; /* shouldn't ever hit this. */ +} + + +static const char * +COREAUDIO_GetAudioDevice(int index, int iscapture) +{ + if ((iscapture) && (index < inputDeviceCount)) { + return inputDevices[index].name; + } else if ((!iscapture) && (index < outputDeviceCount)) { + return outputDevices[index].name; + } + + SDL_SetError("No such device"); + return NULL; +} + + static void COREAUDIO_Deinitialize(void) { - free_device_list(&outputDevices, &outputDeviceCount); - free_device_list(&inputDevices, &inputDeviceCount); + free_device_lists(); }