windows.media.speech: Add ISpeechRecognitionCompilationResult.

Signed-off-by: Bernhard Kölbl <besentv@gmail.com>
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Bernhard Kölbl 2022-04-22 14:48:07 +02:00 committed by Alexandre Julliard
parent f3c131c768
commit 5c27a1ccc2
2 changed files with 130 additions and 11 deletions

View File

@ -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
@ -350,7 +472,7 @@ static HRESULT WINAPI recognizer_get_UIOptions( ISpeechRecognizer *iface, ISpeec
static HRESULT WINAPI compile_callback( IInspectable *invoker, IInspectable **result )
{
return S_OK;
return compilation_result_create(SpeechRecognitionResultStatus_Success, (ISpeechRecognitionCompilationResult **) result);
}
static HRESULT WINAPI recognizer_CompileConstraintsAsync( ISpeechRecognizer *iface,

View File

@ -1005,19 +1005,16 @@ static void test_SpeechRecognizer(void)
compilation_result = (void*)0xdeadbeef;
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 (compilation_result != (void*)0xdeadbeef)
{
todo_wine check_interface(compilation_result, &IID_IAgileObject, TRUE);
check_interface(compilation_result, &IID_IAgileObject, TRUE);
hr = ISpeechRecognitionCompilationResult_get_Status(compilation_result, &result_status);
todo_wine ok(hr == S_OK, "ISpeechRecognitionCompilationResult_get_Status failed, hr %#lx.\n", hr);
todo_wine ok(result_status == SpeechRecognitionResultStatus_Success, "Got unexpected status %#x.\n", 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);
todo_wine ok(!ref , "Got unexpected ref %lu.\n", ref);
}
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);