From: Bernhard Kölbl besentv@gmail.com
Signed-off-by: Bernhard Kölbl besentv@gmail.com --- dlls/windows.media.speech/recognizer.c | 36 ++++++++++++++++++++---- dlls/windows.media.speech/tests/speech.c | 4 +-- 2 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/dlls/windows.media.speech/recognizer.c b/dlls/windows.media.speech/recognizer.c index c6721f4092a..92bd6369d15 100644 --- a/dlls/windows.media.speech/recognizer.c +++ b/dlls/windows.media.speech/recognizer.c @@ -19,6 +19,7 @@
#include "private.h"
+#include "winbase.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(speech); @@ -162,7 +163,7 @@ struct session struct list result_handlers;
HANDLE worker_thread; - BOOLEAN worker_running; + BOOLEAN worker_running, worker_paused; CONDITION_VARIABLE cv; CRITICAL_SECTION cs; }; @@ -188,6 +189,16 @@ static DWORD CALLBACK session_worker_thread_cb( void *args ) { /* TODO: Send mic data to recognizer and handle results. */
+ if (impl->worker_paused) + { + TRACE("Recognition session worked paused!\n"); + + SleepConditionVariableCS(&impl->cv, &impl->cs, INFINITE); + + TRACE("Recognition session worked resumed!\n"); + continue; + } + SleepConditionVariableCS(&impl->cv, &impl->cs, 500); /* Wait 500ms to slow down spinning for now. */ } LeaveCriticalSection(&impl->cs); @@ -386,19 +397,34 @@ static HRESULT WINAPI session_CancelAsync( ISpeechContinuousRecognitionSession *
static HRESULT session_pause_async( IInspectable *invoker ) { + struct session *impl = impl_from_ISpeechContinuousRecognitionSession((ISpeechContinuousRecognitionSession *)invoker); + + EnterCriticalSection(&impl->cs); + if (impl->worker_running) impl->worker_paused = TRUE; + LeaveCriticalSection(&impl->cs); + return S_OK; }
static HRESULT WINAPI session_PauseAsync( ISpeechContinuousRecognitionSession *iface, IAsyncAction **action ) { - FIXME("iface %p, action %p stub!\n", iface, action); - return async_action_create(NULL, session_pause_async, action); + TRACE("iface %p, action %p.\n", iface, action); + return async_action_create((IInspectable *)iface, session_pause_async, action); }
static HRESULT WINAPI session_Resume( ISpeechContinuousRecognitionSession *iface ) { - FIXME("iface %p stub!\n", iface); - return E_NOTIMPL; + struct session *impl = impl_from_ISpeechContinuousRecognitionSession(iface); + + TRACE("iface %p.\n", iface); + + EnterCriticalSection(&impl->cs); + if (impl->worker_running) impl->worker_paused = FALSE; + LeaveCriticalSection(&impl->cs); + + WakeConditionVariable(&impl->cv); + + return S_OK; }
static HRESULT WINAPI session_add_Completed( ISpeechContinuousRecognitionSession *iface, diff --git a/dlls/windows.media.speech/tests/speech.c b/dlls/windows.media.speech/tests/speech.c index 8b31031d3c5..196d0a98302 100644 --- a/dlls/windows.media.speech/tests/speech.c +++ b/dlls/windows.media.speech/tests/speech.c @@ -1798,11 +1798,11 @@ static void test_Recognition(void) IAsyncAction_Release(action2);
hr = ISpeechContinuousRecognitionSession_Resume(session); - todo_wine ok(hr == S_OK, "ISpeechContinuousRecognitionSession_Resume failed, hr %#lx.\n", hr); + ok(hr == S_OK, "ISpeechContinuousRecognitionSession_Resume failed, hr %#lx.\n", hr);
/* Resume when already resumed. */ hr = ISpeechContinuousRecognitionSession_Resume(session); - todo_wine ok(hr == S_OK, "ISpeechContinuousRecognitionSession_Resume failed, hr %#lx.\n", hr); + ok(hr == S_OK, "ISpeechContinuousRecognitionSession_Resume failed, hr %#lx.\n", hr);
recog_state = 0xdeadbeef; hr = ISpeechRecognizer2_get_State(recognizer2, &recog_state);