[PATCH 5/6] windows.media.speech: Add result to IAsyncOperation.
Bernhard Kölbl
besentv at gmail.com
Thu Mar 31 11:18:00 CDT 2022
And fix a mistake in include/windows.foundation.collections.idl.
Signed-off-by: Bernhard Kölbl <besentv at gmail.com>
---
dlls/windows.media.speech/async.c | 32 +++++++++++++++++++---
dlls/windows.media.speech/tests/speech.c | 15 ++++++++++
include/windows.foundation.collections.idl | 2 +-
3 files changed, 44 insertions(+), 5 deletions(-)
diff --git a/dlls/windows.media.speech/async.c b/dlls/windows.media.speech/async.c
index 767b4a3a4e4..88377311ba1 100644
--- a/dlls/windows.media.speech/async.c
+++ b/dlls/windows.media.speech/async.c
@@ -37,6 +37,7 @@ struct async_operation
LONG ref;
IAsyncOperationCompletedHandler_IInspectable *handler;
+ IInspectable *result;
BOOLEAN handler_set;
AsyncStatus status;
};
@@ -88,7 +89,10 @@ static ULONG WINAPI async_operation_Release( IAsyncOperation_IInspectable *iface
TRACE("iface %p, ref %lu.\n", iface, ref);
if (!ref)
+ {
+ if (impl->result) IInspectable_Release(impl->result);
free(impl);
+ }
return ref;
}
@@ -131,15 +135,23 @@ static HRESULT WINAPI async_operation_put_Completed( IAsyncOperation_IInspectabl
static HRESULT WINAPI async_operation_get_Completed( IAsyncOperation_IInspectable *iface,
IAsyncOperationCompletedHandler_IInspectable **handler )
{
- FIXME("iface %p, handler %p semi stub!\n", iface, handler);
+ FIXME("iface %p, handler %p semi-stub!\n", iface, handler);
*handler = NULL;
return S_OK;
}
-static HRESULT WINAPI async_operation_GetResults( IAsyncOperation_IInspectable *iface, IInspectable ***results )
+static HRESULT WINAPI async_operation_GetResults( IAsyncOperation_IInspectable *iface, IInspectable **results )
{
- FIXME("iface %p, results %p stub!\n", iface, results);
- return E_NOTIMPL;
+ /* NOTE: Despite the name, this function only returns one result! */
+ struct async_operation *impl = impl_from_IAsyncOperation_IInspectable(iface);
+
+ TRACE("iface %p, results %p.\n", iface, results);
+
+ if (!impl->result) return E_UNEXPECTED;
+
+ *results = impl->result;
+ impl->result = NULL; /* NOTE: AsyncOperation gives up it's reference to result here! */
+ return S_OK;
}
static const struct IAsyncOperation_IInspectableVtbl async_operation_vtbl =
@@ -244,5 +256,17 @@ HRESULT async_operation_notify( IAsyncOperation_IInspectable *operation )
if (impl->handler)
IAsyncOperationCompletedHandler_IInspectable_Invoke(impl->handler, operation, impl->status);
+ return S_OK;
+}
+
+HRESULT async_operation_set_result( IAsyncOperation_IInspectable *operation, IInspectable *result )
+{
+ struct async_operation *impl = impl_from_IAsyncOperation_IInspectable(operation);
+
+ if(!result) return E_POINTER;
+
+ if (!impl->result) IInspectable_AddRef((impl->result = result));
+ else return E_FAIL;
+
return S_OK;
}
\ No newline at end of file
diff --git a/dlls/windows.media.speech/tests/speech.c b/dlls/windows.media.speech/tests/speech.c
index 9c9ebf2c80c..c0e990c575a 100644
--- a/dlls/windows.media.speech/tests/speech.c
+++ b/dlls/windows.media.speech/tests/speech.c
@@ -814,6 +814,7 @@ static void test_SpeechRecognizer(void)
static const WCHAR *speech_recognition_name = L"Windows.Media.SpeechRecognition.SpeechRecognizer";
IAsyncOperationCompletedHandler_SpeechRecognitionCompilationResult *handler = NULL;
IAsyncOperation_SpeechRecognitionCompilationResult *operation = NULL;
+ ISpeechRecognitionCompilationResult *compilation_result = NULL;
IVector_ISpeechRecognitionConstraint *constraints = NULL;
ISpeechContinuousRecognitionSession *session = NULL;
ISpeechRecognizerFactory *sr_factory = NULL;
@@ -963,6 +964,20 @@ static void test_SpeechRecognizer(void)
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
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);
+
+ if(SUCCEEDED(hr))
+ {
+ check_interface(compilation_result, &IID_IAgileObject, TRUE);
+
+ 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);
+
hr = IAsyncOperation_SpeechRecognitionCompilationResult_QueryInterface(operation, &IID_IAsyncInfo, (void **)&info);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
diff --git a/include/windows.foundation.collections.idl b/include/windows.foundation.collections.idl
index 5ed60ed176e..395adad27aa 100644
--- a/include/windows.foundation.collections.idl
+++ b/include/windows.foundation.collections.idl
@@ -64,7 +64,7 @@ cpp_quote("#endif")
{
[propput] HRESULT Completed([in] Windows.Foundation.AsyncOperationCompletedHandler<TResult> *handler);
[propget] HRESULT Completed([out, retval] Windows.Foundation.AsyncOperationCompletedHandler<TResult> **handler);
- HRESULT GetResults([out, retval] TResult **results);
+ HRESULT GetResults([out, retval] TResult *results);
}
[
--
2.35.1
More information about the wine-devel
mailing list