Commit d8a6fc03 authored by Bernhard Kölbl's avatar Bernhard Kölbl Committed by Alexandre Julliard

windows.media.speech: Add IAgileObject to SpeechRecognizer.

Also make some style improvements. Signed-off-by: 's avatarBernhard Kölbl <besentv@gmail.com> Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 9bfe419e
...@@ -56,19 +56,20 @@ static HRESULT WINAPI recognizer_QueryInterface( ISpeechRecognizer *iface, REFII ...@@ -56,19 +56,20 @@ static HRESULT WINAPI recognizer_QueryInterface( ISpeechRecognizer *iface, REFII
if (IsEqualGUID(iid, &IID_IUnknown) || if (IsEqualGUID(iid, &IID_IUnknown) ||
IsEqualGUID(iid, &IID_IInspectable) || IsEqualGUID(iid, &IID_IInspectable) ||
IsEqualGUID(iid, &IID_IAgileObject) ||
IsEqualGUID(iid, &IID_ISpeechRecognizer)) IsEqualGUID(iid, &IID_ISpeechRecognizer))
{ {
IInspectable_AddRef((*out = &impl->ISpeechRecognizer_iface)); IInspectable_AddRef((*out = &impl->ISpeechRecognizer_iface));
return S_OK; return S_OK;
} }
if(IsEqualGUID(iid, &IID_IClosable)) if (IsEqualGUID(iid, &IID_IClosable))
{ {
IInspectable_AddRef((*out = &impl->IClosable_iface)); IInspectable_AddRef((*out = &impl->IClosable_iface));
return S_OK; return S_OK;
} }
if(IsEqualGUID(iid, &IID_ISpeechRecognizer2)) if (IsEqualGUID(iid, &IID_ISpeechRecognizer2))
{ {
IInspectable_AddRef((*out = &impl->ISpeechRecognizer2_iface)); IInspectable_AddRef((*out = &impl->ISpeechRecognizer2_iface));
return S_OK; return S_OK;
...@@ -94,7 +95,7 @@ static ULONG WINAPI recognizer_Release( ISpeechRecognizer *iface ) ...@@ -94,7 +95,7 @@ static ULONG WINAPI recognizer_Release( ISpeechRecognizer *iface )
ULONG ref = InterlockedDecrement(&impl->ref); ULONG ref = InterlockedDecrement(&impl->ref);
TRACE("iface %p, ref %lu.\n", iface, ref); TRACE("iface %p, ref %lu.\n", iface, ref);
if(!ref) if (!ref)
free(impl); free(impl);
return ref; return ref;
...@@ -403,7 +404,7 @@ static HRESULT WINAPI activation_factory_GetTrustLevel( IActivationFactory *ifac ...@@ -403,7 +404,7 @@ static HRESULT WINAPI activation_factory_GetTrustLevel( IActivationFactory *ifac
static HRESULT WINAPI activation_factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) static HRESULT WINAPI activation_factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance )
{ {
struct recognizer_statics *impl = impl_from_IActivationFactory(iface); struct recognizer_statics *impl = impl_from_IActivationFactory(iface);
TRACE("iface %p, instance %p\n", iface, instance); TRACE("iface %p, instance %p.\n", iface, instance);
return ISpeechRecognizerFactory_Create(&impl->ISpeechRecognizerFactory_iface, NULL, (ISpeechRecognizer **)instance); return ISpeechRecognizerFactory_Create(&impl->ISpeechRecognizerFactory_iface, NULL, (ISpeechRecognizer **)instance);
} }
...@@ -441,15 +442,15 @@ static HRESULT WINAPI recognizer_factory_Create( ISpeechRecognizerFactory *iface ...@@ -441,15 +442,15 @@ static HRESULT WINAPI recognizer_factory_Create( ISpeechRecognizerFactory *iface
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
if(language) if (language)
FIXME("ILanguage parameter unused. Stub!\n"); FIXME("language parameter unused. Stub!\n");
impl->ISpeechRecognizer_iface.lpVtbl = &speech_recognizer_vtbl; impl->ISpeechRecognizer_iface.lpVtbl = &speech_recognizer_vtbl;
impl->IClosable_iface.lpVtbl = &closable_vtbl; impl->IClosable_iface.lpVtbl = &closable_vtbl;
impl->ISpeechRecognizer2_iface.lpVtbl = &speech_recognizer2_vtbl; impl->ISpeechRecognizer2_iface.lpVtbl = &speech_recognizer2_vtbl;
impl->ref = 1; impl->ref = 1;
TRACE("created SpeechRecognizer %p\n", impl); TRACE("created SpeechRecognizer %p.\n", impl);
*speechrecognizer = &impl->ISpeechRecognizer_iface; *speechrecognizer = &impl->ISpeechRecognizer_iface;
return S_OK; return S_OK;
......
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
#include "wine/test.h" #include "wine/test.h"
#define SPERR_WINRT_INTERNAL_ERROR 0x800455a0
HRESULT WINAPI (*pDllGetActivationFactory)(HSTRING, IActivationFactory **); HRESULT WINAPI (*pDllGetActivationFactory)(HSTRING, IActivationFactory **);
static inline LONG get_ref(IUnknown *obj) static inline LONG get_ref(IUnknown *obj)
...@@ -148,7 +150,7 @@ static void test_ActivationFactory(void) ...@@ -148,7 +150,7 @@ static void test_ActivationFactory(void)
hdll = LoadLibraryW(L"windows.media.speech.dll"); hdll = LoadLibraryW(L"windows.media.speech.dll");
if(hdll) if (hdll)
{ {
pDllGetActivationFactory = (void *)GetProcAddress(hdll, "DllGetActivationFactory"); pDllGetActivationFactory = (void *)GetProcAddress(hdll, "DllGetActivationFactory");
ok(!!pDllGetActivationFactory, "DllGetActivationFactory not found.\n"); ok(!!pDllGetActivationFactory, "DllGetActivationFactory not found.\n");
...@@ -364,7 +366,7 @@ static void test_SpeechRecognizer(void) ...@@ -364,7 +366,7 @@ static void test_SpeechRecognizer(void)
hr = RoGetActivationFactory(hstr, &IID_IActivationFactory, (void **)&factory); hr = RoGetActivationFactory(hstr, &IID_IActivationFactory, (void **)&factory);
ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG), "RoGetActivationFactory failed, hr %#lx.\n", hr); ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG), "RoGetActivationFactory failed, hr %#lx.\n", hr);
if(hr == REGDB_E_CLASSNOTREG) /* Win 8 and 8.1 */ if (hr == REGDB_E_CLASSNOTREG) /* Win 8 and 8.1 */
{ {
win_skip("SpeechRecognizer activation factory not available!\n"); win_skip("SpeechRecognizer activation factory not available!\n");
goto done; goto done;
...@@ -379,7 +381,7 @@ static void test_SpeechRecognizer(void) ...@@ -379,7 +381,7 @@ static void test_SpeechRecognizer(void)
hr = ISpeechRecognizerStatics_get_SystemSpeechLanguage(sr_statics, &language); hr = ISpeechRecognizerStatics_get_SystemSpeechLanguage(sr_statics, &language);
todo_wine ok(hr == S_OK, "ISpeechRecognizerStatics_SystemSpeechLanguage failed, hr %#lx.\n", hr); todo_wine ok(hr == S_OK, "ISpeechRecognizerStatics_SystemSpeechLanguage failed, hr %#lx.\n", hr);
if(hr == S_OK) if (hr == S_OK)
{ {
hr = ILanguage_get_LanguageTag(language, &hstr_lang); hr = ILanguage_get_LanguageTag(language, &hstr_lang);
ok(hr == S_OK, "ILanguage_get_LanguageTag failed, hr %#lx.\n", hr); ok(hr == S_OK, "ILanguage_get_LanguageTag failed, hr %#lx.\n", hr);
...@@ -395,7 +397,7 @@ static void test_SpeechRecognizer(void) ...@@ -395,7 +397,7 @@ static void test_SpeechRecognizer(void)
hr = IActivationFactory_QueryInterface(factory, &IID_ISpeechRecognizerStatics2, (void **)&sr_statics2); hr = IActivationFactory_QueryInterface(factory, &IID_ISpeechRecognizerStatics2, (void **)&sr_statics2);
ok(hr == S_OK || broken(hr == E_NOINTERFACE), "IActivationFactory_QueryInterface IID_ISpeechRecognizerStatics2 failed, hr %#lx.\n", hr); ok(hr == S_OK || broken(hr == E_NOINTERFACE), "IActivationFactory_QueryInterface IID_ISpeechRecognizerStatics2 failed, hr %#lx.\n", hr);
if(hr == S_OK) /* SpeechRecognizerStatics2 not implemented on Win10 1507 */ if (hr == S_OK) /* SpeechRecognizerStatics2 not implemented on Win10 1507 */
{ {
ref = ISpeechRecognizerStatics2_Release(sr_statics2); ref = ISpeechRecognizerStatics2_Release(sr_statics2);
ok(ref == 3, "Got unexpected ref %lu.\n", ref); ok(ref == 3, "Got unexpected ref %lu.\n", ref);
...@@ -408,10 +410,13 @@ static void test_SpeechRecognizer(void) ...@@ -408,10 +410,13 @@ static void test_SpeechRecognizer(void)
ok(ref == 1, "Got unexpected ref %lu.\n", ref); ok(ref == 1, "Got unexpected ref %lu.\n", ref);
hr = RoActivateInstance(hstr, &inspectable); hr = RoActivateInstance(hstr, &inspectable);
ok(hr == S_OK || broken(hr == 0x800455a0), "Got unexpected hr %#lx.\n", hr); ok(hr == S_OK || broken(hr == SPERR_WINRT_INTERNAL_ERROR), "Got unexpected hr %#lx.\n", hr);
if(hr == S_OK) if (hr == S_OK)
{ {
check_refcount(inspectable, 1);
check_interface(factory, &IID_IAgileObject, TRUE);
hr = IInspectable_QueryInterface(inspectable, &IID_ISpeechRecognizer, (void **)&recognizer); hr = IInspectable_QueryInterface(inspectable, &IID_ISpeechRecognizer, (void **)&recognizer);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
...@@ -433,7 +438,7 @@ static void test_SpeechRecognizer(void) ...@@ -433,7 +438,7 @@ static void test_SpeechRecognizer(void)
ref = IInspectable_Release(inspectable); ref = IInspectable_Release(inspectable);
ok(!ref, "Got unexpected ref %lu.\n", ref); ok(!ref, "Got unexpected ref %lu.\n", ref);
} }
else if(hr == 0x800455a0) /* Not sure what this hr is... Probably if a language pack is not installed. */ else if (hr == SPERR_WINRT_INTERNAL_ERROR) /* Not sure when this triggers. Probably if a language pack is not installed. */
{ {
win_skip("Could not init SpeechRecognizer with default language!\n"); win_skip("Could not init SpeechRecognizer with default language!\n");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment