Module: wine Branch: master Commit: f37d21db9de4fc696317158136630b6481ec8b7c URL: https://gitlab.winehq.org/wine/wine/-/commit/f37d21db9de4fc696317158136630b6...
Author: Davide Beatrici git@davidebeatrici.dev Date: Mon Jun 26 23:24:27 2023 +0200
winepulse: Move AudioClient's Release, AddRef into mmdevapi.
---
dlls/mmdevapi/client.c | 36 ++++++++++++++++++++++++++++++++++++ dlls/winepulse.drv/mmdevdrv.c | 38 ++++---------------------------------- 2 files changed, 40 insertions(+), 34 deletions(-)
diff --git a/dlls/mmdevapi/client.c b/dlls/mmdevapi/client.c index 9ef508d8c47..bec3e440b7c 100644 --- a/dlls/mmdevapi/client.c +++ b/dlls/mmdevapi/client.c @@ -406,6 +406,42 @@ const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl = capture_GetNextPacketSize };
+ULONG WINAPI client_AddRef(IAudioClient3 *iface) +{ + struct audio_client *This = impl_from_IAudioClient3(iface); + ULONG ref = InterlockedIncrement(&This->ref); + TRACE("(%p) Refcount now %lu\n", This, ref); + return ref; +} + +ULONG WINAPI client_Release(IAudioClient3 *iface) +{ + struct audio_client *This = impl_from_IAudioClient3(iface); + ULONG ref = InterlockedDecrement(&This->ref); + TRACE("(%p) Refcount now %lu\n", This, ref); + + if (!ref) { + IAudioClient3_Stop(iface); + IMMDevice_Release(This->parent); + IUnknown_Release(This->marshal); + + if (This->session) { + sessions_lock(); + list_remove(&This->entry); + sessions_unlock(); + } + + free(This->vols); + + if (This->stream) + stream_release(This->stream, This->timer_thread); + + HeapFree(GetProcessHeap(), 0, This); + } + + return ref; +} + HRESULT WINAPI client_Initialize(IAudioClient3 *iface, AUDCLNT_SHAREMODE mode, DWORD flags, REFERENCE_TIME duration, REFERENCE_TIME period, const WAVEFORMATEX *fmt, const GUID *sessionguid) diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index 9e233cb845e..cdf5920d985 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -131,8 +131,6 @@ extern const IAudioStreamVolumeVtbl AudioStreamVolume_Vtbl; extern struct audio_session_wrapper *session_wrapper_create( struct audio_client *client) DECLSPEC_HIDDEN;
-extern HRESULT stream_release(stream_handle stream, HANDLE timer_thread); - static inline ACImpl *impl_from_IAudioClient3(IAudioClient3 *iface) { return CONTAINING_RECORD(iface, ACImpl, IAudioClient3_iface); @@ -407,37 +405,9 @@ static HRESULT WINAPI AudioClient_QueryInterface(IAudioClient3 *iface, return E_NOINTERFACE; }
-static ULONG WINAPI AudioClient_AddRef(IAudioClient3 *iface) -{ - ACImpl *This = impl_from_IAudioClient3(iface); - ULONG ref; - ref = InterlockedIncrement(&This->ref); - TRACE("(%p) Refcount now %lu\n", This, ref); - return ref; -} +extern ULONG WINAPI client_AddRef(IAudioClient3 *iface);
-static ULONG WINAPI AudioClient_Release(IAudioClient3 *iface) -{ - ACImpl *This = impl_from_IAudioClient3(iface); - ULONG ref; - ref = InterlockedDecrement(&This->ref); - TRACE("(%p) Refcount now %lu\n", This, ref); - if (!ref) { - IAudioClient3_Stop(iface); - IMMDevice_Release(This->parent); - IUnknown_Release(This->marshal); - if (This->session) { - sessions_lock(); - list_remove(&This->entry); - sessions_unlock(); - } - free(This->vols); - if (This->stream) - stream_release(This->stream, This->timer_thread); - HeapFree(GetProcessHeap(), 0, This); - } - return ref; -} +extern ULONG WINAPI client_Release(IAudioClient3 *iface);
static void session_init_vols(AudioSession *session, UINT channels) { @@ -578,8 +548,8 @@ extern HRESULT WINAPI client_InitializeSharedAudioStream(IAudioClient3 *iface, static const IAudioClient3Vtbl AudioClient3_Vtbl = { AudioClient_QueryInterface, - AudioClient_AddRef, - AudioClient_Release, + client_AddRef, + client_Release, client_Initialize, client_GetBufferSize, client_GetStreamLatency,