changeset 3792:866c310e2cb5 SDL-ryan-multiple-audio-device

Changed some 1.3 audio symbol names.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 03 Oct 2006 22:17:59 +0000
parents be33495e4d97
children 2b4795e92b62
files include/SDL_audio.h src/audio/SDL_audio.c src/audio/SDL_sysaudio.h src/audio/disk/SDL_diskaudio.c src/audio/dummy/SDL_dummyaudio.c src/audio/macosx/SDL_coreaudio.c src/audio/macrom/SDL_romaudio.c test/testaudioinfo.c
diffstat 8 files changed, 101 insertions(+), 102 deletions(-) [+]
line wrap: on
line diff
--- a/include/SDL_audio.h	Tue Oct 03 20:48:42 2006 +0000
+++ b/include/SDL_audio.h	Tue Oct 03 22:17:59 2006 +0000
@@ -251,8 +251,8 @@
  *  string for any length of time, you should make your own copy of it, as it
  *  will be invalid next time any of several other SDL functions is called.
  */
-extern DECLSPEC const char *SDLCALL SDL_GetAudioDevice(int index,
-                                                       int iscapture);
+extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index,
+                                                           int iscapture);
 
 
 /*
--- a/src/audio/SDL_audio.c	Tue Oct 03 20:48:42 2006 +0000
+++ b/src/audio/SDL_audio.c	Tue Oct 03 22:17:59 2006 +0000
@@ -230,7 +230,7 @@
                 continue;
             }
         } else {
-            stream = current_audio.impl.GetAudioBuf(device);
+            stream = current_audio.impl.GetDeviceBuf(device);
             if (stream == NULL) {
                 stream = device->fake_stream;
             }
@@ -250,7 +250,7 @@
         /* Convert the audio if necessary */
         if (device->convert.needed) {
             SDL_ConvertAudio(&device->convert);
-            stream = current_audio.impl.GetAudioBuf(device);
+            stream = current_audio.impl.GetDeviceBuf(device);
             if (stream == NULL) {
                 stream = device->fake_stream;
             }
@@ -259,14 +259,14 @@
 
         /* Ready current buffer for play and change current buffer */
         if (stream != device->fake_stream) {
-            current_audio.impl.PlayAudio(device);
+            current_audio.impl.PlayDevice(device);
         }
 
         /* Wait for an audio buffer to become available */
         if (stream == device->fake_stream) {
             SDL_Delay((device->spec.samples * 1000) / device->spec.freq);
         } else {
-            current_audio.impl.WaitAudio(device);
+            current_audio.impl.WaitDevice(device);
         }
     }
 
@@ -275,11 +275,11 @@
         current_audio.impl.WaitDone(device);
     }
 #if SDL_AUDIO_DRIVER_AHI
-    D(bug("WaitAudio...Done\n"));
+    D(bug("WaitDevice...Done\n"));
 
-    audio->CloseAudio(audio);
+    audio->CloseDevice(audio);
 
-    D(bug("CloseAudio..Done, subtask exiting...\n"));
+    D(bug("CloseDevice..Done, subtask exiting...\n"));
     audio_configured = 0;
 #endif
 #ifdef __OS2__
@@ -291,7 +291,7 @@
 }
 
 static void
-SDL_LockAudio_Default(SDL_AudioDevice * audio)
+SDL_LockDevice_Default(SDL_AudioDevice * audio)
 {
     if (audio->thread && (SDL_ThreadID() == audio->threadid)) {
         return;
@@ -300,7 +300,7 @@
 }
 
 static void
-SDL_UnlockAudio_Default(SDL_AudioDevice * audio)
+SDL_UnlockDevice_Default(SDL_AudioDevice * audio)
 {
     if (audio->thread && (SDL_ThreadID() == audio->threadid)) {
         return;
@@ -438,9 +438,9 @@
         }
     }
 
-    if (!current_audio.impl.LockAudio && !current_audio.impl.UnlockAudio) {
-        current_audio.impl.LockAudio = SDL_LockAudio_Default;
-        current_audio.impl.UnlockAudio = SDL_UnlockAudio_Default;
+    if (!current_audio.impl.LockDevice && !current_audio.impl.UnlockDevice) {
+        current_audio.impl.LockDevice = SDL_LockDevice_Default;
+        current_audio.impl.UnlockDevice = SDL_UnlockDevice_Default;
     }
 
     return (0);
@@ -467,19 +467,19 @@
 
 
 const char *
-SDL_GetAudioDevice(int index, int iscapture)
+SDL_GetAudioDeviceName(int index, int iscapture)
 {
     if (!SDL_WasInit(SDL_INIT_AUDIO)) {
         SDL_SetError("Audio subsystem is not initialized");
         return NULL;
     }
 
-    if ((index < 0) && (!current_audio.impl.GetAudioDevice)) {
+    if ((index < 0) && (!current_audio.impl.GetDeviceName)) {
         SDL_SetError("No such device");
         return NULL;
     }
 
-    return current_audio.impl.GetAudioDevice(index, iscapture);
+    return current_audio.impl.GetDeviceName(index, iscapture);
 }
 
 
@@ -501,7 +501,7 @@
     }
 #if !SDL_AUDIO_DRIVER_AHI   /* !!! FIXME: get rid of this #if. */
     if (device->opened) {
-        current_audio.impl.CloseAudio(device);
+        current_audio.impl.CloseDevice(device);
         device->opened = 0;
     }
 #endif
@@ -632,7 +632,7 @@
 /* !!! FIXME: Get this #if out of the core. */
 /* AmigaOS opens audio inside the main loop */
 #if !SDL_AUDIO_DRIVER_AHI
-    if (!current_audio.impl.OpenAudio(device, devname, iscapture)) {
+    if (!current_audio.impl.OpenDevice(device, devname, iscapture)) {
         close_audio_device(device);
         return 0;
     }
@@ -824,11 +824,11 @@
 void
 SDL_LockAudioDevice(SDL_AudioDeviceID devid)
 {
-    if (current_audio.impl.LockAudio != NULL) {
+    if (current_audio.impl.LockDevice != NULL) {
         SDL_AudioDevice *device = get_audio_device(devid);
         /* Obtain a lock on the mixing buffers */
         if (device) {
-            current_audio.impl.LockAudio(device);
+            current_audio.impl.LockDevice(device);
         }
     }
 }
@@ -842,11 +842,11 @@
 void
 SDL_UnlockAudioDevice(SDL_AudioDeviceID devid)
 {
-    if (current_audio.impl.UnlockAudio != NULL) {
+    if (current_audio.impl.UnlockDevice != NULL) {
         SDL_AudioDevice *device = get_audio_device(devid);
         /* Obtain a lock on the mixing buffers */
         if (device) {
-            current_audio.impl.UnlockAudio(device);
+            current_audio.impl.UnlockDevice(device);
         }
     }
 }
--- a/src/audio/SDL_sysaudio.h	Tue Oct 03 20:48:42 2006 +0000
+++ b/src/audio/SDL_sysaudio.h	Tue Oct 03 22:17:59 2006 +0000
@@ -35,16 +35,16 @@
 typedef struct SDL_AudioDriverImpl
 {
     int (*DetectDevices)(int iscapture);
-    const char *(*GetAudioDevice)(int index, int iscapture);
-    int (*OpenAudio) (_THIS, const char *devname, int iscapture);
+    const char *(*GetDeviceName)(int index, int iscapture);
+    int (*OpenDevice) (_THIS, const char *devname, int iscapture);
     void (*ThreadInit) (_THIS); /* Called by audio thread at start */
-    void (*WaitAudio) (_THIS);
-    void (*PlayAudio) (_THIS);
-    Uint8 *(*GetAudioBuf) (_THIS);
+    void (*WaitDevice) (_THIS);
+    void (*PlayDevice) (_THIS);
+    Uint8 *(*GetDeviceBuf) (_THIS);
     void (*WaitDone) (_THIS);
-    void (*CloseAudio) (_THIS);
-    void (*LockAudio) (_THIS);
-    void (*UnlockAudio) (_THIS);
+    void (*CloseDevice) (_THIS);
+    void (*LockDevice) (_THIS);
+    void (*UnlockDevice) (_THIS);
     void (*Deinitialize) (void);
 } SDL_AudioDriverImpl;
 
--- a/src/audio/disk/SDL_diskaudio.c	Tue Oct 03 20:48:42 2006 +0000
+++ b/src/audio/disk/SDL_diskaudio.c	Tue Oct 03 22:17:59 2006 +0000
@@ -47,11 +47,11 @@
 #define DISKDEFAULT_WRITEDELAY   150
 
 /* Audio driver functions */
-static int DISKAUD_OpenAudio(_THIS, const char *devname, int iscapture);
-static void DISKAUD_WaitAudio(_THIS);
-static void DISKAUD_PlayAudio(_THIS);
-static Uint8 *DISKAUD_GetAudioBuf(_THIS);
-static void DISKAUD_CloseAudio(_THIS);
+static int DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture);
+static void DISKAUD_WaitDevice(_THIS);
+static void DISKAUD_PlayDevice(_THIS);
+static Uint8 *DISKAUD_GetDeviceBuf(_THIS);
+static void DISKAUD_CloseDevice(_THIS);
 
 static const char *
 DISKAUD_GetOutputFilename(void)
@@ -80,11 +80,11 @@
     SDL_memset(impl, '\0', sizeof (SDL_AudioDriverImpl));
 
     /* Set the function pointers */
-    impl->OpenAudio = DISKAUD_OpenAudio;
-    impl->WaitAudio = DISKAUD_WaitAudio;
-    impl->PlayAudio = DISKAUD_PlayAudio;
-    impl->GetAudioBuf = DISKAUD_GetAudioBuf;
-    impl->CloseAudio = DISKAUD_CloseAudio;
+    impl->OpenDevice = DISKAUD_OpenDevice;
+    impl->WaitDevice = DISKAUD_WaitDevice;
+    impl->PlayDevice = DISKAUD_PlayDevice;
+    impl->GetDeviceBuf = DISKAUD_GetDeviceBuf;
+    impl->CloseDevice = DISKAUD_CloseDevice;
 
     return 1;
 }
@@ -96,13 +96,13 @@
 
 /* This function waits until it is possible to write a full sound buffer */
 static void
-DISKAUD_WaitAudio(_THIS)
+DISKAUD_WaitDevice(_THIS)
 {
     SDL_Delay(this->hidden->write_delay);
 }
 
 static void
-DISKAUD_PlayAudio(_THIS)
+DISKAUD_PlayDevice(_THIS)
 {
     int written;
 
@@ -120,13 +120,13 @@
 }
 
 static Uint8 *
-DISKAUD_GetAudioBuf(_THIS)
+DISKAUD_GetDeviceBuf(_THIS)
 {
     return (this->hidden->mixbuf);
 }
 
 static void
-DISKAUD_CloseAudio(_THIS)
+DISKAUD_CloseDevice(_THIS)
 {
     if (this->hidden->mixbuf != NULL) {
         SDL_FreeAudioMem(this->hidden->mixbuf);
@@ -141,7 +141,7 @@
 }
 
 static int
-DISKAUD_OpenAudio(_THIS, const char *devname, int iscapture)
+DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture)
 {
     const char *envr = SDL_getenv(DISKENVR_WRITEDELAY);
     const char *fname = DISKAUD_GetOutputFilename();
@@ -163,14 +163,14 @@
     /* Open the audio device */
     this->hidden->output = SDL_RWFromFile(fname, "wb");
     if (this->hidden->output == NULL) {
-        DISKAUD_CloseAudio(this);
+        DISKAUD_CloseDevice(this);
         return 0;
     }
 
     /* Allocate mixing buffer */
     this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
     if (this->hidden->mixbuf == NULL) {
-        DISKAUD_CloseAudio(this);
+        DISKAUD_CloseDevice(this);
         return 0;
     }
     SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
--- a/src/audio/dummy/SDL_dummyaudio.c	Tue Oct 03 20:48:42 2006 +0000
+++ b/src/audio/dummy/SDL_dummyaudio.c	Tue Oct 03 22:17:59 2006 +0000
@@ -37,11 +37,11 @@
 #define DUMMYAUD_DRIVER_NAME         "dummy"
 
 /* Audio driver functions */
-static int DUMMYAUD_OpenAudio(_THIS, const char *devname, int iscapture);
-static void DUMMYAUD_WaitAudio(_THIS);
-static void DUMMYAUD_PlayAudio(_THIS);
-static Uint8 *DUMMYAUD_GetAudioBuf(_THIS);
-static void DUMMYAUD_CloseAudio(_THIS);
+static int DUMMYAUD_OpenDevice(_THIS, const char *devname, int iscapture);
+static void DUMMYAUD_WaitDevice(_THIS);
+static void DUMMYAUD_PlayDevice(_THIS);
+static Uint8 *DUMMYAUD_GetDeviceBuf(_THIS);
+static void DUMMYAUD_CloseDevice(_THIS);
 
 /* Audio driver bootstrap functions */
 static int
@@ -60,11 +60,11 @@
 DUMMYAUD_Init(SDL_AudioDriverImpl *impl)
 {
     /* Set the function pointers */
-    impl->OpenAudio = DUMMYAUD_OpenAudio;
-    impl->WaitAudio = DUMMYAUD_WaitAudio;
-    impl->PlayAudio = DUMMYAUD_PlayAudio;
-    impl->GetAudioBuf = DUMMYAUD_GetAudioBuf;
-    impl->CloseAudio = DUMMYAUD_CloseAudio;
+    impl->OpenDevice = DUMMYAUD_OpenDevice;
+    impl->WaitDevice = DUMMYAUD_WaitDevice;
+    impl->PlayDevice = DUMMYAUD_PlayDevice;
+    impl->GetDeviceBuf = DUMMYAUD_GetDeviceBuf;
+    impl->CloseDevice = DUMMYAUD_CloseDevice;
 
     return 1;
 }
@@ -76,7 +76,7 @@
 
 /* This function waits until it is possible to write a full sound buffer */
 static void
-DUMMYAUD_WaitAudio(_THIS)
+DUMMYAUD_WaitDevice(_THIS)
 {
     /* Don't block on first calls to simulate initial fragment filling. */
     if (this->hidden->initial_calls)
@@ -86,19 +86,19 @@
 }
 
 static void
-DUMMYAUD_PlayAudio(_THIS)
+DUMMYAUD_PlayDevice(_THIS)
 {
     /* no-op...this is a null driver. */
 }
 
 static Uint8 *
-DUMMYAUD_GetAudioBuf(_THIS)
+DUMMYAUD_GetDeviceBuf(_THIS)
 {
     return (this->hidden->mixbuf);
 }
 
 static void
-DUMMYAUD_CloseAudio(_THIS)
+DUMMYAUD_CloseDevice(_THIS)
 {
     if (this->hidden->mixbuf != NULL) {
         SDL_FreeAudioMem(this->hidden->mixbuf);
@@ -109,7 +109,7 @@
 }
 
 static int
-DUMMYAUD_OpenAudio(_THIS, const char *devname, int iscapture)
+DUMMYAUD_OpenDevice(_THIS, const char *devname, int iscapture)
 {
     float bytes_per_sec = 0.0f;
 
@@ -126,7 +126,7 @@
     this->hidden->mixlen = this->spec.size;
     this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
     if (this->hidden->mixbuf == NULL) {
-        DUMMYAUD_CloseAudio(this);
+        DUMMYAUD_CloseDevice(this);
         return 0;
     }
     SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
--- a/src/audio/macosx/SDL_coreaudio.c	Tue Oct 03 20:48:42 2006 +0000
+++ b/src/audio/macosx/SDL_coreaudio.c	Tue Oct 03 22:17:59 2006 +0000
@@ -205,12 +205,12 @@
 /* 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);
-static Uint8 *COREAUDIO_GetAudioBuf(_THIS);
-static void COREAUDIO_CloseAudio(_THIS);
+static const char *COREAUDIO_GetDeviceName(int index, int iscapture);
+static int COREAUDIO_OpenDevice(_THIS, const char *devname, int iscapture);
+static void COREAUDIO_WaitDevice(_THIS);
+static void COREAUDIO_PlayDevice(_THIS);
+static Uint8 *COREAUDIO_GetDeviceBuf(_THIS);
+static void COREAUDIO_CloseDevice(_THIS);
 static void COREAUDIO_Deinitialize(void);
 
 /* Audio driver bootstrap functions */
@@ -226,12 +226,12 @@
 {
     /* Set the function pointers */
     impl->DetectDevices = COREAUDIO_DetectDevices;
-    impl->GetAudioDevice = COREAUDIO_GetAudioDevice;
-    impl->OpenAudio = COREAUDIO_OpenAudio;
-    impl->WaitAudio = COREAUDIO_WaitAudio;
-    impl->PlayAudio = COREAUDIO_PlayAudio;
-    impl->GetAudioBuf = COREAUDIO_GetAudioBuf;
-    impl->CloseAudio = COREAUDIO_CloseAudio;
+    impl->GetDeviceName = COREAUDIO_GetDeviceName;
+    impl->OpenDevice = COREAUDIO_OpenDevice;
+    impl->WaitDevice = COREAUDIO_WaitDevice;
+    impl->PlayDevice = COREAUDIO_PlayDevice;
+    impl->GetDeviceBuf = COREAUDIO_GetDeviceBuf;
+    impl->CloseDevice = COREAUDIO_CloseDevice;
     impl->Deinitialize = COREAUDIO_Deinitialize;
 
     return 1;
@@ -259,7 +259,7 @@
 
 
 static const char *
-COREAUDIO_GetAudioDevice(int index, int iscapture)
+COREAUDIO_GetDeviceName(int index, int iscapture)
 {
     if ((iscapture) && (index < inputDeviceCount)) {
         return inputDevices[index].name;
@@ -357,25 +357,25 @@
 
 /* Dummy functions -- we don't use thread-based audio */
 void
-COREAUDIO_WaitAudio(_THIS)
+COREAUDIO_WaitDevice(_THIS)
 {
     return;
 }
 
 void
-COREAUDIO_PlayAudio(_THIS)
+COREAUDIO_PlayDevice(_THIS)
 {
     return;
 }
 
 Uint8 *
-COREAUDIO_GetAudioBuf(_THIS)
+COREAUDIO_GetDeviceBuf(_THIS)
 {
     return (NULL);
 }
 
 void
-COREAUDIO_CloseAudio(_THIS)
+COREAUDIO_CloseDevice(_THIS)
 {
     if (this->hidden != NULL) {
         OSStatus result = noErr;
@@ -407,7 +407,7 @@
 
 #define CHECK_RESULT(msg) \
     if (result != noErr) { \
-        COREAUDIO_CloseAudio(this); \
+        COREAUDIO_CloseDevice(this); \
         SDL_SetError("CoreAudio error (%s): %d", msg, (int) result); \
         return 0; \
     }
@@ -556,7 +556,7 @@
 
 
 int
-COREAUDIO_OpenAudio(_THIS, const char *devname, int iscapture)
+COREAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
 {
     AudioStreamBasicDescription strdesc;
     SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
--- a/src/audio/macrom/SDL_romaudio.c	Tue Oct 03 20:48:42 2006 +0000
+++ b/src/audio/macrom/SDL_romaudio.c	Tue Oct 03 22:17:59 2006 +0000
@@ -52,14 +52,13 @@
 
 /* Audio driver functions */
 
-static void SNDMGR_CloseAudio(_THIS);
-static int SNDMGR_OpenAudio(_THIS, const char *devname, int iscapture);
-static void SNDMGR_LockAudio(_THIS);
-static void SNDMGR_UnlockAudio(_THIS);
+static void SNDMGR_CloseDevice(_THIS);
+static int SNDMGR_OpenDevice(_THIS, const char *devname, int iscapture);
+static void SNDMGR_LockDevice(_THIS);
+static void SNDMGR_UnlockDevice(_THIS);
 
 /* Audio driver bootstrap functions */
 
-
 static int
 SNDMGR_Available(void)
 {
@@ -71,14 +70,14 @@
 SNDMGR_Init(SDL_AudioDriverImpl *impl)
 {
     /* Set the function pointers */
-    impl->OpenAudio = SNDMGR_OpenAudio;
-    impl->CloseAudio = SNDMGR_CloseAudio;
-    impl->LockAudio = SNDMGR_LockAudio;
-    impl->UnlockAudio = SNDMGR_UnlockAudio;
+    impl->OpenDevice = SNDMGR_OpenDevice;
+    impl->CloseDevice = SNDMGR_CloseDevice;
+    impl->LockDevice = SNDMGR_LockDevice;
+    impl->UnlockDevice = SNDMGR_UnlockDevice;
 
 #ifdef __MACOSX__               /* Mac OS X uses threaded audio, so normal thread code is okay */
-    impl->LockAudio = NULL;
-    impl->UnlockAudio = NULL;
+    impl->LockDevice = NULL;
+    impl->UnlockDevice = NULL;
 #endif
 
     return 1;
@@ -129,13 +128,13 @@
 }
 
 static void
-SNDMGR_LockAudio(_THIS)
+SNDMGR_LockDevice(_THIS)
 {
     IncrementAtomic((SInt32 *) & audio_is_locked);
 }
 
 static void
-SNDMGR_UnlockAudio(_THIS)
+SNDMGR_UnlockDevice(_THIS)
 {
     SInt32 oldval;
 
@@ -198,7 +197,7 @@
 }
 
 static int
-SNDMGR_OpenAudio(_THIS, const char *devname, int iscapture)
+SNDMGR_OpenDevice(_THIS, const char *devname, int iscapture)
 {
     SDL_AudioSpec *spec = &this->spec;
     SndChannelPtr channel = NULL;
@@ -284,7 +283,7 @@
     for (i = 0; i < 2; i++) {
         buffer[i] = (UInt8 *) malloc(sizeof(UInt8) * spec->size);
         if (buffer[i] == NULL) {
-            SNDMGR_CloseAudio(this);
+            SNDMGR_CloseDevice(this);
             SDL_OutOfMemory();
             return 0;
         }
@@ -294,7 +293,7 @@
     /* Create the sound manager channel */
     channel = (SndChannelPtr) SDL_malloc(sizeof(*channel));
     if (channel == NULL) {
-        SNDMGR_CloseAudio(this);
+        SNDMGR_CloseDevice(this);
         SDL_OutOfMemory();
         return 0;
     }
@@ -307,7 +306,7 @@
     channel->userInfo = (long) this;
     channel->qLength = 128;
     if (SndNewChannel(&channel, sampledSynth, initOptions, callback) != noErr) {
-        SNDMGR_CloseAudio(this);
+        SNDMGR_CloseDevice(this);
         SDL_SetError("Unable to create audio channel");
         return 0;
     }
@@ -326,7 +325,7 @@
 }
 
 static void
-SNDMGR_CloseAudio(_THIS)
+SNDMGR_CloseDevice(_THIS)
 {
 
     int i;
--- a/test/testaudioinfo.c	Tue Oct 03 20:48:42 2006 +0000
+++ b/test/testaudioinfo.c	Tue Oct 03 22:17:59 2006 +0000
@@ -12,7 +12,7 @@
         int i;
         printf("%s devices:\n", typestr);
         for (i = 0; i < n; i++) {
-            printf("  %s\n", SDL_GetAudioDevice(i, iscapture));
+            printf("  %s\n", SDL_GetAudioDeviceName(i, iscapture));
         }
         printf("\n");
     }