From eb6ac356544c387f8963628a096f3f97fd84c844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20K=C3=B6lbl?= Date: Wed, 9 Mar 2022 18:45:30 +0100 Subject: [PATCH] windows.media.speech: Explicitly check for available activation factory. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also return the right value when no factory was found. Signed-off-by: Bernhard Kölbl Signed-off-by: Rémi Bernon Signed-off-by: Alexandre Julliard --- dlls/windows.media.speech/main.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/dlls/windows.media.speech/main.c b/dlls/windows.media.speech/main.c index 94e6e5f9b2c..29bacd846b0 100644 --- a/dlls/windows.media.speech/main.c +++ b/dlls/windows.media.speech/main.c @@ -24,15 +24,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(speech); -static const char *debugstr_hstring(HSTRING hstr) -{ - const WCHAR *str; - UINT32 len; - if (hstr && !((ULONG_PTR)hstr >> 16)) return "(invalid)"; - str = WindowsGetStringRawBuffer(hstr, &len); - return wine_dbgstr_wn(str, len); -} - struct voice_information_vector { IVectorView_VoiceInformation IVectorView_VoiceInformation_iface; @@ -583,15 +574,15 @@ HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID riid, void **out) HRESULT WINAPI DllGetActivationFactory(HSTRING classid, IActivationFactory **factory) { - TRACE("classid %s, factory %p.\n", debugstr_hstring(classid), factory); + const WCHAR *buffer = WindowsGetStringRawBuffer(classid, NULL); - if (wcscmp(WindowsGetStringRawBuffer(classid, NULL), L"Windows.Media.SpeechSynthesis.SpeechSynthesizer")) - { - ERR("Unknown classid %s.\n", debugstr_hstring(classid)); - return CLASS_E_CLASSNOTAVAILABLE; - } + TRACE("classid %s, factory %p.\n", debugstr_w(buffer), factory); - *factory = &windows_media_speech.IActivationFactory_iface; - IUnknown_AddRef(*factory); - return S_OK; + *factory = NULL; + + if (!wcscmp(buffer, L"Windows.Media.SpeechSynthesis.SpeechSynthesizer")) + IActivationFactory_AddRef((*factory = &windows_media_speech.IActivationFactory_iface)); + + if (*factory) return S_OK; + return CLASS_E_CLASSNOTAVAILABLE; }