[PATCH 6/6] windows.media.speech: Implement ISpeechRecognitionCompilationResult.
Bernhard Kölbl
besentv at gmail.com
Thu Mar 31 11:18:01 CDT 2022
And use it for ISpeechRecognizer_CompileConstraintsAsync.
Signed-off-by: Bernhard Kölbl <besentv at gmail.com>
---
dlls/windows.media.speech/private.h | 1 +
dlls/windows.media.speech/recognizer.c | 134 ++++++++++++++++++++++-
dlls/windows.media.speech/tests/speech.c | 16 +--
3 files changed, 143 insertions(+), 8 deletions(-)
diff --git a/dlls/windows.media.speech/private.h b/dlls/windows.media.speech/private.h
index aefadaf21c7..066fa8bd6f9 100644
--- a/dlls/windows.media.speech/private.h
+++ b/dlls/windows.media.speech/private.h
@@ -71,6 +71,7 @@ struct vector_iids
HRESULT async_operation_create( const GUID *iid, IAsyncOperation_IInspectable **out );
HRESULT async_operation_notify( IAsyncOperation_IInspectable *operation );
+HRESULT async_operation_set_result( IAsyncOperation_IInspectable *operation, IInspectable *result );
HRESULT typed_event_handlers_append( struct list *list, ITypedEventHandler_IInspectable_IInspectable *handler, EventRegistrationToken *token );
HRESULT typed_event_handlers_remove( struct list *list, EventRegistrationToken *token );
diff --git a/dlls/windows.media.speech/recognizer.c b/dlls/windows.media.speech/recognizer.c
index 793be7d1749..f7aeafb5ad2 100644
--- a/dlls/windows.media.speech/recognizer.c
+++ b/dlls/windows.media.speech/recognizer.c
@@ -23,6 +23,128 @@
WINE_DEFAULT_DEBUG_CHANNEL(speech);
+/*
+ *
+ * ISpeechRecognitionCompilationResult
+ *
+ */
+
+struct compilation_result
+{
+ ISpeechRecognitionCompilationResult ISpeechRecognitionCompilationResult_iface;
+ LONG ref;
+
+ SpeechRecognitionResultStatus status;
+};
+
+static inline struct compilation_result *impl_from_ISpeechRecognitionCompilationResult( ISpeechRecognitionCompilationResult *iface )
+{
+ return CONTAINING_RECORD(iface, struct compilation_result, ISpeechRecognitionCompilationResult_iface);
+}
+
+static HRESULT WINAPI compilation_result_QueryInterface( ISpeechRecognitionCompilationResult *iface, REFIID iid, void **out )
+{
+ struct compilation_result *impl = impl_from_ISpeechRecognitionCompilationResult(iface);
+
+ TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
+
+ if (IsEqualGUID(iid, &IID_IUnknown) ||
+ IsEqualGUID(iid, &IID_IInspectable) ||
+ IsEqualGUID(iid, &IID_IAgileObject) ||
+ IsEqualGUID(iid, &IID_ISpeechRecognitionCompilationResult))
+ {
+ IInspectable_AddRef((*out = &impl->ISpeechRecognitionCompilationResult_iface));
+ return S_OK;
+ }
+
+ WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
+ *out = NULL;
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI compilation_result_AddRef( ISpeechRecognitionCompilationResult *iface )
+{
+ struct compilation_result *impl = impl_from_ISpeechRecognitionCompilationResult(iface);
+ ULONG ref = InterlockedIncrement(&impl->ref);
+ TRACE("iface %p, ref %lu.\n", iface, ref);
+ return ref;
+}
+
+static ULONG WINAPI compilation_result_Release( ISpeechRecognitionCompilationResult *iface )
+{
+ struct compilation_result *impl = impl_from_ISpeechRecognitionCompilationResult(iface);
+
+ ULONG ref = InterlockedDecrement(&impl->ref);
+ TRACE("iface %p, ref %lu.\n", iface, ref);
+
+ if (!ref)
+ free(impl);
+
+ return ref;
+}
+
+static HRESULT WINAPI compilation_result_GetIids( ISpeechRecognitionCompilationResult *iface, ULONG *iid_count, IID **iids )
+{
+ FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI compilation_result_GetRuntimeClassName( ISpeechRecognitionCompilationResult *iface, HSTRING *class_name )
+{
+ FIXME("iface %p, class_name %p stub!\n", iface, class_name);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI compilation_result_GetTrustLevel( ISpeechRecognitionCompilationResult *iface, TrustLevel *trust_level )
+{
+ FIXME("iface %p, trust_level %p stub!\n", iface, trust_level);
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI compilation_result_get_Status( ISpeechRecognitionCompilationResult *iface, SpeechRecognitionResultStatus *value )
+{
+ struct compilation_result *impl = impl_from_ISpeechRecognitionCompilationResult(iface);
+ TRACE("iface %p, value %p.\n", iface, value);
+ *value = impl->status;
+ return S_OK;
+}
+
+static const struct ISpeechRecognitionCompilationResultVtbl compilation_result_vtbl =
+{
+ /* IUnknown methods */
+ compilation_result_QueryInterface,
+ compilation_result_AddRef,
+ compilation_result_Release,
+ /* IInspectable methods */
+ compilation_result_GetIids,
+ compilation_result_GetRuntimeClassName,
+ compilation_result_GetTrustLevel,
+ /* ISpeechRecognitionCompilationResult methods */
+ compilation_result_get_Status
+};
+
+
+static HRESULT WINAPI compilation_result_create( SpeechRecognitionResultStatus status, ISpeechRecognitionCompilationResult **out )
+{
+ struct compilation_result *impl;
+
+ TRACE("out %p.\n", out);
+
+ if (!(impl = calloc(1, sizeof(*impl))))
+ {
+ *out = NULL;
+ return E_OUTOFMEMORY;
+ }
+
+ impl->ISpeechRecognitionCompilationResult_iface.lpVtbl = &compilation_result_vtbl;
+ impl->ref = 1;
+ impl->status = status;
+
+ *out = &impl->ISpeechRecognitionCompilationResult_iface;
+ TRACE("created %p\n", *out);
+ return S_OK;
+}
+
/*
*
* SpeechContinuousRecognitionSession
@@ -352,6 +474,7 @@ static HRESULT WINAPI recognizer_CompileConstraintsAsync( ISpeechRecognizer *ifa
IAsyncOperation_SpeechRecognitionCompilationResult **operation )
{
IAsyncOperation_IInspectable **value = (IAsyncOperation_IInspectable **)operation;
+ ISpeechRecognitionCompilationResult *result;
HRESULT hr;
FIXME("iface %p, operation %p semi-stub!\n", iface, operation);
@@ -359,9 +482,18 @@ static HRESULT WINAPI recognizer_CompileConstraintsAsync( ISpeechRecognizer *ifa
*operation = NULL;
if (FAILED(hr = async_operation_create(&IID_IAsyncOperation_SpeechRecognitionCompilationResult, value))) return hr;
- async_operation_notify(*value);
+ if (FAILED(hr = compilation_result_create(SpeechRecognitionResultStatus_Success, &result))) goto error;
+ hr = async_operation_set_result(*value, (IInspectable *)result);
+ ISpeechRecognitionCompilationResult_Release(result);
+ if (FAILED(hr)) goto error;
+
+ async_operation_notify(*value);
return S_OK;
+
+error:
+ if (*value) IAsyncOperation_IInspectable_Release(*value);
+ return hr;
}
static HRESULT WINAPI recognizer_RecognizeAsync( ISpeechRecognizer *iface,
diff --git a/dlls/windows.media.speech/tests/speech.c b/dlls/windows.media.speech/tests/speech.c
index c0e990c575a..359aafe95f0 100644
--- a/dlls/windows.media.speech/tests/speech.c
+++ b/dlls/windows.media.speech/tests/speech.c
@@ -831,6 +831,7 @@ static void test_SpeechRecognizer(void)
struct recognition_result_handler result_handler;
struct compilation_handler compilation_handler;
EventRegistrationToken token = { .value = 0 };
+ SpeechRecognitionResultStatus result_status;
AsyncStatus async_status;
HSTRING hstr, hstr_lang;
HRESULT hr;
@@ -965,15 +966,16 @@ static void test_SpeechRecognizer(void)
ok(handler == NULL, "Handler had value %p.\n", handler);
hr = IAsyncOperation_SpeechRecognitionCompilationResult_GetResults(operation, &compilation_result);
- todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
- if(SUCCEEDED(hr))
- {
- check_interface(compilation_result, &IID_IAgileObject, TRUE);
+ check_interface(compilation_result, &IID_IAgileObject, TRUE);
- ref = ISpeechRecognitionCompilationResult_Release(compilation_result);
- ok(!ref , "Got unexpected ref %lu.\n", ref);
- }
+ hr = ISpeechRecognitionCompilationResult_get_Status(compilation_result, &result_status);
+ ok(hr == S_OK, "ISpeechRecognitionCompilationResult_get_Status failed, hr %#lx.\n", hr);
+ ok(result_status == SpeechRecognitionResultStatus_Success, "Got unexpected status %x.\n", result_status);
+
+ ref = ISpeechRecognitionCompilationResult_Release(compilation_result);
+ ok(!ref, "Got unexpected ref %lu.\n", ref);
hr = IAsyncOperation_SpeechRecognitionCompilationResult_GetResults(operation, &compilation_result);
ok(hr == E_UNEXPECTED, "Got unexpected hr %#lx.\n", hr);
--
2.35.1
More information about the wine-devel
mailing list