Signed-off-by: Bernhard Kölbl besentv@gmail.com
-- v3: windows.media.speech: Rename async_operation to async_inspectable. windows.media.speech/tests: Add a test for IAsyncOperation_get_Completed. windows.media.speech/tests: Make the IAsyncInfo_Close block test more consistent. windows.media.speech/tests: Remove some unreliable ref checks.
From: Bernhard Kölbl besentv@gmail.com
Signed-off-by: Bernhard Kölbl besentv@gmail.com --- dlls/windows.media.speech/async.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/windows.media.speech/async.c b/dlls/windows.media.speech/async.c index 64a095a0134..e7547225c1c 100644 --- a/dlls/windows.media.speech/async.c +++ b/dlls/windows.media.speech/async.c @@ -367,6 +367,8 @@ HRESULT async_operation_create( const GUID *iid, IInspectable *invoker, async_op { struct async_operation *impl;
+ TRACE("iid %s, invoker %p, callback %p, out %p.\n", debugstr_guid(iid), invoker, callback, out); + *out = NULL; if (!(impl = calloc(1, sizeof(*impl)))) return E_OUTOFMEMORY; impl->IAsyncOperation_IInspectable_iface.lpVtbl = &async_operation_vtbl;
From: Bernhard Kölbl besentv@gmail.com
Signed-off-by: Bernhard Kölbl besentv@gmail.com --- dlls/windows.media.speech/tests/speech.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/dlls/windows.media.speech/tests/speech.c b/dlls/windows.media.speech/tests/speech.c index 9ef49b160cd..b66782f31ab 100644 --- a/dlls/windows.media.speech/tests/speech.c +++ b/dlls/windows.media.speech/tests/speech.c @@ -1060,8 +1060,7 @@ static void test_SpeechRecognizer(void) ok(hr == E_ILLEGAL_METHOD_CALL, "IAsyncInfo_get_ErrorCode failed, hr %#lx.\n", hr); ok(error_code == E_ILLEGAL_METHOD_CALL, "ErrorCode was %#lx.\n", error_code);
- ref = IAsyncInfo_Release(info); - ok(ref == 1, "Got unexpected ref %lu.\n", ref); + IAsyncInfo_Release(info);
hr = IAsyncOperation_SpeechRecognitionCompilationResult_put_Completed(operation, NULL); ok(hr == E_ILLEGAL_METHOD_CALL, "Got unexpected hr %#lx.\n", hr); @@ -1102,10 +1101,8 @@ static void test_SpeechRecognizer(void) ok(hr == S_OK, "IAsyncInfo_get_Status failed, hr %#lx.\n", hr); ok(async_status == Completed, "Status was %#x.\n", async_status);
- ref = IAsyncInfo_Release(info); - ok(ref >= 1, "Got unexpected ref %lu.\n", ref); - ref = IAsyncOperation_SpeechRecognitionCompilationResult_Release(operation); - ok(ref >= 0, "Got unexpected ref %lu.\n", ref); + IAsyncInfo_Release(info); + IAsyncOperation_SpeechRecognitionCompilationResult_Release(operation);
ref = ISpeechRecognizer_Release(recognizer); ok(ref == 1, "Got unexpected ref %lu.\n", ref); @@ -1154,12 +1151,10 @@ static void test_SpeechRecognizer(void) CloseHandle(compilation_handler.event_block); CloseHandle(compilation_handler.event_finished);
- ref = IAsyncInfo_Release(info); - ok(ref == 1, "Got unexpected ref %lu.\n", ref); + IAsyncInfo_Release(info);
skip_operation: - ref = IAsyncOperation_SpeechRecognitionCompilationResult_Release(operation); - ok(!ref, "Got unexpected ref %lu.\n", ref); + IAsyncOperation_SpeechRecognitionCompilationResult_Release(operation);
ref = ISpeechRecognizer_Release(recognizer); ok(ref == 1, "Got unexpected ref %lu.\n", ref);
From: Bernhard Kölbl besentv@gmail.com
By waiting for an additional event, instead of the return of a thread.
Signed-off-by: Bernhard Kölbl besentv@gmail.com --- dlls/windows.media.speech/tests/speech.c | 35 +++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/dlls/windows.media.speech/tests/speech.c b/dlls/windows.media.speech/tests/speech.c index b66782f31ab..13732a2499b 100644 --- a/dlls/windows.media.speech/tests/speech.c +++ b/dlls/windows.media.speech/tests/speech.c @@ -240,6 +240,7 @@ struct compilation_handler LONG ref;
HANDLE event_block; + HANDLE event_unblock; HANDLE event_finished; DWORD thread_id; }; @@ -294,6 +295,8 @@ HRESULT WINAPI compilation_handler_Invoke( IAsyncHandler_Compilation *iface, if (impl->event_finished) SetEvent(impl->event_finished); /* Block handler until event is set. */ if (impl->event_block) WaitForSingleObject(impl->event_block, INFINITE); + /* Signal unblock of the handler. */ + if (impl->event_unblock) SetEvent(impl->event_unblock);
return S_OK; } @@ -815,15 +818,15 @@ static void test_VoiceInformation(void) RoUninitialize(); }
-struct async_operation_block_param +struct op_put_completed_thread_param { IAsyncOperationCompletedHandler_SpeechRecognitionCompilationResult *handler; IAsyncOperation_SpeechRecognitionCompilationResult *operation; };
-static DWORD WINAPI async_operation_block_thread(void *arg) +static DWORD WINAPI put_completed_thread(void *arg) { - struct async_operation_block_param *param = arg; + struct op_put_completed_thread_param *param = arg; HRESULT hr;
hr = IAsyncOperation_SpeechRecognitionCompilationResult_put_Completed(param->operation, param->handler); @@ -849,15 +852,15 @@ static void test_SpeechRecognizer(void) IInspectable *inspectable = NULL; ILanguage *language = NULL; IAsyncInfo *info = NULL; + struct op_put_completed_thread_param put_completed_param; struct completed_event_handler completed_handler; struct recognition_result_handler result_handler; - struct async_operation_block_param block_param; struct compilation_handler compilation_handler; SpeechRecognitionResultStatus result_status; EventRegistrationToken token = { .value = 0 }; AsyncStatus async_status; HSTRING hstr, hstr_lang; - HANDLE blocked_thread; + HANDLE put_thread; HRESULT hr, error_code; UINT32 id; LONG ref; @@ -1120,23 +1123,22 @@ static void test_SpeechRecognizer(void) compilation_handler_create_static(&compilation_handler); compilation_handler.event_block = CreateEventW(NULL, FALSE, FALSE, NULL); compilation_handler.event_finished = CreateEventW(NULL, FALSE, FALSE, NULL); + compilation_handler.event_unblock = CreateEventW(NULL, FALSE, FALSE, NULL); compilation_handler.thread_id = GetCurrentThreadId();
- ok(compilation_handler.event_finished != NULL, "Finished event wasn't created.\n"); + ok(!!compilation_handler.event_finished, "event_block wasn't created.\n"); + ok(!!compilation_handler.event_finished, "event_finished wasn't created.\n"); + ok(!!compilation_handler.event_finished, "event_unblock wasn't created.\n");
hr = ISpeechRecognizer_CompileConstraintsAsync(recognizer, &operation); ok(hr == S_OK, "ISpeechRecognizer_CompileConstraintsAsync failed, hr %#lx.\n", hr);
- block_param.handler = &compilation_handler.IAsyncHandler_Compilation_iface; - block_param.operation = operation; - blocked_thread = CreateThread(NULL, 0, async_operation_block_thread, &block_param, 0, NULL); + put_completed_param.handler = &compilation_handler.IAsyncHandler_Compilation_iface; + put_completed_param.operation = operation; + put_thread = CreateThread(NULL, 0, put_completed_thread, &put_completed_param, 0, NULL);
ok(!WaitForSingleObject(compilation_handler.event_finished, 5000), "Wait for event_finished failed.\n"); - - ok(WaitForSingleObject(blocked_thread, 100) == WAIT_TIMEOUT, "Wait for block_thread didn't time out.\n"); - - todo_wine ok(compilation_handler.ref == 3, "Got unexpected ref %lu.\n", compilation_handler.ref); - todo_wine check_refcount(operation, 3); + ok(WaitForSingleObject(compilation_handler.event_unblock, 100) == WAIT_TIMEOUT, "Wait for event_unblock didn't time out.\n");
hr = IAsyncOperation_SpeechRecognitionCompilationResult_QueryInterface(operation, &IID_IAsyncInfo, (void **)&info); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); @@ -1145,11 +1147,12 @@ static void test_SpeechRecognizer(void) ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
SetEvent(compilation_handler.event_block); - ok(!WaitForSingleObject(blocked_thread, 1000), "Wait for block_thread failed.\n"); + ok(!WaitForSingleObject(compilation_handler.event_unblock, 1000), "Wait for event_unblock failed.\n");
- CloseHandle(blocked_thread); + CloseHandle(put_thread); CloseHandle(compilation_handler.event_block); CloseHandle(compilation_handler.event_finished); + CloseHandle(compilation_handler.event_unblock);
IAsyncInfo_Release(info);
From: Bernhard Kölbl besentv@gmail.com
This one actually retrieves a handler.
Signed-off-by: Bernhard Kölbl besentv@gmail.com --- dlls/windows.media.speech/tests/speech.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/dlls/windows.media.speech/tests/speech.c b/dlls/windows.media.speech/tests/speech.c index 13732a2499b..ec235542d58 100644 --- a/dlls/windows.media.speech/tests/speech.c +++ b/dlls/windows.media.speech/tests/speech.c @@ -863,7 +863,7 @@ static void test_SpeechRecognizer(void) HANDLE put_thread; HRESULT hr, error_code; UINT32 id; - LONG ref; + LONG ref, old_ref;
hr = RoInitialize(RO_INIT_MULTITHREADED); ok(hr == S_OK, "RoInitialize failed, hr %#lx.\n", hr); @@ -1140,6 +1140,16 @@ static void test_SpeechRecognizer(void) ok(!WaitForSingleObject(compilation_handler.event_finished, 5000), "Wait for event_finished failed.\n"); ok(WaitForSingleObject(compilation_handler.event_unblock, 100) == WAIT_TIMEOUT, "Wait for event_unblock didn't time out.\n");
+ handler = (void*)0xdeadbeef; + old_ref = compilation_handler.ref; + hr = IAsyncOperation_SpeechRecognitionCompilationResult_get_Completed(operation, &handler); + ok(hr == S_OK, "IAsyncOperation_SpeechRecognitionCompilationResult_get_Completed failed, hr %#lx.\n", hr); + todo_wine ok(handler == &compilation_handler.IAsyncHandler_Compilation_iface, "Handler was %p.\n", handler); + + ref = compilation_handler.ref - old_ref; + todo_wine ok(ref == 1, "The ref was increased by %lu.\n", ref); + if (handler) IAsyncOperationCompletedHandler_SpeechRecognitionCompilationResult_Release(handler); + hr = IAsyncOperation_SpeechRecognitionCompilationResult_QueryInterface(operation, &IID_IAsyncInfo, (void **)&info); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
From: Bernhard Kölbl besentv@gmail.com
Signed-off-by: Bernhard Kölbl besentv@gmail.com --- dlls/windows.media.speech/async.c | 125 +++++++++++++------------ dlls/windows.media.speech/private.h | 5 +- dlls/windows.media.speech/recognizer.c | 2 +- 3 files changed, 68 insertions(+), 64 deletions(-)
diff --git a/dlls/windows.media.speech/async.c b/dlls/windows.media.speech/async.c index e7547225c1c..79510d61dc7 100644 --- a/dlls/windows.media.speech/async.c +++ b/dlls/windows.media.speech/async.c @@ -32,7 +32,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(speech); * */
-struct async_operation +struct async_inspectable { IAsyncOperation_IInspectable IAsyncOperation_IInspectable_iface; IAsyncInfo IAsyncInfo_iface; @@ -42,7 +42,7 @@ struct async_operation IAsyncOperationCompletedHandler_IInspectable *handler; IInspectable *result;
- async_operation_callback callback; + async_operation_inspectable_callback callback; TP_WORK *async_run_work; IInspectable *invoker;
@@ -51,14 +51,14 @@ struct async_operation HRESULT hr; };
-static inline struct async_operation *impl_from_IAsyncOperation_IInspectable(IAsyncOperation_IInspectable *iface) +static inline struct async_inspectable *impl_from_IAsyncOperation_IInspectable(IAsyncOperation_IInspectable *iface) { - return CONTAINING_RECORD(iface, struct async_operation, IAsyncOperation_IInspectable_iface); + return CONTAINING_RECORD(iface, struct async_inspectable, IAsyncOperation_IInspectable_iface); }
-static HRESULT WINAPI async_operation_QueryInterface( IAsyncOperation_IInspectable *iface, REFIID iid, void **out ) +static HRESULT WINAPI async_inspectable_QueryInterface( IAsyncOperation_IInspectable *iface, REFIID iid, void **out ) { - struct async_operation *impl = impl_from_IAsyncOperation_IInspectable(iface); + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable(iface);
TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out);
@@ -82,17 +82,17 @@ static HRESULT WINAPI async_operation_QueryInterface( IAsyncOperation_IInspectab return E_NOINTERFACE; }
-static ULONG WINAPI async_operation_AddRef( IAsyncOperation_IInspectable *iface ) +static ULONG WINAPI async_inspectable_AddRef( IAsyncOperation_IInspectable *iface ) { - struct async_operation *impl = impl_from_IAsyncOperation_IInspectable(iface); + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable(iface); ULONG ref = InterlockedIncrement(&impl->ref); TRACE("iface %p, ref %lu.\n", iface, ref); return ref; }
-static ULONG WINAPI async_operation_Release( IAsyncOperation_IInspectable *iface ) +static ULONG WINAPI async_inspectable_Release( IAsyncOperation_IInspectable *iface ) { - struct async_operation *impl = impl_from_IAsyncOperation_IInspectable(iface); + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable(iface);
ULONG ref = InterlockedDecrement(&impl->ref); TRACE("iface %p, ref %lu.\n", iface, ref); @@ -115,28 +115,28 @@ static ULONG WINAPI async_operation_Release( IAsyncOperation_IInspectable *iface return ref; }
-static HRESULT WINAPI async_operation_GetIids( IAsyncOperation_IInspectable *iface, ULONG *iid_count, IID **iids ) +static HRESULT WINAPI async_inspectable_GetIids( IAsyncOperation_IInspectable *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 async_operation_GetRuntimeClassName( IAsyncOperation_IInspectable *iface, HSTRING *class_name ) +static HRESULT WINAPI async_inspectable_GetRuntimeClassName( IAsyncOperation_IInspectable *iface, HSTRING *class_name ) { FIXME("iface %p, class_name %p stub!\n", iface, class_name); return E_NOTIMPL; }
-static HRESULT WINAPI async_operation_GetTrustLevel( IAsyncOperation_IInspectable *iface, TrustLevel *trust_level ) +static HRESULT WINAPI async_inspectable_GetTrustLevel( IAsyncOperation_IInspectable *iface, TrustLevel *trust_level ) { FIXME("iface %p, trust_level %p stub!\n", iface, trust_level); return E_NOTIMPL; }
-static HRESULT WINAPI async_operation_put_Completed( IAsyncOperation_IInspectable *iface, - IAsyncOperationCompletedHandler_IInspectable *handler ) +static HRESULT WINAPI async_inspectable_put_Completed( IAsyncOperation_IInspectable *iface, + IAsyncOperationCompletedHandler_IInspectable *handler ) { - struct async_operation *impl = impl_from_IAsyncOperation_IInspectable(iface); + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable(iface); HRESULT hr = S_OK;
TRACE("iface %p, handler %p.\n", iface, handler); @@ -147,7 +147,7 @@ static HRESULT WINAPI async_operation_put_Completed( IAsyncOperation_IInspectabl else if (impl->handler != HANDLER_NOT_SET) hr = E_ILLEGAL_DELEGATE_ASSIGNMENT; /* - impl->handler can only be set once with async_operation_put_Completed, + impl->handler can only be set once with async_inspectable_put_Completed, so by default we set a non HANDLER_NOT_SET value, in this case handler. */ else if ((impl->handler = handler)) @@ -172,10 +172,10 @@ static HRESULT WINAPI async_operation_put_Completed( IAsyncOperation_IInspectabl return hr; }
-static HRESULT WINAPI async_operation_get_Completed( IAsyncOperation_IInspectable *iface, - IAsyncOperationCompletedHandler_IInspectable **handler ) +static HRESULT WINAPI async_inspectable_get_Completed( IAsyncOperation_IInspectable *iface, + IAsyncOperationCompletedHandler_IInspectable **handler ) { - struct async_operation *impl = impl_from_IAsyncOperation_IInspectable(iface); + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable(iface); HRESULT hr = S_OK;
FIXME("iface %p, handler %p semi stub!\n", iface, handler); @@ -189,10 +189,10 @@ static HRESULT WINAPI async_operation_get_Completed( IAsyncOperation_IInspectabl return hr; }
-static HRESULT WINAPI async_operation_GetResults( IAsyncOperation_IInspectable *iface, IInspectable **results ) +static HRESULT WINAPI async_inspectable_GetResults( IAsyncOperation_IInspectable *iface, IInspectable **results ) { /* NOTE: Despite the name, this function only returns one result! */ - struct async_operation *impl = impl_from_IAsyncOperation_IInspectable(iface); + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable(iface); HRESULT hr;
TRACE("iface %p, results %p.\n", iface, results); @@ -213,20 +213,20 @@ static HRESULT WINAPI async_operation_GetResults( IAsyncOperation_IInspectable * return hr; }
-static const struct IAsyncOperation_IInspectableVtbl async_operation_vtbl = +static const struct IAsyncOperation_IInspectableVtbl async_inspectable_vtbl = { /* IUnknown methods */ - async_operation_QueryInterface, - async_operation_AddRef, - async_operation_Release, + async_inspectable_QueryInterface, + async_inspectable_AddRef, + async_inspectable_Release, /* IInspectable methods */ - async_operation_GetIids, - async_operation_GetRuntimeClassName, - async_operation_GetTrustLevel, + async_inspectable_GetIids, + async_inspectable_GetRuntimeClassName, + async_inspectable_GetTrustLevel, /* IAsyncOperation<IInspectable*> */ - async_operation_put_Completed, - async_operation_get_Completed, - async_operation_GetResults + async_inspectable_put_Completed, + async_inspectable_get_Completed, + async_inspectable_GetResults };
/* @@ -235,17 +235,17 @@ static const struct IAsyncOperation_IInspectableVtbl async_operation_vtbl = * */
-DEFINE_IINSPECTABLE(async_operation_info, IAsyncInfo, struct async_operation, IAsyncOperation_IInspectable_iface) +DEFINE_IINSPECTABLE(async_inspectable_info, IAsyncInfo, struct async_inspectable, IAsyncOperation_IInspectable_iface)
-static HRESULT WINAPI async_operation_info_get_Id( IAsyncInfo *iface, UINT32 *id ) +static HRESULT WINAPI async_inspectable_info_get_Id( IAsyncInfo *iface, UINT32 *id ) { FIXME("iface %p, id %p stub!\n", iface, id); return E_NOTIMPL; }
-static HRESULT WINAPI async_operation_info_get_Status( IAsyncInfo *iface, AsyncStatus *status ) +static HRESULT WINAPI async_inspectable_info_get_Status( IAsyncInfo *iface, AsyncStatus *status ) { - struct async_operation *impl = impl_from_IAsyncInfo(iface); + struct async_inspectable *impl = impl_from_IAsyncInfo(iface); HRESULT hr = S_OK;
TRACE("iface %p, status %p.\n", iface, status); @@ -259,9 +259,9 @@ static HRESULT WINAPI async_operation_info_get_Status( IAsyncInfo *iface, AsyncS return hr; }
-static HRESULT WINAPI async_operation_info_get_ErrorCode( IAsyncInfo *iface, HRESULT *error_code ) +static HRESULT WINAPI async_inspectable_info_get_ErrorCode( IAsyncInfo *iface, HRESULT *error_code ) { - struct async_operation *impl = impl_from_IAsyncInfo(iface); + struct async_inspectable *impl = impl_from_IAsyncInfo(iface); HRESULT hr = S_OK;
TRACE("iface %p, error_code %p.\n", iface, error_code); @@ -276,9 +276,9 @@ static HRESULT WINAPI async_operation_info_get_ErrorCode( IAsyncInfo *iface, HRE return hr; }
-static HRESULT WINAPI async_operation_info_Cancel( IAsyncInfo *iface ) +static HRESULT WINAPI async_inspectable_info_Cancel( IAsyncInfo *iface ) { - struct async_operation *impl = impl_from_IAsyncInfo(iface); + struct async_inspectable *impl = impl_from_IAsyncInfo(iface); HRESULT hr = S_OK;
TRACE("iface %p.\n", iface); @@ -293,9 +293,9 @@ static HRESULT WINAPI async_operation_info_Cancel( IAsyncInfo *iface ) return hr; }
-static HRESULT WINAPI async_operation_info_Close( IAsyncInfo *iface ) +static HRESULT WINAPI async_inspectable_info_Close( IAsyncInfo *iface ) { - struct async_operation *impl = impl_from_IAsyncInfo(iface); + struct async_inspectable *impl = impl_from_IAsyncInfo(iface); HRESULT hr = S_OK;
TRACE("iface %p.\n", iface); @@ -314,29 +314,29 @@ static HRESULT WINAPI async_operation_info_Close( IAsyncInfo *iface ) return hr; }
-static const struct IAsyncInfoVtbl async_operation_info_vtbl = +static const struct IAsyncInfoVtbl async_inspectable_info_vtbl = { /* IUnknown methods */ - async_operation_info_QueryInterface, - async_operation_info_AddRef, - async_operation_info_Release, + async_inspectable_info_QueryInterface, + async_inspectable_info_AddRef, + async_inspectable_info_Release, /* IInspectable methods */ - async_operation_info_GetIids, - async_operation_info_GetRuntimeClassName, - async_operation_info_GetTrustLevel, + async_inspectable_info_GetIids, + async_inspectable_info_GetRuntimeClassName, + async_inspectable_info_GetTrustLevel, /* IAsyncInfo */ - async_operation_info_get_Id, - async_operation_info_get_Status, - async_operation_info_get_ErrorCode, - async_operation_info_Cancel, - async_operation_info_Close + async_inspectable_info_get_Id, + async_inspectable_info_get_Status, + async_inspectable_info_get_ErrorCode, + async_inspectable_info_Cancel, + async_inspectable_info_Close };
-static void CALLBACK async_run_cb(TP_CALLBACK_INSTANCE *instance, void *data, TP_WORK *work) +static void CALLBACK async_inspectable_run_cb(TP_CALLBACK_INSTANCE *instance, void *data, TP_WORK *work) { IAsyncOperation_IInspectable *operation = data; IInspectable *result = NULL; - struct async_operation *impl = impl_from_IAsyncOperation_IInspectable(operation); + struct async_inspectable *impl = impl_from_IAsyncOperation_IInspectable(operation); HRESULT hr;
hr = impl->callback(impl->invoker, &result); @@ -363,16 +363,19 @@ static void CALLBACK async_run_cb(TP_CALLBACK_INSTANCE *instance, void *data, TP IAsyncOperation_IInspectable_Release(operation); }
-HRESULT async_operation_create( const GUID *iid, IInspectable *invoker, async_operation_callback callback, IAsyncOperation_IInspectable **out ) +HRESULT async_operation_inspectable_create( const GUID *iid, + IInspectable *invoker, + async_operation_inspectable_callback callback, + IAsyncOperation_IInspectable **out ) { - struct async_operation *impl; + struct async_inspectable *impl;
TRACE("iid %s, invoker %p, callback %p, out %p.\n", debugstr_guid(iid), invoker, callback, out);
*out = NULL; if (!(impl = calloc(1, sizeof(*impl)))) return E_OUTOFMEMORY; - impl->IAsyncOperation_IInspectable_iface.lpVtbl = &async_operation_vtbl; - impl->IAsyncInfo_iface.lpVtbl = &async_operation_info_vtbl; + impl->IAsyncOperation_IInspectable_iface.lpVtbl = &async_inspectable_vtbl; + impl->IAsyncInfo_iface.lpVtbl = &async_inspectable_info_vtbl; impl->iid = iid; impl->ref = 1;
@@ -380,7 +383,7 @@ HRESULT async_operation_create( const GUID *iid, IInspectable *invoker, async_op impl->callback = callback; impl->status = Started;
- if (!(impl->async_run_work = CreateThreadpoolWork(async_run_cb, &impl->IAsyncOperation_IInspectable_iface, NULL))) + if (!(impl->async_run_work = CreateThreadpoolWork(async_inspectable_run_cb, &impl->IAsyncOperation_IInspectable_iface, NULL))) { free(impl); return HRESULT_FROM_WIN32(GetLastError()); diff --git a/dlls/windows.media.speech/private.h b/dlls/windows.media.speech/private.h index 4b55a5cbfa7..97afa4d3499 100644 --- a/dlls/windows.media.speech/private.h +++ b/dlls/windows.media.speech/private.h @@ -69,9 +69,10 @@ struct vector_iids const GUID *view; };
-typedef HRESULT (WINAPI *async_operation_callback)( IInspectable *invoker, IInspectable **result ); +typedef HRESULT (WINAPI *async_operation_inspectable_callback)( IInspectable *invoker, IInspectable **result );
-HRESULT async_operation_create( const GUID *iid, IInspectable *invoker, async_operation_callback callback, IAsyncOperation_IInspectable **out ); +HRESULT async_operation_inspectable_create( const GUID *iid, IInspectable *invoker, async_operation_inspectable_callback callback, + IAsyncOperation_IInspectable **out );
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 39813ef5607..c78f69b0a67 100644 --- a/dlls/windows.media.speech/recognizer.c +++ b/dlls/windows.media.speech/recognizer.c @@ -480,7 +480,7 @@ static HRESULT WINAPI recognizer_CompileConstraintsAsync( ISpeechRecognizer *ifa { IAsyncOperation_IInspectable **value = (IAsyncOperation_IInspectable **)operation; FIXME("iface %p, operation %p semi-stub!\n", iface, operation); - return async_operation_create(&IID_IAsyncOperation_SpeechRecognitionCompilationResult, NULL, compile_callback, value); + return async_operation_inspectable_create(&IID_IAsyncOperation_SpeechRecognitionCompilationResult, NULL, compile_callback, value); }
static HRESULT WINAPI recognizer_RecognizeAsync( ISpeechRecognizer *iface,
Rémi Bernon (@rbernon) commented about dlls/windows.media.speech/tests/speech.c:
ok(hr == S_OK, "ISpeechRecognizer_CompileConstraintsAsync failed, hr %#lx.\n", hr);
block_param.handler = &compilation_handler.IAsyncHandler_Compilation_iface;
block_param.operation = operation;
blocked_thread = CreateThread(NULL, 0, async_operation_block_thread, &block_param, 0, NULL);
put_completed_param.handler = &compilation_handler.IAsyncHandler_Compilation_iface;
put_completed_param.operation = operation;
put_thread = CreateThread(NULL, 0, put_completed_thread, &put_completed_param, 0, NULL); ok(!WaitForSingleObject(compilation_handler.event_finished, 5000), "Wait for event_finished failed.\n");
ok(WaitForSingleObject(blocked_thread, 100) == WAIT_TIMEOUT, "Wait for block_thread didn't time out.\n");
todo_wine ok(compilation_handler.ref == 3, "Got unexpected ref %lu.\n", compilation_handler.ref);
todo_wine check_refcount(operation, 3);
ok(WaitForSingleObject(compilation_handler.event_unblock, 100) == WAIT_TIMEOUT, "Wait for event_unblock didn't time out.\n");
I don't think it matters so much, but I also don't think this additional event is really useful. If wait succeeds here, it means that `event_block` wasn't waited on in the handler, which would mean something really bad is happening with events.
You could simply keep the thread wait and ref count tests removal here, as they are not reliable, and not add any additional event.
Rémi Bernon (@rbernon) commented about dlls/windows.media.speech/tests/speech.c:
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); SetEvent(compilation_handler.event_block);
ok(!WaitForSingleObject(blocked_thread, 1000), "Wait for block_thread failed.\n");
ok(!WaitForSingleObject(compilation_handler.event_unblock, 1000), "Wait for event_unblock failed.\n");
Here it would just wait on the thread handle, even if it didn't previously block.