[prev in list] [next in list] [prev in thread] [next in thread]
List: wine-devel
Subject: [PATCH 4/6] windows.media.speech: Implement handler for IAsyncOperation.
From: Bernhard Kölbl <besentv () gmail ! com>
Date: 2022-03-31 16:17:59
Message-ID: 20220331161801.158303-4-besentv () gmail ! com
[Download RAW message or body]
Signed-off-by: Bernhard Kölbl <besentv@gmail.com>
---
dlls/windows.media.speech/async.c | 40 ++++++++++++++++++++----
dlls/windows.media.speech/private.h | 1 +
dlls/windows.media.speech/recognizer.c | 10 +++++-
dlls/windows.media.speech/tests/speech.c | 25 +++++++--------
4 files changed, 55 insertions(+), 21 deletions(-)
diff --git a/dlls/windows.media.speech/async.c b/dlls/windows.media.speech/async.c
index 5b74ec60be1..767b4a3a4e4 100644
--- a/dlls/windows.media.speech/async.c
+++ b/dlls/windows.media.speech/async.c
@@ -35,6 +35,10 @@ struct async_operation
IAsyncInfo IAsyncInfo_iface;
const GUID *iid;
LONG ref;
+
+ IAsyncOperationCompletedHandler_IInspectable *handler;
+ BOOLEAN handler_set;
+ AsyncStatus status;
};
static inline struct async_operation \
*impl_from_IAsyncOperation_IInspectable(IAsyncOperation_IInspectable *iface) @@ \
-110,15 +114,26 @@ static HRESULT WINAPI async_operation_GetTrustLevel( \
IAsyncOperation_IInspectabl static HRESULT WINAPI async_operation_put_Completed( \
IAsyncOperation_IInspectable *iface,
\
IAsyncOperationCompletedHandler_IInspectable *handler ) {
- FIXME("iface %p, handler %p stub!\n", iface, handler);
- return E_NOTIMPL;
+ struct async_operation *impl = impl_from_IAsyncOperation_IInspectable(iface);
+
+ TRACE("iface %p, handler %p.\n", iface, handler);
+
+ if (impl->handler_set) return E_ILLEGAL_DELEGATE_ASSIGNMENT;
+ impl->handler = handler;
+ impl->handler_set = TRUE;
+
+ if (impl->status == Completed)
+ return async_operation_notify(iface);
+
+ return S_OK;
}
static HRESULT WINAPI async_operation_get_Completed( IAsyncOperation_IInspectable \
*iface,
\
IAsyncOperationCompletedHandler_IInspectable **handler ) {
- FIXME("iface %p, handler %p stub!\n", iface, handler);
- return E_NOTIMPL;
+ 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 ) @@ -159,8 +174,10 @@ static HRESULT WINAPI \
async_operation_info_get_Id( IAsyncInfo *iface, UINT32 *id
static HRESULT WINAPI async_operation_info_get_Status( IAsyncInfo *iface, \
AsyncStatus *status ) {
- FIXME("iface %p, status %p stub!\n", iface, status);
- return E_NOTIMPL;
+ struct async_operation *impl = impl_from_IAsyncInfo(iface);
+ TRACE("iface %p, status %p.\n", iface, status);
+ *status = impl->status;
+ return S_OK;
}
static HRESULT WINAPI async_operation_info_get_ErrorCode( IAsyncInfo *iface, HRESULT \
*error_code ) @@ -218,3 +235,14 @@ HRESULT async_operation_create( const GUID *iid, \
IAsyncOperation_IInspectable ** TRACE("created %p\n", *out);
return S_OK;
}
+
+HRESULT async_operation_notify( IAsyncOperation_IInspectable *operation )
+{
+ struct async_operation *impl = \
impl_from_IAsyncOperation_IInspectable(operation); +
+ impl->status = Completed;
+ if (impl->handler)
+ IAsyncOperationCompletedHandler_IInspectable_Invoke(impl->handler, \
operation, impl->status); +
+ return S_OK;
+}
\ No newline at end of file
diff --git a/dlls/windows.media.speech/private.h \
b/dlls/windows.media.speech/private.h index 1cf61c51f1e..aefadaf21c7 100644
--- a/dlls/windows.media.speech/private.h
+++ b/dlls/windows.media.speech/private.h
@@ -70,6 +70,7 @@ struct vector_iids
};
HRESULT async_operation_create( const GUID *iid, IAsyncOperation_IInspectable **out \
); +HRESULT async_operation_notify( IAsyncOperation_IInspectable *operation );
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 b16ecb24641..793be7d1749 100644
--- a/dlls/windows.media.speech/recognizer.c
+++ b/dlls/windows.media.speech/recognizer.c
@@ -352,8 +352,16 @@ static HRESULT WINAPI recognizer_CompileConstraintsAsync( \
ISpeechRecognizer *ifa
\
IAsyncOperation_SpeechRecognitionCompilationResult **operation ) {
IAsyncOperation_IInspectable **value = (IAsyncOperation_IInspectable \
**)operation; + HRESULT hr;
+
FIXME("iface %p, operation %p semi-stub!\n", iface, operation);
- return async_operation_create(&IID_IAsyncOperation_SpeechRecognitionCompilationResult, \
value); +
+ *operation = NULL;
+
+ if (FAILED(hr = \
async_operation_create(&IID_IAsyncOperation_SpeechRecognitionCompilationResult, \
value))) return hr; + async_operation_notify(*value);
+
+ return S_OK;
}
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 542d6fcf8d0..9c9ebf2c80c 100644
--- a/dlls/windows.media.speech/tests/speech.c
+++ b/dlls/windows.media.speech/tests/speech.c
@@ -949,24 +949,22 @@ static void test_SpeechRecognizer(void)
handler = (void*)0xdeadbeef;
hr = IAsyncOperation_SpeechRecognitionCompilationResult_get_Completed(operation, \
&handler);
- todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
- todo_wine ok(handler == NULL, "Handler had value %p.\n", handler);
-
- if (FAILED(hr)) goto skip_operation;
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(handler == NULL, "Handler had value %p.\n", handler);
hr = IAsyncOperation_SpeechRecognitionCompilationResult_put_Completed(operation, \
&compilation_handler.IAsyncHandler_Compilation_iface);
- todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
check_refcount(&compilation_handler.IAsyncHandler_Compilation_iface, 1);
WaitForSingleObject(compilation_handler.event_finished, INFINITE);
handler = (void*)0xdeadbeef;
hr = IAsyncOperation_SpeechRecognitionCompilationResult_get_Completed(operation, \
&handler);
- todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
- todo_wine ok(handler == NULL, "Handler had value %p.\n", handler);
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(handler == NULL, "Handler had value %p.\n", handler);
hr = IAsyncOperation_SpeechRecognitionCompilationResult_QueryInterface(operation, \
&IID_IAsyncInfo, (void **)&info);
- todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
+ ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
IAsyncInfo_AddRef(info);
check_refcount(operation, 3);
@@ -978,7 +976,7 @@ static void test_SpeechRecognizer(void)
IAsyncOperation_SpeechRecognitionCompilationResult_Release(operation);
ref = IAsyncInfo_Release(info);
- todo_wine ok(ref == 2, "Got unexpected ref %lu.\n", ref);
+ ok(ref == 2, "Got unexpected ref %lu.\n", ref);
id = 0xdeadbeef;
hr = IAsyncInfo_get_Id(info, &id);
@@ -987,22 +985,21 @@ static void test_SpeechRecognizer(void)
async_status = 0xdeadbeef;
hr = IAsyncInfo_get_Status(info, &async_status);
- todo_wine ok(hr == S_OK, "IAsyncInfo_get_Status failed, hr %#lx.\n", hr);
- todo_wine ok(async_status == Completed, "Status was %x.\n", async_status);
+ ok(hr == S_OK, "IAsyncInfo_get_Status failed, hr %#lx.\n", hr);
+ ok(async_status == Completed, "Status was %x.\n", async_status);
hr = IAsyncOperation_SpeechRecognitionCompilationResult_put_Completed(operation, \
NULL);
- todo_wine ok(hr == E_ILLEGAL_DELEGATE_ASSIGNMENT, "Got unexpected hr \
%#lx.\n", hr); + ok(hr == E_ILLEGAL_DELEGATE_ASSIGNMENT, "Got unexpected hr \
%#lx.\n", hr);
hr = IAsyncInfo_Close(info);
todo_wine ok(hr == S_OK, "IAsyncInfo_Close failed, hr %#lx.\n", hr);
ref = IAsyncInfo_Release(info);
- todo_wine ok(ref == 1, "Got unexpected ref %lu.\n", ref);
+ ok(ref == 1, "Got unexpected ref %lu.\n", ref);
hr = IAsyncOperation_SpeechRecognitionCompilationResult_put_Completed(operation, \
NULL);
todo_wine ok(hr == E_ILLEGAL_METHOD_CALL, "Got unexpected hr %#lx.\n", hr);
-skip_operation:
ref = IAsyncOperation_SpeechRecognitionCompilationResult_Release(operation);
ok(!ref, "Got unexpected ref %lu.\n", ref);
--
2.35.1
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic