SDL_RemoveAudioDevice() should specify capture vs output. This lets us reuse values between the two categories without conflicting, etc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index af91753..eafeb33 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -400,11 +400,14 @@ mark_device_removed(void *handle, SDL_AudioDeviceItem *devices, SDL_bool *remove
/* 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, ¤t_audio.captureDevicesRemoved);
- mark_device_removed(handle, current_audio.outputDevices, ¤t_audio.outputDevicesRemoved);
+ if (iscapture) {
+ mark_device_removed(handle, current_audio.inputDevices, ¤t_audio.captureDevicesRemoved);
+ } else {
+ mark_device_removed(handle, current_audio.outputDevices, ¤t_audio.outputDevicesRemoved);
+ }
SDL_UnlockMutex(current_audio.detectionLock);
current_audio.impl.FreeDeviceHandle(handle);
}
diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h
index a339f81..2b4e956 100644
--- a/src/audio/SDL_sysaudio.h
+++ b/src/audio/SDL_sysaudio.h
@@ -37,7 +37,7 @@ extern void SDL_AddAudioDevice(const int iscapture, const char *name, void *hand
/* 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,
diff --git a/src/audio/coreaudio/SDL_coreaudio.c b/src/audio/coreaudio/SDL_coreaudio.c
index afd2565..22210b0 100644
--- a/src/audio/coreaudio/SDL_coreaudio.c
+++ b/src/audio/coreaudio/SDL_coreaudio.c
@@ -246,7 +246,7 @@ reprocess_device_list(const int iscapture, AudioDeviceList **list)
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 {
diff --git a/src/audio/winmm/SDL_winmm.c b/src/audio/winmm/SDL_winmm.c
index bd795cf..8bc86b8 100644
--- a/src/audio/winmm/SDL_winmm.c
+++ b/src/audio/winmm/SDL_winmm.c
@@ -47,7 +47,7 @@ static void DetectWave##typ##Devs(void) { \
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 @@ WINMM_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
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 */