From 22afa5735f97e8a797a2f7c35066e552a04054e2 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 3 Jul 2023 20:32:31 -0400
Subject: [PATCH] audio: FreeDeviceHandle should pass the whole device, for
convenience.
---
src/audio/SDL_audio.c | 4 ++--
src/audio/SDL_sysaudio.h | 2 +-
src/audio/directsound/SDL_directsound.c | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index 8926b7e000c4..d60ccb5f2e8a 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -198,7 +198,7 @@ static void DestroyPhysicalAudioDevice(SDL_AudioDevice *device)
// it's safe to not hold the lock for this (we can't anyhow, or the audio thread won't quit), because we shouldn't be in the device list at this point.
ClosePhysicalAudioDevice(device);
- current_audio.impl.FreeDeviceHandle(device->handle);
+ current_audio.impl.FreeDeviceHandle(device);
SDL_DestroyMutex(device->lock);
SDL_free(device->work_buffer);
@@ -418,7 +418,7 @@ static void SDL_AudioWaitCaptureDevice_Default(SDL_AudioDevice *device) { /* no-
static void SDL_AudioFlushCapture_Default(SDL_AudioDevice *device) { /* no-op. */ }
static void SDL_AudioCloseDevice_Default(SDL_AudioDevice *device) { /* no-op. */ }
static void SDL_AudioDeinitialize_Default(void) { /* no-op. */ }
-static void SDL_AudioFreeDeviceHandle_Default(void *handle) { /* no-op. */ }
+static void SDL_AudioFreeDeviceHandle_Default(SDL_AudioDevice *device) { /* no-op. */ }
static void SDL_AudioDetectDevices_Default(SDL_AudioDevice **default_output, SDL_AudioDevice **default_capture)
{
diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h
index ca71097fb7c5..ff3d1755c8b8 100644
--- a/src/audio/SDL_sysaudio.h
+++ b/src/audio/SDL_sysaudio.h
@@ -114,7 +114,7 @@ typedef struct SDL_AudioDriverImpl
int (*CaptureFromDevice)(SDL_AudioDevice *device, void *buffer, int buflen);
void (*FlushCapture)(SDL_AudioDevice *device);
void (*CloseDevice)(SDL_AudioDevice *device);
- void (*FreeDeviceHandle)(void *handle); /**< SDL is done with handle from SDL_AddAudioDevice() */
+ void (*FreeDeviceHandle)(SDL_AudioDevice *handle); // SDL is done with this device; free the handle from SDL_AddAudioDevice()
void (*Deinitialize)(void);
/* Some flags to push duplicate code into the core and reduce #ifdefs. */
diff --git a/src/audio/directsound/SDL_directsound.c b/src/audio/directsound/SDL_directsound.c
index 33ad19645193..17fef74bf765 100644
--- a/src/audio/directsound/SDL_directsound.c
+++ b/src/audio/directsound/SDL_directsound.c
@@ -149,9 +149,9 @@ static int SetDSerror(const char *function, int code)
return SDL_SetError("%s: %s (0x%x)", function, error, code);
}
-static void DSOUND_FreeDeviceHandle(void *handle)
+static void DSOUND_FreeDeviceHandle(SDL_AudioDevice *device)
{
- SDL_free(handle);
+ SDL_free(device->handle);
}
static int DSOUND_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)