2 * MSTTSEngine SAPI engine implementation.
4 * Copyright 2023 Shaun Ren for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(msttsengine
);
38 ISpTTSEngine ISpTTSEngine_iface
;
39 ISpObjectWithToken ISpObjectWithToken_iface
;
42 ISpObjectToken
*token
;
45 static inline struct ttsengine
*impl_from_ISpTTSEngine(ISpTTSEngine
*iface
)
47 return CONTAINING_RECORD(iface
, struct ttsengine
, ISpTTSEngine_iface
);
50 static inline struct ttsengine
*impl_from_ISpObjectWithToken(ISpObjectWithToken
*iface
)
52 return CONTAINING_RECORD(iface
, struct ttsengine
, ISpObjectWithToken_iface
);
55 static HRESULT WINAPI
ttsengine_QueryInterface(ISpTTSEngine
*iface
, REFIID iid
, void **obj
)
57 struct ttsengine
*This
= impl_from_ISpTTSEngine(iface
);
59 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(iid
), obj
);
61 if (IsEqualIID(iid
, &IID_IUnknown
) ||
62 IsEqualIID(iid
, &IID_ISpTTSEngine
))
64 *obj
= &This
->ISpTTSEngine_iface
;
66 else if (IsEqualIID(iid
, &IID_ISpObjectWithToken
))
67 *obj
= &This
->ISpObjectWithToken_iface
;
74 IUnknown_AddRef((IUnknown
*)*obj
);
78 static ULONG WINAPI
ttsengine_AddRef(ISpTTSEngine
*iface
)
80 struct ttsengine
*This
= impl_from_ISpTTSEngine(iface
);
81 ULONG ref
= InterlockedIncrement(&This
->ref
);
83 TRACE("(%p) ref=%lu\n", This
, ref
);
88 static ULONG WINAPI
ttsengine_Release(ISpTTSEngine
*iface
)
90 struct ttsengine
*This
= impl_from_ISpTTSEngine(iface
);
91 ULONG ref
= InterlockedDecrement(&This
->ref
);
93 TRACE("(%p) ref=%lu\n", This
, ref
);
97 if (This
->token
) ISpObjectToken_Release(This
->token
);
104 static HRESULT WINAPI
ttsengine_Speak(ISpTTSEngine
*iface
, DWORD flags
, REFGUID fmtid
,
105 const WAVEFORMATEX
*wfx
, const SPVTEXTFRAG
*frag_list
,
106 ISpTTSEngineSite
*site
)
108 FIXME("(%p, %#lx, %s, %p, %p, %p): stub.\n", iface
, flags
, debugstr_guid(fmtid
), wfx
, frag_list
, site
);
113 static HRESULT WINAPI
ttsengine_GetOutputFormat(ISpTTSEngine
*iface
, const GUID
*fmtid
,
114 const WAVEFORMATEX
*wfx
, GUID
*out_fmtid
,
115 WAVEFORMATEX
**out_wfx
)
117 FIXME("(%p, %s, %p, %p, %p): stub.\n", iface
, debugstr_guid(fmtid
), wfx
, out_fmtid
, out_wfx
);
122 static ISpTTSEngineVtbl ttsengine_vtbl
=
124 ttsengine_QueryInterface
,
128 ttsengine_GetOutputFormat
,
131 static HRESULT WINAPI
objwithtoken_QueryInterface(ISpObjectWithToken
*iface
, REFIID iid
, void **obj
)
133 struct ttsengine
*This
= impl_from_ISpObjectWithToken(iface
);
135 TRACE("(%p, %s, %p).\n", iface
, debugstr_guid(iid
), obj
);
137 return ISpTTSEngine_QueryInterface(&This
->ISpTTSEngine_iface
, iid
, obj
);
140 static ULONG WINAPI
objwithtoken_AddRef(ISpObjectWithToken
*iface
)
142 struct ttsengine
*This
= impl_from_ISpObjectWithToken(iface
);
144 TRACE("(%p).\n", iface
);
146 return ISpTTSEngine_AddRef(&This
->ISpTTSEngine_iface
);
149 static ULONG WINAPI
objwithtoken_Release(ISpObjectWithToken
*iface
)
151 struct ttsengine
*This
= impl_from_ISpObjectWithToken(iface
);
153 TRACE("(%p).\n", iface
);
155 return ISpTTSEngine_Release(&This
->ISpTTSEngine_iface
);
158 static HRESULT WINAPI
objwithtoken_SetObjectToken(ISpObjectWithToken
*iface
, ISpObjectToken
*token
)
160 struct ttsengine
*This
= impl_from_ISpObjectWithToken(iface
);
162 FIXME("(%p, %p): semi-stub.\n", iface
, token
);
167 return SPERR_ALREADY_INITIALIZED
;
169 ISpObjectToken_AddRef(token
);
174 static HRESULT WINAPI
objwithtoken_GetObjectToken(ISpObjectWithToken
*iface
, ISpObjectToken
**token
)
176 struct ttsengine
*This
= impl_from_ISpObjectWithToken(iface
);
178 TRACE("(%p, %p).\n", iface
, token
);
183 *token
= This
->token
;
186 ISpObjectToken_AddRef(*token
);
193 static const ISpObjectWithTokenVtbl objwithtoken_vtbl
=
195 objwithtoken_QueryInterface
,
197 objwithtoken_Release
,
198 objwithtoken_SetObjectToken
,
199 objwithtoken_GetObjectToken
202 HRESULT
ttsengine_create(REFIID iid
, void **obj
)
204 struct ttsengine
*This
;
207 if (!(This
= malloc(sizeof(*This
))))
208 return E_OUTOFMEMORY
;
210 This
->ISpTTSEngine_iface
.lpVtbl
= &ttsengine_vtbl
;
211 This
->ISpObjectWithToken_iface
.lpVtbl
= &objwithtoken_vtbl
;
216 hr
= ISpTTSEngine_QueryInterface(&This
->ISpTTSEngine_iface
, iid
, obj
);
217 ISpTTSEngine_Release(&This
->ISpTTSEngine_iface
);