Sfoglia il codice sorgente

audio: FreeDeviceHandle should pass the whole device, for convenience.

Ryan C. Gordon 1 anno fa
parent
commit
22afa5735f

+ 2 - 2
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)
 {

+ 1 - 1
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. */

+ 2 - 2
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)