SDL_RemoveAudioDevice() should specify capture vs output.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 19 Mar 2015 15:43:00 -0400
changeset 9399a684dbd185c7
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
     1.1 --- a/src/audio/SDL_audio.c	Thu Mar 19 13:34:17 2015 -0400
     1.2 +++ b/src/audio/SDL_audio.c	Thu Mar 19 15:43:00 2015 -0400
     1.3 @@ -400,11 +400,14 @@
     1.4  
     1.5  /* The audio backends call this when a device is removed from the system. */
     1.6  void
     1.7 -SDL_RemoveAudioDevice(void *handle)
     1.8 +SDL_RemoveAudioDevice(const int iscapture, void *handle)
     1.9  {
    1.10      SDL_LockMutex(current_audio.detectionLock);
    1.11 -    mark_device_removed(handle, current_audio.inputDevices, &current_audio.captureDevicesRemoved);
    1.12 -    mark_device_removed(handle, current_audio.outputDevices, &current_audio.outputDevicesRemoved);
    1.13 +    if (iscapture) {
    1.14 +        mark_device_removed(handle, current_audio.inputDevices, &current_audio.captureDevicesRemoved);
    1.15 +    } else {
    1.16 +        mark_device_removed(handle, current_audio.outputDevices, &current_audio.outputDevicesRemoved);
    1.17 +    }
    1.18      SDL_UnlockMutex(current_audio.detectionLock);
    1.19      current_audio.impl.FreeDeviceHandle(handle);
    1.20  }
     2.1 --- a/src/audio/SDL_sysaudio.h	Thu Mar 19 13:34:17 2015 -0400
     2.2 +++ b/src/audio/SDL_sysaudio.h	Thu Mar 19 15:43:00 2015 -0400
     2.3 @@ -37,7 +37,7 @@
     2.4  
     2.5  /* Audio targets should call this as devices are removed, so SDL can update
     2.6     its list of available devices. */
     2.7 -extern void SDL_RemoveAudioDevice(void *handle);
     2.8 +extern void SDL_RemoveAudioDevice(const int iscapture, void *handle);
     2.9  
    2.10  /* Audio targets should call this if an opened audio device is lost while
    2.11     being used. This can happen due to i/o errors, or a device being unplugged,
     3.1 --- a/src/audio/coreaudio/SDL_coreaudio.c	Thu Mar 19 13:34:17 2015 -0400
     3.2 +++ b/src/audio/coreaudio/SDL_coreaudio.c	Thu Mar 19 15:43:00 2015 -0400
     3.3 @@ -246,7 +246,7 @@
     3.4          if (item->alive) {
     3.5              prev = item;
     3.6          } else {
     3.7 -            SDL_RemoveAudioDevice((void *) ((size_t) item->devid));
     3.8 +            SDL_RemoveAudioDevice(iscapture, (void *) ((size_t) item->devid));
     3.9              if (prev) {
    3.10                  prev->next = item->next;
    3.11              } else {
     4.1 --- a/src/audio/winmm/SDL_winmm.c	Thu Mar 19 13:34:17 2015 -0400
     4.2 +++ b/src/audio/winmm/SDL_winmm.c	Thu Mar 19 15:43:00 2015 -0400
     4.3 @@ -47,7 +47,7 @@
     4.4          if (wave##typ##GetDevCaps(i,&caps,sizeof(caps))==MMSYSERR_NOERROR) { \
     4.5              char *name = WIN_StringToUTF8(caps.szPname); \
     4.6              if (name != NULL) { \
     4.7 -                SDL_AddAudioDevice((int) iscapture, name, (void *) ((size_t) i|(iscap<<31))); \
     4.8 +                SDL_AddAudioDevice((int) iscapture, name, (void *) ((size_t) i)); \
     4.9                  SDL_free(name); \
    4.10              } \
    4.11          } \
    4.12 @@ -232,11 +232,6 @@
    4.13      if (handle != NULL) {  /* specific device requested? */
    4.14          const size_t val = (size_t) handle;
    4.15          devId = (UINT) val;
    4.16 -        if (iscapture) {
    4.17 -            /* we use the top bit to make value unique vs output indices. */
    4.18 -            SDL_assert((devId & (1<<31)) != 0);
    4.19 -            devId &= ~(1<<31);
    4.20 -        }
    4.21      }
    4.22  
    4.23      /* Initialize all variables that we clean on shutdown */