From f3bd61add44997517ad8fe0d91600eb02e427dd8 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Wed, 2 Mar 2022 10:53:19 +0000 Subject: [PATCH] winealsa: Move reset to the unixlib. Signed-off-by: Huw Davies Signed-off-by: Andrew Eikum Signed-off-by: Alexandre Julliard --- dlls/winealsa.drv/alsa.c | 36 +++++++++++++++++++++++++++++++++++ dlls/winealsa.drv/mmdevdrv.c | 37 ++++-------------------------------- dlls/winealsa.drv/unixlib.h | 7 +++++++ 3 files changed, 47 insertions(+), 33 deletions(-) diff --git a/dlls/winealsa.drv/alsa.c b/dlls/winealsa.drv/alsa.c index e5efb6b201b..8d148a9828f 100644 --- a/dlls/winealsa.drv/alsa.c +++ b/dlls/winealsa.drv/alsa.c @@ -1514,6 +1514,41 @@ static NTSTATUS stop(void *args) return alsa_unlock_result(stream, ¶ms->result, S_OK); } +static NTSTATUS reset(void *args) +{ + struct reset_params *params = args; + struct alsa_stream *stream = params->stream; + + alsa_lock(stream); + + if(stream->started) + return alsa_unlock_result(stream, ¶ms->result, AUDCLNT_E_NOT_STOPPED); + + if(stream->getbuf_last) + return alsa_unlock_result(stream, ¶ms->result, AUDCLNT_E_BUFFER_OPERATION_PENDING); + + if(snd_pcm_drop(stream->pcm_handle) < 0) + WARN("snd_pcm_drop failed\n"); + + if(snd_pcm_reset(stream->pcm_handle) < 0) + WARN("snd_pcm_reset failed\n"); + + if(snd_pcm_prepare(stream->pcm_handle) < 0) + WARN("snd_pcm_prepare failed\n"); + + if(stream->flow == eRender){ + stream->written_frames = 0; + stream->last_pos_frames = 0; + }else{ + stream->written_frames += stream->held_frames; + } + stream->held_frames = 0; + stream->lcl_offs_frames = 0; + stream->wri_offs_frames = 0; + + return alsa_unlock_result(stream, ¶ms->result, S_OK); +} + static NTSTATUS timer_loop(void *args) { struct timer_loop_params *params = args; @@ -1861,6 +1896,7 @@ unixlib_entry_t __wine_unix_call_funcs[] = release_stream, start, stop, + reset, timer_loop, is_format_supported, get_mix_format, diff --git a/dlls/winealsa.drv/mmdevdrv.c b/dlls/winealsa.drv/mmdevdrv.c index d9e96b7790c..fa05cb00968 100644 --- a/dlls/winealsa.drv/mmdevdrv.c +++ b/dlls/winealsa.drv/mmdevdrv.c @@ -1020,47 +1020,18 @@ static HRESULT WINAPI AudioClient_Stop(IAudioClient3 *iface) static HRESULT WINAPI AudioClient_Reset(IAudioClient3 *iface) { ACImpl *This = impl_from_IAudioClient3(iface); - struct alsa_stream *stream = This->stream; + struct reset_params params; TRACE("(%p)\n", This); if(!This->stream) return AUDCLNT_E_NOT_INITIALIZED; - alsa_lock(stream); + params.stream = This->stream; - if(stream->started){ - alsa_unlock(stream); - return AUDCLNT_E_NOT_STOPPED; - } + ALSA_CALL(reset, ¶ms); - if(stream->getbuf_last){ - alsa_unlock(stream); - return AUDCLNT_E_BUFFER_OPERATION_PENDING; - } - - if(snd_pcm_drop(stream->pcm_handle) < 0) - WARN("snd_pcm_drop failed\n"); - - if(snd_pcm_reset(stream->pcm_handle) < 0) - WARN("snd_pcm_reset failed\n"); - - if(snd_pcm_prepare(stream->pcm_handle) < 0) - WARN("snd_pcm_prepare failed\n"); - - if(stream->flow == eRender){ - stream->written_frames = 0; - stream->last_pos_frames = 0; - }else{ - stream->written_frames += stream->held_frames; - } - stream->held_frames = 0; - stream->lcl_offs_frames = 0; - stream->wri_offs_frames = 0; - - alsa_unlock(stream); - - return S_OK; + return params.result; } static HRESULT WINAPI AudioClient_SetEventHandle(IAudioClient3 *iface, diff --git a/dlls/winealsa.drv/unixlib.h b/dlls/winealsa.drv/unixlib.h index 1c3caabcc26..3d88d8d7f9b 100644 --- a/dlls/winealsa.drv/unixlib.h +++ b/dlls/winealsa.drv/unixlib.h @@ -103,6 +103,12 @@ struct stop_params HRESULT result; }; +struct reset_params +{ + struct alsa_stream *stream; + HRESULT result; +}; + struct timer_loop_params { struct alsa_stream *stream; @@ -154,6 +160,7 @@ enum alsa_funcs alsa_release_stream, alsa_start, alsa_stop, + alsa_reset, alsa_timer_loop, alsa_is_format_supported, alsa_get_mix_format,