From: Davide Beatrici git@davidebeatrici.dev
--- dlls/mmdevapi/client.c | 65 +++++++++++++++++++++++++++++++++++ dlls/winepulse.drv/mmdevdrv.c | 54 ++--------------------------- 2 files changed, 68 insertions(+), 51 deletions(-)
diff --git a/dlls/mmdevapi/client.c b/dlls/mmdevapi/client.c index 87bc3fef0e5..d52fc13e833 100644 --- a/dlls/mmdevapi/client.c +++ b/dlls/mmdevapi/client.c @@ -36,6 +36,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(mmdevapi); extern void sessions_lock(void) DECLSPEC_HIDDEN; extern void sessions_unlock(void) DECLSPEC_HIDDEN;
+extern struct audio_session_wrapper *session_wrapper_create(struct audio_client *client) DECLSPEC_HIDDEN; + void set_stream_volumes(struct audio_client *This) { struct set_volumes_params params; @@ -194,6 +196,69 @@ const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl = capture_GetNextPacketSize };
+HRESULT WINAPI client_GetService(IAudioClient3 *iface, REFIID riid, void **ppv) +{ + struct audio_client *This = impl_from_IAudioClient3(iface); + + TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv); + + if (!ppv) + return E_POINTER; + + *ppv = NULL; + + sessions_lock(); + + if (!This->stream) { + sessions_unlock(); + return AUDCLNT_E_NOT_INITIALIZED; + } + + if (IsEqualIID(riid, &IID_IAudioRenderClient)) { + if (This->dataflow != eRender) { + sessions_unlock(); + return AUDCLNT_E_WRONG_ENDPOINT_TYPE; + } + *ppv = &This->IAudioRenderClient_iface; + } else if (IsEqualIID(riid, &IID_IAudioCaptureClient)) { + if (This->dataflow != eCapture) { + sessions_unlock(); + return AUDCLNT_E_WRONG_ENDPOINT_TYPE; + } + *ppv = &This->IAudioCaptureClient_iface; + } else if (IsEqualIID(riid, &IID_IAudioClock)) { + *ppv = &This->IAudioClock_iface; + } else if (IsEqualIID(riid, &IID_IAudioStreamVolume)) { + *ppv = &This->IAudioStreamVolume_iface; + } else if (IsEqualIID(riid, &IID_IAudioSessionControl) || + IsEqualIID(riid, &IID_IChannelAudioVolume) || + IsEqualIID(riid, &IID_ISimpleAudioVolume)) { + if (!This->session_wrapper) { + This->session_wrapper = session_wrapper_create(This); + if (!This->session_wrapper) { + sessions_unlock(); + return E_OUTOFMEMORY; + } + } + if (IsEqualIID(riid, &IID_IAudioSessionControl)) + *ppv = &This->session_wrapper->IAudioSessionControl2_iface; + else if (IsEqualIID(riid, &IID_IChannelAudioVolume)) + *ppv = &This->session_wrapper->IChannelAudioVolume_iface; + else if (IsEqualIID(riid, &IID_ISimpleAudioVolume)) + *ppv = &This->session_wrapper->ISimpleAudioVolume_iface; + } + + if (*ppv) { + IUnknown_AddRef((IUnknown*)*ppv); + sessions_unlock(); + return S_OK; + } + + sessions_unlock(); + + return E_NOINTERFACE; +} + HRESULT WINAPI client_IsOffloadCapable(IAudioClient3 *iface, AUDIO_STREAM_CATEGORY category, BOOL *offload_capable) { diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index 15d9e076b5c..19d4bd41c7a 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -1021,56 +1021,8 @@ static HRESULT WINAPI AudioClient_SetEventHandle(IAudioClient3 *iface, return params.result; }
-static HRESULT WINAPI AudioClient_GetService(IAudioClient3 *iface, REFIID riid, - void **ppv) -{ - ACImpl *This = impl_from_IAudioClient3(iface); - - TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv); - - if (!ppv) - return E_POINTER; - *ppv = NULL; - - if (!This->stream) - return AUDCLNT_E_NOT_INITIALIZED; - - if (IsEqualIID(riid, &IID_IAudioRenderClient)) { - if (This->dataflow != eRender) - return AUDCLNT_E_WRONG_ENDPOINT_TYPE; - *ppv = &This->IAudioRenderClient_iface; - } else if (IsEqualIID(riid, &IID_IAudioCaptureClient)) { - if (This->dataflow != eCapture) - return AUDCLNT_E_WRONG_ENDPOINT_TYPE; - *ppv = &This->IAudioCaptureClient_iface; - } else if (IsEqualIID(riid, &IID_IAudioClock)) { - *ppv = &This->IAudioClock_iface; - } else if (IsEqualIID(riid, &IID_IAudioStreamVolume)) { - *ppv = &This->IAudioStreamVolume_iface; - } else if (IsEqualIID(riid, &IID_IAudioSessionControl) || - IsEqualIID(riid, &IID_IChannelAudioVolume) || - IsEqualIID(riid, &IID_ISimpleAudioVolume)) { - if (!This->session_wrapper) { - This->session_wrapper = session_wrapper_create(This); - if (!This->session_wrapper) - return E_OUTOFMEMORY; - } - if (IsEqualIID(riid, &IID_IAudioSessionControl)) - *ppv = &This->session_wrapper->IAudioSessionControl2_iface; - else if (IsEqualIID(riid, &IID_IChannelAudioVolume)) - *ppv = &This->session_wrapper->IChannelAudioVolume_iface; - else if (IsEqualIID(riid, &IID_ISimpleAudioVolume)) - *ppv = &This->session_wrapper->ISimpleAudioVolume_iface; - } - - if (*ppv) { - IUnknown_AddRef((IUnknown*)*ppv); - return S_OK; - } - - FIXME("stub %s\n", debugstr_guid(riid)); - return E_NOINTERFACE; -} +extern HRESULT WINAPI client_GetService(IAudioClient3 *iface, REFIID riid, + void **ppv);
extern HRESULT WINAPI client_IsOffloadCapable(IAudioClient3 *iface, AUDIO_STREAM_CATEGORY category, BOOL *offload_capable); @@ -1109,7 +1061,7 @@ static const IAudioClient3Vtbl AudioClient3_Vtbl = AudioClient_Stop, AudioClient_Reset, AudioClient_SetEventHandle, - AudioClient_GetService, + client_GetService, client_IsOffloadCapable, client_SetClientProperties, client_GetBufferSizeLimits,