From: Bernhard Kölbl besentv@gmail.com
Based on a patch by: Connor McAdams cmcadams@codeweavers.com
Silences a warning about narrator being broken in Forza Horizon 5.
CW-Bug-Id: #19642
Signed-off-by: Bernhard Kölbl besentv@gmail.com --- dlls/windows.media.speech/synthesizer.c | 122 ++++++++++++++++++++++- dlls/windows.media.speech/tests/speech.c | 18 ++-- 2 files changed, 126 insertions(+), 14 deletions(-)
diff --git a/dlls/windows.media.speech/synthesizer.c b/dlls/windows.media.speech/synthesizer.c index 22f28433216..9b3e0ae70fd 100644 --- a/dlls/windows.media.speech/synthesizer.c +++ b/dlls/windows.media.speech/synthesizer.c @@ -146,6 +146,124 @@ static struct voice_information_vector all_voices = 0 };
+/* + * + * ISpeechSynthesisStream + * + */ + +struct synthesis_stream +{ + ISpeechSynthesisStream ISpeechSynthesisStream_iface; + LONG ref; +}; + +static inline struct synthesis_stream *impl_from_ISpeechSynthesisStream( ISpeechSynthesisStream *iface ) +{ + return CONTAINING_RECORD(iface, struct synthesis_stream, ISpeechSynthesisStream_iface); +} + +HRESULT WINAPI synthesis_stream_QueryInterface( ISpeechSynthesisStream *iface, REFIID iid, void **out ) +{ + struct synthesis_stream *impl = impl_from_ISpeechSynthesisStream(iface); + + TRACE("iface %p, iid %s, out %p stub!\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_IUnknown) || + IsEqualGUID(iid, &IID_IInspectable) || + IsEqualGUID(iid, &IID_IAgileObject) || + IsEqualGUID(iid, &IID_ISpeechSynthesisStream)) + { + IInspectable_AddRef((*out = &impl->ISpeechSynthesisStream_iface)); + return S_OK; + } + + FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + *out = NULL; + return E_NOINTERFACE; +} + +ULONG WINAPI synthesis_stream_AddRef( ISpeechSynthesisStream *iface ) +{ + struct synthesis_stream *impl = impl_from_ISpeechSynthesisStream(iface); + ULONG ref = InterlockedIncrement(&impl->ref); + TRACE("iface %p, ref %lu.\n", iface, ref); + return ref; +} + +ULONG WINAPI synthesis_stream_Release( ISpeechSynthesisStream *iface ) +{ + struct synthesis_stream *impl = impl_from_ISpeechSynthesisStream(iface); + ULONG ref = InterlockedDecrement(&impl->ref); + + TRACE("iface %p, ref %lu.\n", iface, ref); + + if (!ref) + free(impl); + + return ref; +} + +HRESULT WINAPI synthesis_stream_GetIids( ISpeechSynthesisStream *iface, ULONG *iid_count, IID **iids ) +{ + FIXME("iface %p, iid_count %p, iids %p stub.\n", iface, iid_count, iids); + return E_NOTIMPL; +} + +HRESULT WINAPI synthesis_stream_GetRuntimeClassName( ISpeechSynthesisStream *iface, HSTRING *class_name ) +{ + FIXME("iface %p, class_name %p stub.\n", iface, class_name); + return E_NOTIMPL; +} + +HRESULT WINAPI synthesis_stream_GetTrustLevel( ISpeechSynthesisStream *iface, TrustLevel *trust_level ) +{ + FIXME("iface %p, trust_level %p stub.\n", iface, trust_level); + return E_NOTIMPL; +} + +HRESULT WINAPI synthesis_stream_get_Markers( ISpeechSynthesisStream *iface, IVectorView_IMediaMarker **value ) +{ + FIXME("iface %p, value %p stub!\n", iface, value); + *value = NULL; + return S_OK; +} + +static const struct ISpeechSynthesisStreamVtbl synthesis_stream_vtbl = +{ + /* IUnknown methods */ + synthesis_stream_QueryInterface, + synthesis_stream_AddRef, + synthesis_stream_Release, + /* IInspectable methods */ + synthesis_stream_GetIids, + synthesis_stream_GetRuntimeClassName, + synthesis_stream_GetTrustLevel, + /* ISpeechSynthesisStream methods */ + synthesis_stream_get_Markers +}; + + +static HRESULT synthesis_stream_create( ISpeechSynthesisStream **out ) +{ + struct synthesis_stream *impl; + + TRACE("out %p.\n", out); + + if (!(impl = calloc(1, sizeof(*impl)))) + { + *out = NULL; + return E_OUTOFMEMORY; + } + + impl->ISpeechSynthesisStream_iface.lpVtbl = &synthesis_stream_vtbl; + impl->ref = 1; + + TRACE("created ISpeechSynthesisStream %p.\n", impl); + *out = &impl->ISpeechSynthesisStream_iface; + return S_OK; +} + /* * * SpeechSynthesizer runtimeclass @@ -243,7 +361,7 @@ static HRESULT WINAPI synthesizer_GetTrustLevel( ISpeechSynthesizer *iface, Trus
static HRESULT CALLBACK text_to_stream_operation( IInspectable *invoker, IInspectable **result ) { - return S_OK; + return synthesis_stream_create((ISpeechSynthesisStream **)result); }
static HRESULT WINAPI synthesizer_SynthesizeTextToStreamAsync( ISpeechSynthesizer *iface, HSTRING text, @@ -256,7 +374,7 @@ static HRESULT WINAPI synthesizer_SynthesizeTextToStreamAsync( ISpeechSynthesize
static HRESULT CALLBACK ssml_to_stream_operation( IInspectable *invoker, IInspectable **result ) { - return S_OK; + return synthesis_stream_create((ISpeechSynthesisStream **)result); }
static HRESULT WINAPI synthesizer_SynthesizeSsmlToStreamAsync( ISpeechSynthesizer *iface, HSTRING ssml, diff --git a/dlls/windows.media.speech/tests/speech.c b/dlls/windows.media.speech/tests/speech.c index 726ff6b0f5b..652542aac92 100644 --- a/dlls/windows.media.speech/tests/speech.c +++ b/dlls/windows.media.speech/tests/speech.c @@ -938,13 +938,10 @@ static void test_SpeechSynthesizer(void) check_interface(operation_ss_stream, &IID_IAgileObject, TRUE);
hr = IAsyncOperation_SpeechSynthesisStream_GetResults(operation_ss_stream, &ss_stream); - todo_wine ok(hr == S_OK, "IAsyncOperation_SpeechSynthesisStream_GetResults failed, hr %#lx\n", hr); + ok(hr == S_OK, "IAsyncOperation_SpeechSynthesisStream_GetResults failed, hr %#lx\n", hr);
- if (hr == S_OK && ss_stream) - { - ref = ISpeechSynthesisStream_Release(ss_stream); - todo_wine ok(ref == 0, "Got unexpected ref %lu.\n", ref); - } + ref = ISpeechSynthesisStream_Release(ss_stream); + ok(ref == 0, "Got unexpected ref %lu.\n", ref);
IAsyncOperation_SpeechSynthesisStream_Release(operation_ss_stream); WindowsDeleteString(str); @@ -962,13 +959,10 @@ static void test_SpeechSynthesizer(void) check_interface(operation_ss_stream, &IID_IAgileObject, TRUE);
hr = IAsyncOperation_SpeechSynthesisStream_GetResults(operation_ss_stream, &ss_stream); - todo_wine ok(hr == S_OK, "IAsyncOperation_SpeechSynthesisStream_GetResults failed, hr %#lx\n", hr); + ok(hr == S_OK, "IAsyncOperation_SpeechSynthesisStream_GetResults failed, hr %#lx\n", hr);
- if (hr == S_OK && ss_stream) - { - ref = ISpeechSynthesisStream_Release(ss_stream); - ok(ref == 0, "Got unexpected ref %lu.\n", ref); - } + ref = ISpeechSynthesisStream_Release(ss_stream); + ok(ref == 0, "Got unexpected ref %lu.\n", ref);
IAsyncOperation_SpeechSynthesisStream_Release(operation_ss_stream); WindowsDeleteString(str);