Module: wine Branch: master Commit: c6a97c0f194911302e798e133fb2040259d16885 URL: https://gitlab.winehq.org/wine/wine/-/commit/c6a97c0f194911302e798e133fb2040...
Author: Davide Beatrici git@davidebeatrici.dev Date: Sat Apr 8 04:43:24 2023 +0200
winecoreaudio: Implement and call set_event_handle in unixlib.
---
dlls/winecoreaudio.drv/coreaudio.c | 48 +++++++++++++++++++++++++++++++++++--- dlls/winecoreaudio.drv/mmdevdrv.c | 25 +++++++------------- 2 files changed, 54 insertions(+), 19 deletions(-)
diff --git a/dlls/winecoreaudio.drv/coreaudio.c b/dlls/winecoreaudio.drv/coreaudio.c index ee660b0887e..4191958b1ca 100644 --- a/dlls/winecoreaudio.drv/coreaudio.c +++ b/dlls/winecoreaudio.drv/coreaudio.c @@ -85,6 +85,7 @@ struct coreaudio_stream EDataFlow flow; DWORD flags; AUDCLNT_SHAREMODE share; + HANDLE event;
BOOL playing; REFERENCE_TIME period; @@ -1308,7 +1309,9 @@ static NTSTATUS unix_start(void *args)
OSSpinLockLock(&stream->lock);
- if(stream->playing) + if((stream->flags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK) && !stream->event) + params->result = AUDCLNT_E_EVENTHANDLE_NOT_SET; + else if(stream->playing) params->result = AUDCLNT_E_NOT_STOPPED; else{ stream->playing = TRUE; @@ -1653,6 +1656,27 @@ static NTSTATUS unix_set_volumes(void *args) return STATUS_SUCCESS; }
+static NTSTATUS unix_set_event_handle(void *args) +{ + struct set_event_handle_params *params = args; + struct coreaudio_stream *stream = handle_get_stream(params->stream); + HRESULT hr = S_OK; + + OSSpinLockLock(&stream->lock); + if(!stream->unit) + hr = AUDCLNT_E_DEVICE_INVALIDATED; + else if(!(stream->flags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK)) + hr = AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED; + else if(stream->event) + hr = HRESULT_FROM_WIN32(ERROR_INVALID_NAME); + else + stream->event = params->event; + OSSpinLockUnlock(&stream->lock); + + params->result = hr; + return STATUS_SUCCESS; +} + unixlib_entry_t __wine_unix_call_funcs[] = { unix_not_implemented, @@ -1679,7 +1703,7 @@ unixlib_entry_t __wine_unix_call_funcs[] = unix_get_frequency, unix_get_position, unix_set_volumes, - unix_not_implemented, + unix_set_event_handle, unix_not_implemented, unix_is_started, unix_not_implemented, @@ -1997,6 +2021,24 @@ static NTSTATUS unix_wow64_set_volumes(void *args) return unix_set_volumes(¶ms); }
+static NTSTATUS unix_wow64_set_event_handle(void *args) +{ + struct + { + stream_handle stream; + PTR32 event; + HRESULT result; + } *params32 = args; + struct set_event_handle_params params = + { + .stream = params32->stream, + .event = ULongToHandle(params32->event) + }; + unix_set_event_handle(¶ms); + params32->result = params.result; + return STATUS_SUCCESS; +} + unixlib_entry_t __wine_unix_call_wow64_funcs[] = { unix_not_implemented, @@ -2023,7 +2065,7 @@ unixlib_entry_t __wine_unix_call_wow64_funcs[] = unix_wow64_get_frequency, unix_wow64_get_position, unix_wow64_set_volumes, - unix_not_implemented, + unix_wow64_set_event_handle, unix_not_implemented, unix_is_started, unix_not_implemented, diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c index 8d1d14aa26f..e40b3c0f019 100644 --- a/dlls/winecoreaudio.drv/mmdevdrv.c +++ b/dlls/winecoreaudio.drv/mmdevdrv.c @@ -92,7 +92,6 @@ struct ACImpl {
EDataFlow dataflow; UINT32 channel_count, period_ms; - DWORD flags; HANDLE event; float *vols;
@@ -752,7 +751,6 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface, return params.result; }
- This->flags = flags; This->channel_count = fmt->nChannels; This->period_ms = period / 10000;
@@ -942,9 +940,6 @@ static HRESULT WINAPI AudioClient_Start(IAudioClient3 *iface) if(!This->stream) return AUDCLNT_E_NOT_INITIALIZED;
- if((This->flags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK) && !This->event) - return AUDCLNT_E_EVENTHANDLE_NOT_SET; - params.stream = This->stream; UNIX_CALL(start, ¶ms);
@@ -996,7 +991,7 @@ static HRESULT WINAPI AudioClient_SetEventHandle(IAudioClient3 *iface, HANDLE event) { ACImpl *This = impl_from_IAudioClient3(iface); - HRESULT hr = S_OK; + struct set_event_handle_params params;
TRACE("(%p)->(%p)\n", This, event);
@@ -1006,19 +1001,17 @@ static HRESULT WINAPI AudioClient_SetEventHandle(IAudioClient3 *iface, if(!This->stream) return AUDCLNT_E_NOT_INITIALIZED;
- EnterCriticalSection(&g_sessions_lock); + params.stream = This->stream; + params.event = event; + UNIX_CALL(set_event_handle, ¶ms);
- if(!(This->flags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK)) - hr = AUDCLNT_E_EVENTHANDLE_NOT_EXPECTED; - else if(This->event){ - FIXME("called twice\n"); - hr = HRESULT_FROM_WIN32(ERROR_INVALID_NAME); - }else + if(SUCCEEDED(params.result)){ + EnterCriticalSection(&g_sessions_lock); This->event = event; + LeaveCriticalSection(&g_sessions_lock); + }
- LeaveCriticalSection(&g_sessions_lock); - - return hr; + return params.result; }
static HRESULT WINAPI AudioClient_GetService(IAudioClient3 *iface, REFIID riid,