Commit 74129bd8 authored by Bernhard Kölbl's avatar Bernhard Kölbl Committed by Alexandre Julliard

windows.media.speech: Partially implement the speech recognizer state.

parent 85ce23a9
......@@ -162,6 +162,8 @@ struct session
IVector_ISpeechRecognitionConstraint *constraints;
SpeechRecognizerState recognizer_state;
struct list completed_handlers;
struct list result_handlers;
......@@ -379,6 +381,7 @@ static HRESULT WINAPI session_StartAsync( ISpeechContinuousRecognitionSession *i
else
{
impl->worker_running = TRUE;
impl->recognizer_state = SpeechRecognizerState_Capturing;
}
LeaveCriticalSection(&impl->cs);
......@@ -422,6 +425,7 @@ static HRESULT WINAPI session_StopAsync( ISpeechContinuousRecognitionSession *if
impl->worker_thread = INVALID_HANDLE_VALUE;
impl->worker_running = FALSE;
impl->worker_paused = FALSE;
impl->recognizer_state = SpeechRecognizerState_Idle;
}
else
{
......@@ -475,6 +479,7 @@ static HRESULT WINAPI session_PauseAsync( ISpeechContinuousRecognitionSession *i
if (impl->worker_running)
{
impl->worker_paused = TRUE;
impl->recognizer_state = SpeechRecognizerState_Paused;
}
LeaveCriticalSection(&impl->cs);
......@@ -493,6 +498,7 @@ static HRESULT WINAPI session_Resume( ISpeechContinuousRecognitionSession *iface
if (impl->worker_running)
{
impl->worker_paused = FALSE;
impl->recognizer_state = SpeechRecognizerState_Capturing;
}
LeaveCriticalSection(&impl->cs);
......@@ -816,8 +822,19 @@ static HRESULT WINAPI recognizer2_get_ContinuousRecognitionSession( ISpeechRecog
static HRESULT WINAPI recognizer2_get_State( ISpeechRecognizer2 *iface, SpeechRecognizerState *state )
{
FIXME("iface %p, state %p stub!\n", iface, state);
return E_NOTIMPL;
struct recognizer *impl = impl_from_ISpeechRecognizer2(iface);
struct session *session = impl_from_ISpeechContinuousRecognitionSession(impl->session);
FIXME("iface %p, state %p not all states are supported, yet.\n", iface, state);
if (!state)
return E_POINTER;
EnterCriticalSection(&session->cs);
*state = session->recognizer_state;
LeaveCriticalSection(&session->cs);
return S_OK;
}
static HRESULT WINAPI recognizer2_StopRecognitionAsync( ISpeechRecognizer2 *iface, IAsyncAction **action )
......
......@@ -1721,8 +1721,8 @@ static void test_Recognition(void)
recog_state = 0xdeadbeef;
hr = ISpeechRecognizer2_get_State(recognizer2, &recog_state);
todo_wine ok(hr == S_OK, "ISpeechRecognizer2_get_State failed, hr %#lx.\n", hr);
todo_wine ok(recog_state == SpeechRecognizerState_Idle, "recog_state was %u.\n", recog_state);
ok(hr == S_OK, "ISpeechRecognizer2_get_State failed, hr %#lx.\n", hr);
ok(recog_state == SpeechRecognizerState_Idle, "recog_state was %u.\n", recog_state);
hr = ISpeechRecognizer_CompileConstraintsAsync(recognizer, &operation);
ok(hr == S_OK, "ISpeechRecognizer_CompileConstraintsAsync failed, hr %#lx.\n", hr);
......@@ -1771,8 +1771,8 @@ static void test_Recognition(void)
recog_state = 0xdeadbeef;
hr = ISpeechRecognizer2_get_State(recognizer2, &recog_state);
todo_wine ok(hr == S_OK, "ISpeechRecognizer2_get_State failed, hr %#lx.\n", hr);
todo_wine ok(recog_state == SpeechRecognizerState_Capturing, "recog_state was %u.\n", recog_state);
ok(hr == S_OK, "ISpeechRecognizer2_get_State failed, hr %#lx.\n", hr);
ok(recog_state == SpeechRecognizerState_Capturing, "recog_state was %u.\n", recog_state);
/*
* TODO: Use a loopback device together with prerecorded audio files to test the recognizer's functionality.
......@@ -1786,9 +1786,9 @@ static void test_Recognition(void)
recog_state = 0xdeadbeef;
hr = ISpeechRecognizer2_get_State(recognizer2, &recog_state);
todo_wine ok(hr == S_OK, "ISpeechRecognizer2_get_State failed, hr %#lx.\n", hr);
todo_wine ok(recog_state == SpeechRecognizerState_Paused ||
broken(recog_state == SpeechRecognizerState_Capturing) /* Broken on Win10 1507 */, "recog_state was %u.\n", recog_state);
ok(hr == S_OK, "ISpeechRecognizer2_get_State failed, hr %#lx.\n", hr);
ok(recog_state == SpeechRecognizerState_Paused ||
broken(recog_state == SpeechRecognizerState_Capturing) /* Broken on Win10 1507 */, "recog_state was %u.\n", recog_state);
/* Check what happens if we try to pause again, when the session is already paused. */
hr = ISpeechContinuousRecognitionSession_PauseAsync(session, &action2);
......@@ -1806,8 +1806,8 @@ static void test_Recognition(void)
recog_state = 0xdeadbeef;
hr = ISpeechRecognizer2_get_State(recognizer2, &recog_state);
todo_wine ok(hr == S_OK, "ISpeechRecognizer2_get_State failed, hr %#lx.\n", hr);
todo_wine ok(recog_state == SpeechRecognizerState_Capturing, "recog_state was %u.\n", recog_state);
ok(hr == S_OK, "ISpeechRecognizer2_get_State failed, hr %#lx.\n", hr);
ok(recog_state == SpeechRecognizerState_Capturing, "recog_state was %u.\n", recog_state);
hr = ISpeechContinuousRecognitionSession_StopAsync(session, &action2);
ok(hr == S_OK, "ISpeechContinuousRecognitionSession_StopAsync failed, hr %#lx.\n", hr);
......@@ -1858,8 +1858,8 @@ static void test_Recognition(void)
recog_state = 0xdeadbeef;
hr = ISpeechRecognizer2_get_State(recognizer2, &recog_state);
todo_wine ok(hr == S_OK, "ISpeechRecognizer2_get_State failed, hr %#lx.\n", hr);
todo_wine ok(recog_state == SpeechRecognizerState_Idle, "recog_state was %u.\n", recog_state);
ok(hr == S_OK, "ISpeechRecognizer2_get_State failed, hr %#lx.\n", hr);
ok(recog_state == SpeechRecognizerState_Idle, "recog_state was %u.\n", recog_state);
/* Try stopping, when already stopped. */
hr = ISpeechContinuousRecognitionSession_StopAsync(session, &action);
......@@ -1879,9 +1879,9 @@ static void test_Recognition(void)
recog_state = 0xdeadbeef;
hr = ISpeechRecognizer2_get_State(recognizer2, &recog_state);
todo_wine ok(hr == S_OK, "ISpeechRecognizer2_get_State failed, hr %#lx.\n", hr);
todo_wine ok(recog_state == SpeechRecognizerState_Paused ||
broken(recog_state == SpeechRecognizerState_Capturing) /* Broken on Win10 1507 */, "recog_state was %u.\n", recog_state);
ok(hr == S_OK, "ISpeechRecognizer2_get_State failed, hr %#lx.\n", hr);
ok(recog_state == SpeechRecognizerState_Paused ||
broken(recog_state == SpeechRecognizerState_Capturing) /* Broken on Win10 1507 */, "recog_state was %u.\n", recog_state);
hr = ISpeechContinuousRecognitionSession_StopAsync(session, &action);
ok(hr == S_OK, "ISpeechContinuousRecognitionSession_PauseAsync failed, hr %#lx.\n", hr);
......@@ -1890,8 +1890,8 @@ static void test_Recognition(void)
recog_state = 0xdeadbeef;
hr = ISpeechRecognizer2_get_State(recognizer2, &recog_state);
todo_wine ok(hr == S_OK, "ISpeechRecognizer2_get_State failed, hr %#lx.\n", hr);
todo_wine ok(recog_state == SpeechRecognizerState_Idle, "recog_state was %u.\n", recog_state);
ok(hr == S_OK, "ISpeechRecognizer2_get_State failed, hr %#lx.\n", hr);
ok(recog_state == SpeechRecognizerState_Idle, "recog_state was %u.\n", recog_state);
hr = ISpeechContinuousRecognitionSession_StartAsync(session, &action);
ok(hr == S_OK, "ISpeechContinuousRecognitionSession_PauseAsync failed, hr %#lx.\n", hr);
......@@ -1900,10 +1900,10 @@ static void test_Recognition(void)
recog_state = 0xdeadbeef;
hr = ISpeechRecognizer2_get_State(recognizer2, &recog_state);
todo_wine ok(hr == S_OK, "ISpeechRecognizer2_get_State failed, hr %#lx.\n", hr);
todo_wine ok(recog_state == SpeechRecognizerState_Capturing
|| broken(recog_state == SpeechRecognizerState_Idle) /* Sometimes Windows is a little behind. */,
"recog_state was %u.\n", recog_state);
ok(hr == S_OK, "ISpeechRecognizer2_get_State failed, hr %#lx.\n", hr);
ok(recog_state == SpeechRecognizerState_Capturing
|| broken(recog_state == SpeechRecognizerState_Idle) /* Sometimes Windows is a little behind. */,
"recog_state was %u.\n", recog_state);
hr = ISpeechContinuousRecognitionSession_StopAsync(session, &action);
ok(hr == S_OK, "ISpeechContinuousRecognitionSession_PauseAsync failed, hr %#lx.\n", hr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment