Needed by Assassin's Creed Valhalla.
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/sapi/Makefile.in | 1 + dlls/sapi/main.c | 3 + dlls/sapi/sapi_classes.idl | 14 ++ dlls/sapi/sapi_private.h | 1 + dlls/sapi/stream.c | 249 ++++++++++++++++++++++++++++++++++++ dlls/sapi/tests/Makefile.in | 1 + dlls/sapi/tests/stream.c | 69 ++++++++++ include/sapi.idl | 14 ++ 8 files changed, 352 insertions(+) create mode 100644 dlls/sapi/stream.c create mode 100644 dlls/sapi/tests/stream.c
diff --git a/dlls/sapi/Makefile.in b/dlls/sapi/Makefile.in index 464a174caa0..f695bd47b12 100644 --- a/dlls/sapi/Makefile.in +++ b/dlls/sapi/Makefile.in @@ -6,6 +6,7 @@ EXTRADLLFLAGS = -mno-cygwin C_SRCS = \ automation.c \ main.c \ + stream.c \ token.c \ tts.c
diff --git a/dlls/sapi/main.c b/dlls/sapi/main.c index 9c644001faa..cbe097f22ad 100644 --- a/dlls/sapi/main.c +++ b/dlls/sapi/main.c @@ -107,6 +107,7 @@ static const struct IClassFactoryVtbl class_factory_vtbl =
static struct class_factory data_key_cf = { { &class_factory_vtbl }, data_key_create }; static struct class_factory file_stream_cf = { { &class_factory_vtbl }, file_stream_create }; +static struct class_factory speech_stream_cf = { { &class_factory_vtbl }, speech_stream_create }; static struct class_factory speech_voice_cf = { { &class_factory_vtbl }, speech_voice_create }; static struct class_factory token_category_cf = { { &class_factory_vtbl }, token_category_create }; static struct class_factory token_enum_cf = { { &class_factory_vtbl }, token_enum_create }; @@ -131,6 +132,8 @@ HRESULT WINAPI DllGetClassObject( REFCLSID clsid, REFIID iid, void **obj ) cf = &token_enum_cf.IClassFactory_iface; else if (IsEqualCLSID( clsid, &CLSID_SpObjectToken )) cf = &token_cf.IClassFactory_iface; + else if (IsEqualCLSID( clsid, &CLSID_SpStream )) + cf = &speech_stream_cf.IClassFactory_iface; else if (IsEqualCLSID( clsid, &CLSID_SpVoice )) cf = &speech_voice_cf.IClassFactory_iface;
diff --git a/dlls/sapi/sapi_classes.idl b/dlls/sapi/sapi_classes.idl index 082244e0812..bb580dde18e 100644 --- a/dlls/sapi/sapi_classes.idl +++ b/dlls/sapi/sapi_classes.idl @@ -64,6 +64,20 @@ coclass SpObjectToken [default] interface ISpDataKey; }
+[ + uuid(715d9c59-4442-11d2-9605-00c04f8ee628), + helpstring("Speech Stream"), + progid("SAPI.SpStream.1"), + vi_progid("SAPI.SpStream"), + threading(both), + restricted, + hidden +] +coclass SpStream +{ + interface ISpStream; +} + [ uuid(96749377-3391-11d2-9ee3-00c04f797396), helpstring("Speech Voice"), diff --git a/dlls/sapi/sapi_private.h b/dlls/sapi/sapi_private.h index 414dea2755a..509bcb0715b 100644 --- a/dlls/sapi/sapi_private.h +++ b/dlls/sapi/sapi_private.h @@ -22,6 +22,7 @@
HRESULT data_key_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN; HRESULT file_stream_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN; +HRESULT speech_stream_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN; HRESULT speech_voice_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN; HRESULT token_category_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN; HRESULT token_enum_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN; diff --git a/dlls/sapi/stream.c b/dlls/sapi/stream.c new file mode 100644 index 00000000000..06ba4367b48 --- /dev/null +++ b/dlls/sapi/stream.c @@ -0,0 +1,249 @@ +/* + * Speech API (SAPI) stream implementation. + * + * Copyright 2020 Gijs Vermeulen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "objbase.h" + +#include "sapiddk.h" + +#include "wine/debug.h" + +#include "sapi_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(sapi); + +struct spstream +{ + ISpStream ISpStream_iface; + LONG ref; +}; + +static inline struct spstream *impl_from_ISpStream(ISpStream *iface) +{ + return CONTAINING_RECORD(iface, struct spstream, ISpStream_iface); +} + +static HRESULT WINAPI spstream_QueryInterface(ISpStream *iface, REFIID iid, void **obj) +{ + struct spstream *This = impl_from_ISpStream(iface); + + TRACE("(%p, %s, %p).\n", iface, debugstr_guid(iid), obj); + + if (IsEqualIID(iid, &IID_IUnknown) || + IsEqualIID(iid, &IID_ISpStream)) + *obj = &This->ISpStream_iface; + else + { + *obj = NULL; + FIXME("interface %s not implemented.\n", debugstr_guid(iid)); + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown *)*obj); + return S_OK; +} + +static ULONG WINAPI spstream_AddRef(ISpStream *iface) +{ + struct spstream *This = impl_from_ISpStream(iface); + ULONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p): ref=%u.\n", iface, ref); + + return ref; +} + +static ULONG WINAPI spstream_Release(ISpStream *iface) +{ + struct spstream *This = impl_from_ISpStream(iface); + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p): ref=%u.\n", iface, ref); + + if (!ref) + { + heap_free(This); + } + + return ref; +} + +static HRESULT WINAPI spstream_Read(ISpStream *iface, void *pv, ULONG cb, ULONG *read) +{ + FIXME("(%p, %p, %d, %p): stub.\n", iface, pv, cb, read); + + return E_NOTIMPL; +} + +static HRESULT WINAPI spstream_Write(ISpStream *iface, const void *pv, ULONG cb, ULONG *written) +{ + FIXME("(%p, %p, %d, %p): stub.\n", iface, pv, cb, written); + + return E_NOTIMPL; +} + +static HRESULT WINAPI spstream_Seek(ISpStream *iface, LARGE_INTEGER mode, DWORD origin, ULARGE_INTEGER *position) +{ + FIXME("(%p, %s, %d, %p): stub.\n", iface, wine_dbgstr_longlong(mode.QuadPart), origin, position); + + return E_NOTIMPL; +} + +static HRESULT WINAPI spstream_SetSize(ISpStream *iface, ULARGE_INTEGER size) +{ + FIXME("(%p, %s): stub.\n", iface, wine_dbgstr_longlong(size.QuadPart)); + + return E_NOTIMPL; +} + +static HRESULT WINAPI spstream_CopyTo(ISpStream *iface, IStream *stream, ULARGE_INTEGER cb, + ULARGE_INTEGER *read, ULARGE_INTEGER *written) +{ + FIXME("(%p, %p, %s, %p, %p): stub.\n", iface, stream, wine_dbgstr_longlong(cb.QuadPart), + read, written); + + return E_NOTIMPL; +} + +static HRESULT WINAPI spstream_Commit(ISpStream *iface, DWORD flag) +{ + FIXME("(%p, %d): stub.\n", iface, flag); + + return E_NOTIMPL; +} + +static HRESULT WINAPI spstream_Revert(ISpStream *iface) +{ + FIXME("(%p): stub.\n", iface); + + return E_NOTIMPL; +} + +static HRESULT WINAPI spstream_LockRegion(ISpStream *iface, ULARGE_INTEGER offset, ULARGE_INTEGER cb, DWORD type) +{ + FIXME("(%p, %s, %s, %d): stub.\n", iface, wine_dbgstr_longlong(offset.QuadPart), + wine_dbgstr_longlong(cb.QuadPart), type); + + return E_NOTIMPL; +} + +static HRESULT WINAPI spstream_UnlockRegion(ISpStream *iface, ULARGE_INTEGER offset, ULARGE_INTEGER cb, DWORD type) +{ + FIXME("(%p, %s, %s, %d): stub.\n", iface, wine_dbgstr_longlong(offset.QuadPart), + wine_dbgstr_longlong(cb.QuadPart), type); + + return E_NOTIMPL; +} + +static HRESULT WINAPI spstream_Stat(ISpStream *iface, STATSTG *statstg, DWORD flag) +{ + FIXME("(%p, %p, %d): stub.\n", iface, statstg, flag); + + return E_NOTIMPL; +} + +static HRESULT WINAPI spstream_Clone(ISpStream *iface, IStream **stream) +{ + FIXME("(%p, %p): stub.\n", iface, stream); + + return E_NOTIMPL; +} + +static HRESULT WINAPI spstream_GetFormat(ISpStream *iface, GUID *format, WAVEFORMATEX **wave) +{ + FIXME("(%p, %p, %p): stub.\n", iface, format, wave); + + return E_NOTIMPL; +} + +static HRESULT WINAPI spstream_SetBaseStream(ISpStream *iface, IStream *stream, REFGUID format, + const WAVEFORMATEX *wave) +{ + FIXME("(%p, %p, %s, %p): stub.\n", iface, stream, debugstr_guid(format), wave); + + return E_NOTIMPL; +} + +static HRESULT WINAPI spstream_GetBaseStream(ISpStream *iface, IStream **stream) +{ + FIXME("(%p, %p): stub.\n", iface, stream); + + return E_NOTIMPL; +} + +static HRESULT WINAPI spstream_BindToFile(ISpStream *iface, LPCWSTR filename, SPFILEMODE mode, + const GUID *format, const WAVEFORMATEX* wave, + ULONGLONG interest) +{ + FIXME("(%p, %s, %d, %s, %p, %s): stub.\n", iface, debugstr_w(filename), mode, debugstr_guid(format), + wave, wine_dbgstr_longlong(interest)); + + return E_NOTIMPL; +} + +static HRESULT WINAPI spstream_Close(ISpStream *iface) +{ + FIXME("(%p): stub.\n", iface); + + return E_NOTIMPL; +} + +const static ISpStreamVtbl spstream_vtbl = +{ + spstream_QueryInterface, + spstream_AddRef, + spstream_Release, + spstream_Read, + spstream_Write, + spstream_Seek, + spstream_SetSize, + spstream_CopyTo, + spstream_Commit, + spstream_Revert, + spstream_LockRegion, + spstream_UnlockRegion, + spstream_Stat, + spstream_Clone, + spstream_GetFormat, + spstream_SetBaseStream, + spstream_GetBaseStream, + spstream_BindToFile, + spstream_Close +}; + +HRESULT speech_stream_create(IUnknown *outer, REFIID iid, void **obj) +{ + struct spstream *This = heap_alloc(sizeof(*This)); + HRESULT hr; + + if (!This) return E_OUTOFMEMORY; + This->ISpStream_iface.lpVtbl = &spstream_vtbl; + This->ref = 1; + + hr = ISpStream_QueryInterface(&This->ISpStream_iface, iid, obj); + + ISpStream_Release(&This->ISpStream_iface); + return hr; +} diff --git a/dlls/sapi/tests/Makefile.in b/dlls/sapi/tests/Makefile.in index d5d97550970..f1de67418dc 100644 --- a/dlls/sapi/tests/Makefile.in +++ b/dlls/sapi/tests/Makefile.in @@ -3,5 +3,6 @@ IMPORTS = ole32 user32 advapi32
C_SRCS = \ automation.c \ + stream.c \ token.c \ tts.c diff --git a/dlls/sapi/tests/stream.c b/dlls/sapi/tests/stream.c new file mode 100644 index 00000000000..f5248ff756d --- /dev/null +++ b/dlls/sapi/tests/stream.c @@ -0,0 +1,69 @@ +/* + * Speech API (SAPI) stream tests. + * + * Copyright 2020 Gijs Vermeulen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define COBJMACROS + +#include "sapiddk.h" +#include "sperror.h" + +#include "wine/test.h" + +#define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__) +static void _expect_ref(IUnknown *obj, ULONG ref, int line) +{ + ULONG rc; + IUnknown_AddRef(obj); + rc = IUnknown_Release(obj); + ok_(__FILE__,line)(rc == ref, "Unexpected refcount %d, expected %d.\n", rc, ref); +} + +static void test_interfaces(void) +{ + ISpStream *speech_stream; + IDispatch *dispatch; + IUnknown *unk; + HRESULT hr; + + hr = CoCreateInstance(&CLSID_SpStream, NULL, CLSCTX_INPROC_SERVER, + &IID_ISpStream, (void **)&speech_stream); + ok(hr == S_OK, "Failed to create ISpStream interface: %#x.\n", hr); + EXPECT_REF(speech_stream, 1); + + hr = CoCreateInstance(&CLSID_SpStream, NULL, CLSCTX_INPROC_SERVER, + &IID_IUnknown, (void **)&unk); + ok(hr == S_OK, "Failed to create IUnknown interface: %#x.\n", hr); + EXPECT_REF(unk, 1); + EXPECT_REF(speech_stream, 1); + IUnknown_Release(unk); + + hr = CoCreateInstance(&CLSID_SpStream, NULL, CLSCTX_INPROC_SERVER, + &IID_IDispatch, (void **)&dispatch); + ok(hr == E_NOINTERFACE, "Succeeded to create IDispatch interface: %#x.\n", hr); + ok(!dispatch, "Expected NULL dispatch, got %p.", dispatch); + + ISpStream_Release(speech_stream); +} + +START_TEST(stream) +{ + CoInitialize(NULL); + test_interfaces(); + CoUninitialize(); +} diff --git a/include/sapi.idl b/include/sapi.idl index 0a7a034cace..e71d009428c 100644 --- a/include/sapi.idl +++ b/include/sapi.idl @@ -1086,6 +1086,20 @@ library SpeechLib interface ISpRecognizer; };
+ [ + uuid(715d9c59-4442-11d2-9605-00c04f8ee628), + helpstring("Speech Stream"), + progid("SAPI.SpStream.1"), + vi_progid("SAPI.SpStream"), + threading(both), + restricted, + hidden + ] + coclass SpStream + { + interface ISpStream; + }; + [ uuid(96749377-3391-11d2-9ee3-00c04f797396) ]
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/sapi/Makefile.in | 1 + dlls/sapi/main.c | 3 + dlls/sapi/resource.c | 140 ++++++++++++++++++++++++++++++++++++ dlls/sapi/sapi_classes.idl | 14 ++++ dlls/sapi/sapi_private.h | 1 + dlls/sapi/tests/Makefile.in | 1 + dlls/sapi/tests/resource.c | 78 ++++++++++++++++++++ include/sapi.idl | 32 +++++++++ 8 files changed, 270 insertions(+) create mode 100644 dlls/sapi/resource.c create mode 100644 dlls/sapi/tests/resource.c
diff --git a/dlls/sapi/Makefile.in b/dlls/sapi/Makefile.in index f695bd47b12..466941ddd87 100644 --- a/dlls/sapi/Makefile.in +++ b/dlls/sapi/Makefile.in @@ -6,6 +6,7 @@ EXTRADLLFLAGS = -mno-cygwin C_SRCS = \ automation.c \ main.c \ + resource.c \ stream.c \ token.c \ tts.c diff --git a/dlls/sapi/main.c b/dlls/sapi/main.c index cbe097f22ad..4408e1e693f 100644 --- a/dlls/sapi/main.c +++ b/dlls/sapi/main.c @@ -107,6 +107,7 @@ static const struct IClassFactoryVtbl class_factory_vtbl =
static struct class_factory data_key_cf = { { &class_factory_vtbl }, data_key_create }; static struct class_factory file_stream_cf = { { &class_factory_vtbl }, file_stream_create }; +static struct class_factory resource_mgr_cf = { { &class_factory_vtbl }, resource_manager_create }; static struct class_factory speech_stream_cf = { { &class_factory_vtbl }, speech_stream_create }; static struct class_factory speech_voice_cf = { { &class_factory_vtbl }, speech_voice_create }; static struct class_factory token_category_cf = { { &class_factory_vtbl }, token_category_create }; @@ -132,6 +133,8 @@ HRESULT WINAPI DllGetClassObject( REFCLSID clsid, REFIID iid, void **obj ) cf = &token_enum_cf.IClassFactory_iface; else if (IsEqualCLSID( clsid, &CLSID_SpObjectToken )) cf = &token_cf.IClassFactory_iface; + else if (IsEqualCLSID( clsid, &CLSID_SpResourceManager )) + cf = &resource_mgr_cf.IClassFactory_iface; else if (IsEqualCLSID( clsid, &CLSID_SpStream )) cf = &speech_stream_cf.IClassFactory_iface; else if (IsEqualCLSID( clsid, &CLSID_SpVoice )) diff --git a/dlls/sapi/resource.c b/dlls/sapi/resource.c new file mode 100644 index 00000000000..85d4430f8ad --- /dev/null +++ b/dlls/sapi/resource.c @@ -0,0 +1,140 @@ +/* + * Speech API (SAPI) resource manager implementation. + * + * Copyright 2020 Gijs Vermeulen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "objbase.h" + +#include "sapiddk.h" + +#include "wine/debug.h" + +#include "sapi_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(sapi); + +struct resource_manager +{ + ISpResourceManager ISpResourceManager_iface; + LONG ref; +}; + +static inline struct resource_manager *impl_from_ISpResourceManager(ISpResourceManager *iface) +{ + return CONTAINING_RECORD(iface, struct resource_manager, ISpResourceManager_iface); +} + +static HRESULT WINAPI resource_manager_QueryInterface(ISpResourceManager *iface, REFIID iid, void **obj) +{ + struct resource_manager *This = impl_from_ISpResourceManager(iface); + + TRACE("(%p, %s, %p).\n", iface, debugstr_guid(iid), obj); + + if (IsEqualIID(iid, &IID_IUnknown) || + IsEqualIID(iid, &IID_ISpResourceManager)) + *obj = &This->ISpResourceManager_iface; + else + { + *obj = NULL; + FIXME("interface %s not implemented.\n", debugstr_guid(iid)); + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown *)*obj); + return S_OK; +} + +static ULONG WINAPI resource_manager_AddRef(ISpResourceManager *iface) +{ + struct resource_manager *This = impl_from_ISpResourceManager(iface); + ULONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p): ref=%u.\n", iface, ref); + + return ref; +} + +static ULONG WINAPI resource_manager_Release(ISpResourceManager *iface) +{ + struct resource_manager *This = impl_from_ISpResourceManager(iface); + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p): ref=%u.\n", iface, ref); + + if (!ref) + { + heap_free(This); + } + + return ref; +} + +static HRESULT WINAPI resource_manager_QueryService(ISpResourceManager *iface, REFGUID guid, REFIID iid, + void **obj) +{ + FIXME("(%p, %s, %s, %p): stub.\n", iface, debugstr_guid(guid), debugstr_guid(iid), obj); + + return E_NOTIMPL; +} + +static HRESULT WINAPI resource_manager_SetObject(ISpResourceManager *iface, REFGUID guid, IUnknown *obj) +{ + FIXME("(%p, %s, %p): stub.\n", iface, debugstr_guid(guid), obj); + + return E_NOTIMPL; +} + +static HRESULT WINAPI resource_manager_GetObject(ISpResourceManager *iface, REFGUID guid, REFCLSID clsid, REFIID iid, + BOOL release, void **obj) +{ + FIXME("(%p, %s, %s, %s, %d, %p): stub.\n", iface, debugstr_guid(guid), debugstr_guid(clsid), debugstr_guid(iid), + release, obj); + + return E_NOTIMPL; +} + +const static ISpResourceManagerVtbl resource_manager_vtbl = +{ + resource_manager_QueryInterface, + resource_manager_AddRef, + resource_manager_Release, + resource_manager_QueryService, + resource_manager_SetObject, + resource_manager_GetObject +}; + +HRESULT resource_manager_create(IUnknown *outer, REFIID iid, void **obj) +{ + struct resource_manager *This = heap_alloc(sizeof(*This)); + HRESULT hr; + + if (!This) return E_OUTOFMEMORY; + This->ISpResourceManager_iface.lpVtbl = &resource_manager_vtbl; + This->ref = 1; + + hr = ISpResourceManager_QueryInterface(&This->ISpResourceManager_iface, iid, obj); + + ISpResourceManager_Release(&This->ISpResourceManager_iface); + return hr; +} diff --git a/dlls/sapi/sapi_classes.idl b/dlls/sapi/sapi_classes.idl index bb580dde18e..b331eb2e4a0 100644 --- a/dlls/sapi/sapi_classes.idl +++ b/dlls/sapi/sapi_classes.idl @@ -78,6 +78,20 @@ coclass SpStream interface ISpStream; }
+[ + uuid(96749373-3391-11d2-9ee3-00c04f797396), + helpstring("Resource Manager"), + progid("SAPI.SpResourceManager.1"), + vi_progid("SAPI.SpResourceManager"), + threading(both), + restricted, + hidden +] +coclass SpResourceManager +{ + [default] interface ISpResourceManager; +} + [ uuid(96749377-3391-11d2-9ee3-00c04f797396), helpstring("Speech Voice"), diff --git a/dlls/sapi/sapi_private.h b/dlls/sapi/sapi_private.h index 509bcb0715b..8a375cdb6c2 100644 --- a/dlls/sapi/sapi_private.h +++ b/dlls/sapi/sapi_private.h @@ -22,6 +22,7 @@
HRESULT data_key_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN; HRESULT file_stream_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN; +HRESULT resource_manager_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN; HRESULT speech_stream_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN; HRESULT speech_voice_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN; HRESULT token_category_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN; diff --git a/dlls/sapi/tests/Makefile.in b/dlls/sapi/tests/Makefile.in index f1de67418dc..75c70d072d8 100644 --- a/dlls/sapi/tests/Makefile.in +++ b/dlls/sapi/tests/Makefile.in @@ -3,6 +3,7 @@ IMPORTS = ole32 user32 advapi32
C_SRCS = \ automation.c \ + resource.c \ stream.c \ token.c \ tts.c diff --git a/dlls/sapi/tests/resource.c b/dlls/sapi/tests/resource.c new file mode 100644 index 00000000000..92a84289202 --- /dev/null +++ b/dlls/sapi/tests/resource.c @@ -0,0 +1,78 @@ +/* + * Speech API (SAPI) resource manager tests. + * + * Copyright 2020 Gijs Vermeulen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define COBJMACROS + +#include "sapiddk.h" +#include "sperror.h" + +#include "wine/test.h" + +#define EXPECT_REF(obj,ref,broken_ref) _expect_ref((IUnknown*)obj, ref, broken_ref, __LINE__) +static void _expect_ref(IUnknown *obj, ULONG ref, ULONG broken_ref, int line) +{ + ULONG rc; + IUnknown_AddRef(obj); + rc = IUnknown_Release(obj); + ok_(__FILE__,line)(rc == ref || broken(rc == broken_ref), "Unexpected refcount %d, expected %d.\n", rc, ref); +} + +static void test_interfaces(void) +{ + ISpResourceManager *resource_manager, *resource_manager2; + IDispatch *dispatch; + IUnknown *unk; + HRESULT hr; + + hr = CoCreateInstance(&CLSID_SpResourceManager, NULL, CLSCTX_INPROC_SERVER, + &IID_ISpResourceManager, (void **)&resource_manager); + ok(hr == S_OK, "Failed to create ISpResourceManager interface: %#x.\n", hr); + todo_wine EXPECT_REF(resource_manager, 2, 1); + + hr = CoCreateInstance(&CLSID_SpResourceManager, NULL, CLSCTX_INPROC_SERVER, + &IID_ISpResourceManager, (void **)&resource_manager2); + ok(hr == S_OK, "Failed to create ISpResourceManager interface: %#x.\n", hr); + todo_wine ok(resource_manager2 == resource_manager, "Expected managers to match.\n"); + todo_wine EXPECT_REF(resource_manager2, 3, 2); + todo_wine EXPECT_REF(resource_manager, 3, 2); + if (resource_manager2 == resource_manager) ISpResourceManager_Release(resource_manager2); + + hr = CoCreateInstance(&CLSID_SpResourceManager, NULL, CLSCTX_INPROC_SERVER, + &IID_IUnknown, (void **)&unk); + ok(hr == S_OK, "Failed to create IUnknown interface: %#x.\n", hr); + todo_wine ok(unk == (IUnknown *)resource_manager, "Expected unk to match existing manager.\n"); + todo_wine EXPECT_REF(unk, 3, 2); + todo_wine EXPECT_REF(resource_manager, 3, 2); + if (unk == (IUnknown *)resource_manager) IUnknown_Release(unk); + + hr = CoCreateInstance(&CLSID_SpResourceManager, NULL, CLSCTX_INPROC_SERVER, + &IID_IDispatch, (void **)&dispatch); + ok(hr == E_NOINTERFACE, "Succeeded to create IDispatch interface: %#x.\n", hr); + ok(!dispatch, "Expected NULL dispatch, got %p.", dispatch); + + ISpResourceManager_Release(resource_manager); +} + +START_TEST(resource) +{ + CoInitialize(NULL); + test_interfaces(); + CoUninitialize(); +} diff --git a/include/sapi.idl b/include/sapi.idl index e71d009428c..5120e379450 100644 --- a/include/sapi.idl +++ b/include/sapi.idl @@ -651,6 +651,24 @@ interface IEnumSpObjectTokens : IUnknown HRESULT GetCount([out] ULONG *pCount); }
+[ + object, + uuid(93384e18-5014-43d5-adbb-a78e055926bd), + helpstring("ISpResourceManager"), + pointer_default(unique), + restricted +] +interface ISpResourceManager : IServiceProvider +{ + HRESULT SetObject([in] REFGUID guidServiceId, + [in] IUnknown *pUnkObject); + HRESULT GetObject([in] REFGUID guidServiceId, + [in] REFCLSID ObjectCLSID, + [in] REFIID ObjectIID, + [in] BOOL fReleaseWhenLastExternalRefReleased, + [out, iid_is(ObjectIID)] void** ppObject); +} + [ object, uuid(1a5c0354-b621-4b5a-8791-d306ed379e53), @@ -1077,6 +1095,20 @@ library SpeechLib [default] interface ISpDataKey; }
+ [ + uuid(96749373-3391-11d2-9ee3-00c04f797396), + helpstring("Resource Manager"), + progid("SAPI.SpResourceManager.1"), + vi_progid("SAPI.SpResourceManager"), + threading(both), + restricted, + hidden + ] + coclass SpResourceManager + { + [default] interface ISpResourceManager; + }; + [ uuid(3bee4890-4fe9-4a37-8c1e-5e7e12791c1f) ]
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=81798
Your paranoid android.
=== debiant (32 bit report) ===
sapi: resource.c:46: Test failed: Failed to create ISpResourceManager interface: 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x0040124f). stream.c:46: Test failed: Failed to create ISpStream interface: 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x0040175c).
Report validation errors: sapi:resource crashed (c0000005) sapi:stream crashed (c0000005)
=== debiant (32 bit French report) ===
sapi: resource.c:46: Test failed: Failed to create ISpResourceManager interface: 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x0040124f).
Report validation errors: sapi:resource crashed (c0000005)
=== debiant (32 bit Japanese:Japan report) ===
sapi: resource.c:46: Test failed: Failed to create ISpResourceManager interface: 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x0040124f).
Report validation errors: sapi:resource crashed (c0000005)
=== debiant (32 bit Chinese:China report) ===
sapi: resource.c:46: Test failed: Failed to create ISpResourceManager interface: 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x0040124f). stream.c:46: Test failed: Failed to create ISpStream interface: 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x0040175c).
Report validation errors: sapi:resource crashed (c0000005) sapi:stream crashed (c0000005)
=== debiant (32 bit WoW report) ===
sapi: resource.c:46: Test failed: Failed to create ISpResourceManager interface: 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x0040124f). stream.c:46: Test failed: Failed to create ISpStream interface: 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x0040175c).
Report validation errors: sapi:resource crashed (c0000005) sapi:stream crashed (c0000005)
=== debiant (64 bit WoW report) ===
sapi: resource.c:46: Test failed: Failed to create ISpResourceManager interface: 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x0040124f). stream.c:46: Test failed: Failed to create ISpStream interface: 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x0040175c).
Report validation errors: sapi:resource crashed (c0000005) sapi:stream crashed (c0000005)
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=81797
Your paranoid android.
=== debiant (32 bit report) ===
sapi: stream.c:46: Test failed: Failed to create ISpStream interface: 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x0040124c).
Report validation errors: sapi:stream crashed (c0000005)
=== debiant (32 bit French report) ===
sapi: stream.c:46: Test failed: Failed to create ISpStream interface: 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x0040124c).
Report validation errors: sapi:stream crashed (c0000005)
=== debiant (32 bit Japanese:Japan report) ===
sapi: stream.c:46: Test failed: Failed to create ISpStream interface: 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x0040124c).
Report validation errors: sapi:stream crashed (c0000005)
=== debiant (32 bit Chinese:China report) ===
sapi: stream.c:46: Test failed: Failed to create ISpStream interface: 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x0040124c).
Report validation errors: sapi:stream crashed (c0000005)
=== debiant (32 bit WoW report) ===
sapi: stream.c:46: Test failed: Failed to create ISpStream interface: 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x0040124c).
Report validation errors: sapi:stream crashed (c0000005)
=== debiant (64 bit WoW report) ===
sapi: stream.c:46: Test failed: Failed to create ISpStream interface: 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x0040124c).
Report validation errors: sapi:stream crashed (c0000005)