summaryrefslogtreecommitdiffstats
path: root/drivers/wasapi/audio_driver_wasapi.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/wasapi/audio_driver_wasapi.cpp')
-rw-r--r--drivers/wasapi/audio_driver_wasapi.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp
index a349a66f75..4e7c9695a5 100644
--- a/drivers/wasapi/audio_driver_wasapi.cpp
+++ b/drivers/wasapi/audio_driver_wasapi.cpp
@@ -39,6 +39,9 @@
#include <functiondiscoverykeys.h>
+#include <wrl/client.h>
+using Microsoft::WRL::ComPtr;
+
// Define IAudioClient3 if not already defined by MinGW headers
#if defined __MINGW32__ || defined __MINGW64__
@@ -107,6 +110,12 @@ const IID IID_IAudioClient3 = __uuidof(IAudioClient3);
const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient);
const IID IID_IAudioCaptureClient = __uuidof(IAudioCaptureClient);
+#define SAFE_RELEASE(memory) \
+ if ((memory) != nullptr) { \
+ (memory)->Release(); \
+ (memory) = nullptr; \
+ }
+
#define REFTIMES_PER_SEC 10000000
#define REFTIMES_PER_MILLISEC 10000
@@ -302,7 +311,7 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_i
audioProps.bIsOffload = FALSE;
audioProps.eCategory = AudioCategory_GameEffects;
- hr = ((IAudioClient3 *)p_device->audio_client.Get())->SetClientProperties(&audioProps);
+ hr = ((IAudioClient3 *)p_device->audio_client)->SetClientProperties(&audioProps);
ERR_FAIL_COND_V_MSG(hr != S_OK, ERR_CANT_OPEN, "WASAPI: SetClientProperties failed with error 0x" + String::num_uint64(hr, 16) + ".");
}
@@ -385,7 +394,7 @@ Error AudioDriverWASAPI::audio_device_init(AudioDeviceWASAPI *p_device, bool p_i
}
} else {
- IAudioClient3 *device_audio_client_3 = (IAudioClient3 *)p_device->audio_client.Get();
+ IAudioClient3 *device_audio_client_3 = (IAudioClient3 *)p_device->audio_client;
// AUDCLNT_STREAMFLAGS_RATEADJUST is an invalid flag with IAudioClient3, therefore we have to use
// the closest supported mix rate supported by the audio driver.
@@ -516,9 +525,9 @@ Error AudioDriverWASAPI::audio_device_finish(AudioDeviceWASAPI *p_device) {
p_device->active.clear();
}
- p_device->audio_client.Reset();
- p_device->render_client.Reset();
- p_device->capture_client.Reset();
+ SAFE_RELEASE(p_device->audio_client)
+ SAFE_RELEASE(p_device->render_client)
+ SAFE_RELEASE(p_device->capture_client)
return OK;
}