SDL_RemoveAudioDevice() should specify capture vs output.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 19 Mar 2015 15:43:00 -0400
changeset 9399 a684dbd185c7
parent 9398 c41dd34e4996
child 9400 6f662d802380
SDL_RemoveAudioDevice() should specify capture vs output. This lets us reuse values between the two categories without conflicting, etc.
src/audio/SDL_audio.c
src/audio/SDL_sysaudio.h
src/audio/coreaudio/SDL_coreaudio.c
src/audio/winmm/SDL_winmm.c
--- a/src/audio/SDL_audio.c	Thu Mar 19 13:34:17 2015 -0400
+++ b/src/audio/SDL_audio.c	Thu Mar 19 15:43:00 2015 -0400
@@ -400,11 +400,14 @@
 
 /* The audio backends call this when a device is removed from the system. */
 void
-SDL_RemoveAudioDevice(void *handle)
+SDL_RemoveAudioDevice(const int iscapture, void *handle)
 {
     SDL_LockMutex(current_audio.detectionLock);
-    mark_device_removed(handle, current_audio.inputDevices, &current_audio.captureDevicesRemoved);
-    mark_device_removed(handle, current_audio.outputDevices, &current_audio.outputDevicesRemoved);
+    if (iscapture) {
+        mark_device_removed(handle, current_audio.inputDevices, &current_audio.captureDevicesRemoved);
+    } else {
+        mark_device_removed(handle, current_audio.outputDevices, &current_audio.outputDevicesRemoved);
+    }
     SDL_UnlockMutex(current_audio.detectionLock);
     current_audio.impl.FreeDeviceHandle(handle);
 }
--- a/src/audio/SDL_sysaudio.h	Thu Mar 19 13:34:17 2015 -0400
+++ b/src/audio/SDL_sysaudio.h	Thu Mar 19 15:43:00 2015 -0400
@@ -37,7 +37,7 @@
 
 /* Audio targets should call this as devices are removed, so SDL can update
    its list of available devices. */
-extern void SDL_RemoveAudioDevice(void *handle);
+extern void SDL_RemoveAudioDevice(const int iscapture, void *handle);
 
 /* Audio targets should call this if an opened audio device is lost while
    being used. This can happen due to i/o errors, or a device being unplugged,
--- a/src/audio/coreaudio/SDL_coreaudio.c	Thu Mar 19 13:34:17 2015 -0400
+++ b/src/audio/coreaudio/SDL_coreaudio.c	Thu Mar 19 15:43:00 2015 -0400
@@ -246,7 +246,7 @@
         if (item->alive) {
             prev = item;
         } else {
-            SDL_RemoveAudioDevice((void *) ((size_t) item->devid));
+            SDL_RemoveAudioDevice(iscapture, (void *) ((size_t) item->devid));
             if (prev) {
                 prev->next = item->next;
             } else {
--- a/src/audio/winmm/SDL_winmm.c	Thu Mar 19 13:34:17 2015 -0400
+++ b/src/audio/winmm/SDL_winmm.c	Thu Mar 19 15:43:00 2015 -0400
@@ -47,7 +47,7 @@
         if (wave##typ##GetDevCaps(i,&caps,sizeof(caps))==MMSYSERR_NOERROR) { \
             char *name = WIN_StringToUTF8(caps.szPname); \
             if (name != NULL) { \
-                SDL_AddAudioDevice((int) iscapture, name, (void *) ((size_t) i|(iscap<<31))); \
+                SDL_AddAudioDevice((int) iscapture, name, (void *) ((size_t) i)); \
                 SDL_free(name); \
             } \
         } \
@@ -232,11 +232,6 @@
     if (handle != NULL) {  /* specific device requested? */
         const size_t val = (size_t) handle;
         devId = (UINT) val;
-        if (iscapture) {
-            /* we use the top bit to make value unique vs output indices. */
-            SDL_assert((devId & (1<<31)) != 0);
-            devId &= ~(1<<31);
-        }
     }
 
     /* Initialize all variables that we clean on shutdown */