msvcrt: Use the remquo()/remquof() implementation from the bundled musl library.
[wine.git] / dlls / windows.media.speech / synthesizer.c
blob39d14b84ab78590019c31c354ee303d4b681407d
1 /* WinRT Windows.Media.Speech implementation
3 * Copyright 2021 RĂ©mi Bernon for CodeWeavers
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "private.h"
22 #include "wine/debug.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(speech);
28 * IVectorView_VoiceInformation
32 struct voice_information_vector
34 IVectorView_VoiceInformation IVectorView_VoiceInformation_iface;
35 LONG ref;
38 static inline struct voice_information_vector *impl_from_IVectorView_VoiceInformation( IVectorView_VoiceInformation *iface )
40 return CONTAINING_RECORD(iface, struct voice_information_vector, IVectorView_VoiceInformation_iface);
43 static HRESULT WINAPI vector_view_voice_information_QueryInterface( IVectorView_VoiceInformation *iface, REFIID iid, void **out )
45 struct voice_information_vector *impl = impl_from_IVectorView_VoiceInformation(iface);
47 TRACE("iface %p, iid %s, out %p stub!\n", iface, debugstr_guid(iid), out);
49 if (IsEqualGUID(iid, &IID_IUnknown) ||
50 IsEqualGUID(iid, &IID_IInspectable) ||
51 IsEqualGUID(iid, &IID_IVectorView_VoiceInformation))
53 IInspectable_AddRef((*out = &impl->IVectorView_VoiceInformation_iface));
54 return S_OK;
57 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
58 *out = NULL;
59 return E_NOINTERFACE;
62 static ULONG WINAPI vector_view_voice_information_AddRef( IVectorView_VoiceInformation *iface )
64 struct voice_information_vector *impl = impl_from_IVectorView_VoiceInformation(iface);
65 ULONG ref = InterlockedIncrement(&impl->ref);
66 TRACE("iface %p, ref %lu.\n", iface, ref);
67 return ref;
70 static ULONG WINAPI vector_view_voice_information_Release( IVectorView_VoiceInformation *iface )
72 struct voice_information_vector *impl = impl_from_IVectorView_VoiceInformation(iface);
73 ULONG ref = InterlockedDecrement(&impl->ref);
74 TRACE("iface %p, ref %lu.\n", iface, ref);
75 return ref;
78 static HRESULT WINAPI vector_view_voice_information_GetIids( IVectorView_VoiceInformation *iface, ULONG *iid_count, IID **iids )
80 FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids);
81 return E_NOTIMPL;
84 static HRESULT WINAPI vector_view_voice_information_GetRuntimeClassName( IVectorView_VoiceInformation *iface, HSTRING *class_name )
86 FIXME("iface %p, class_name %p stub!\n", iface, class_name);
87 return E_NOTIMPL;
90 static HRESULT WINAPI vector_view_voice_information_GetTrustLevel( IVectorView_VoiceInformation *iface, TrustLevel *trust_level )
92 FIXME("iface %p, trust_level %p stub!\n", iface, trust_level);
93 return E_NOTIMPL;
96 static HRESULT WINAPI vector_view_voice_information_GetAt( IVectorView_VoiceInformation *iface, UINT32 index, IVoiceInformation **value )
98 FIXME("iface %p, index %#x, value %p stub!\n", iface, index, value);
99 *value = NULL;
100 return E_BOUNDS;
103 static HRESULT WINAPI vector_view_voice_information_get_Size( IVectorView_VoiceInformation *iface, UINT32 *value )
105 FIXME("iface %p, value %p stub!\n", iface, value);
106 *value = 0;
107 return S_OK;
110 static HRESULT WINAPI vector_view_voice_information_IndexOf( IVectorView_VoiceInformation *iface,
111 IVoiceInformation *element, UINT32 *index, BOOLEAN *found )
113 FIXME("iface %p, element %p, index %p, found %p stub!\n", iface, element, index, found);
114 *index = 0;
115 *found = FALSE;
116 return S_OK;
119 static HRESULT WINAPI vector_view_voice_information_GetMany( IVectorView_VoiceInformation *iface, UINT32 start_index,
120 UINT32 items_size, IVoiceInformation **items, UINT *value )
122 FIXME("iface %p, start_index %#x, items %p, value %p stub!\n", iface, start_index, items, value);
123 *value = 0;
124 return S_OK;
127 static const struct IVectorView_VoiceInformationVtbl vector_view_voice_information_vtbl =
129 vector_view_voice_information_QueryInterface,
130 vector_view_voice_information_AddRef,
131 vector_view_voice_information_Release,
132 /* IInspectable methods */
133 vector_view_voice_information_GetIids,
134 vector_view_voice_information_GetRuntimeClassName,
135 vector_view_voice_information_GetTrustLevel,
136 /* IVectorView<VoiceInformation> methods */
137 vector_view_voice_information_GetAt,
138 vector_view_voice_information_get_Size,
139 vector_view_voice_information_IndexOf,
140 vector_view_voice_information_GetMany,
143 static struct voice_information_vector all_voices =
145 {&vector_view_voice_information_vtbl},
151 * ISpeechSynthesisStream
155 struct synthesis_stream
157 ISpeechSynthesisStream ISpeechSynthesisStream_iface;
158 LONG ref;
160 IVector_IMediaMarker *markers;
163 static inline struct synthesis_stream *impl_from_ISpeechSynthesisStream( ISpeechSynthesisStream *iface )
165 return CONTAINING_RECORD(iface, struct synthesis_stream, ISpeechSynthesisStream_iface);
168 HRESULT WINAPI synthesis_stream_QueryInterface( ISpeechSynthesisStream *iface, REFIID iid, void **out )
170 struct synthesis_stream *impl = impl_from_ISpeechSynthesisStream(iface);
172 TRACE("iface %p, iid %s, out %p stub!\n", iface, debugstr_guid(iid), out);
174 if (IsEqualGUID(iid, &IID_IUnknown) ||
175 IsEqualGUID(iid, &IID_IInspectable) ||
176 IsEqualGUID(iid, &IID_IAgileObject) ||
177 IsEqualGUID(iid, &IID_ISpeechSynthesisStream))
179 IInspectable_AddRef((*out = &impl->ISpeechSynthesisStream_iface));
180 return S_OK;
183 FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
184 *out = NULL;
185 return E_NOINTERFACE;
188 ULONG WINAPI synthesis_stream_AddRef( ISpeechSynthesisStream *iface )
190 struct synthesis_stream *impl = impl_from_ISpeechSynthesisStream(iface);
191 ULONG ref = InterlockedIncrement(&impl->ref);
192 TRACE("iface %p, ref %lu.\n", iface, ref);
193 return ref;
196 ULONG WINAPI synthesis_stream_Release( ISpeechSynthesisStream *iface )
198 struct synthesis_stream *impl = impl_from_ISpeechSynthesisStream(iface);
199 ULONG ref = InterlockedDecrement(&impl->ref);
201 TRACE("iface %p, ref %lu.\n", iface, ref);
203 if (!ref)
204 free(impl);
206 return ref;
209 HRESULT WINAPI synthesis_stream_GetIids( ISpeechSynthesisStream *iface, ULONG *iid_count, IID **iids )
211 FIXME("iface %p, iid_count %p, iids %p stub.\n", iface, iid_count, iids);
212 return E_NOTIMPL;
215 HRESULT WINAPI synthesis_stream_GetRuntimeClassName( ISpeechSynthesisStream *iface, HSTRING *class_name )
217 FIXME("iface %p, class_name %p stub.\n", iface, class_name);
218 return E_NOTIMPL;
221 HRESULT WINAPI synthesis_stream_GetTrustLevel( ISpeechSynthesisStream *iface, TrustLevel *trust_level )
223 FIXME("iface %p, trust_level %p stub.\n", iface, trust_level);
224 return E_NOTIMPL;
227 HRESULT WINAPI synthesis_stream_get_Markers( ISpeechSynthesisStream *iface, IVectorView_IMediaMarker **value )
229 struct synthesis_stream *impl = impl_from_ISpeechSynthesisStream(iface);
230 FIXME("iface %p, value %p stub!\n", iface, value);
231 return IVector_IMediaMarker_GetView(impl->markers, value);
234 static const struct ISpeechSynthesisStreamVtbl synthesis_stream_vtbl =
236 /* IUnknown methods */
237 synthesis_stream_QueryInterface,
238 synthesis_stream_AddRef,
239 synthesis_stream_Release,
240 /* IInspectable methods */
241 synthesis_stream_GetIids,
242 synthesis_stream_GetRuntimeClassName,
243 synthesis_stream_GetTrustLevel,
244 /* ISpeechSynthesisStream methods */
245 synthesis_stream_get_Markers
249 static HRESULT synthesis_stream_create( ISpeechSynthesisStream **out )
251 struct synthesis_stream *impl;
252 struct vector_iids markers_iids =
254 .iterable = &IID_IIterable_IMediaMarker,
255 .iterator = &IID_IIterator_IMediaMarker,
256 .vector = &IID_IVector_IMediaMarker,
257 .view = &IID_IVectorView_IMediaMarker,
259 HRESULT hr;
261 TRACE("out %p.\n", out);
263 if (!(impl = calloc(1, sizeof(*impl))))
265 *out = NULL;
266 return E_OUTOFMEMORY;
269 impl->ISpeechSynthesisStream_iface.lpVtbl = &synthesis_stream_vtbl;
270 impl->ref = 1;
271 if (FAILED(hr = vector_inspectable_create(&markers_iids, (IVector_IInspectable**)&impl->markers)))
272 goto error;
274 TRACE("created ISpeechSynthesisStream %p.\n", impl);
275 *out = &impl->ISpeechSynthesisStream_iface;
276 return S_OK;
278 error:
279 free(impl);
280 return hr;
285 * SpeechSynthesizer runtimeclass
289 struct synthesizer
291 ISpeechSynthesizer ISpeechSynthesizer_iface;
292 ISpeechSynthesizer2 ISpeechSynthesizer2_iface;
293 IClosable IClosable_iface;
294 LONG ref;
299 * ISpeechSynthesizer for SpeechSynthesizer runtimeclass
303 static inline struct synthesizer *impl_from_ISpeechSynthesizer( ISpeechSynthesizer *iface )
305 return CONTAINING_RECORD(iface, struct synthesizer, ISpeechSynthesizer_iface);
308 static HRESULT WINAPI synthesizer_QueryInterface( ISpeechSynthesizer *iface, REFIID iid, void **out )
310 struct synthesizer *impl = impl_from_ISpeechSynthesizer(iface);
312 TRACE("iface %p, iid %s, out %p stub!\n", iface, debugstr_guid(iid), out);
314 if (IsEqualGUID(iid, &IID_IUnknown) ||
315 IsEqualGUID(iid, &IID_IInspectable) ||
316 IsEqualGUID(iid, &IID_ISpeechSynthesizer))
318 IInspectable_AddRef((*out = &impl->ISpeechSynthesizer_iface));
319 return S_OK;
322 if (IsEqualGUID(iid, &IID_ISpeechSynthesizer2))
324 IInspectable_AddRef((*out = &impl->ISpeechSynthesizer2_iface));
325 return S_OK;
328 if (IsEqualGUID(iid, &IID_IClosable))
330 IInspectable_AddRef((*out = &impl->IClosable_iface));
331 return S_OK;
334 FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
335 *out = NULL;
336 return E_NOINTERFACE;
339 static ULONG WINAPI synthesizer_AddRef( ISpeechSynthesizer *iface )
341 struct synthesizer *impl = impl_from_ISpeechSynthesizer(iface);
342 ULONG ref = InterlockedIncrement(&impl->ref);
343 TRACE("iface %p, ref %lu.\n", iface, ref);
344 return ref;
347 static ULONG WINAPI synthesizer_Release( ISpeechSynthesizer *iface )
349 struct synthesizer *impl = impl_from_ISpeechSynthesizer(iface);
350 ULONG ref = InterlockedDecrement(&impl->ref);
352 TRACE("iface %p, ref %lu.\n", iface, ref);
354 if (!ref)
355 free(impl);
357 return ref;
360 static HRESULT WINAPI synthesizer_GetIids( ISpeechSynthesizer *iface, ULONG *iid_count, IID **iids )
362 FIXME("iface %p, iid_count %p, iids %p stub.\n", iface, iid_count, iids);
363 return E_NOTIMPL;
366 static HRESULT WINAPI synthesizer_GetRuntimeClassName( ISpeechSynthesizer *iface, HSTRING *class_name )
368 FIXME("iface %p, class_name %p stub.\n", iface, class_name);
369 return E_NOTIMPL;
372 static HRESULT WINAPI synthesizer_GetTrustLevel( ISpeechSynthesizer *iface, TrustLevel *trust_level )
374 FIXME("iface %p, trust_level %p stub.\n", iface, trust_level);
375 return E_NOTIMPL;
378 static HRESULT synthesizer_synthesize_text_to_stream_async( IInspectable *invoker, IInspectable **result )
380 return synthesis_stream_create((ISpeechSynthesisStream **)result);
383 static HRESULT WINAPI synthesizer_SynthesizeTextToStreamAsync( ISpeechSynthesizer *iface, HSTRING text,
384 IAsyncOperation_SpeechSynthesisStream **operation )
386 TRACE("iface %p, text %p, operation %p.\n", iface, text, operation);
387 return async_operation_inspectable_create(&IID_IAsyncOperation_SpeechSynthesisStream, NULL,
388 synthesizer_synthesize_text_to_stream_async, (IAsyncOperation_IInspectable **)operation);
391 static HRESULT synthesizer_synthesize_ssml_to_stream_async( IInspectable *invoker, IInspectable **result )
393 return synthesis_stream_create((ISpeechSynthesisStream **)result);
396 static HRESULT WINAPI synthesizer_SynthesizeSsmlToStreamAsync( ISpeechSynthesizer *iface, HSTRING ssml,
397 IAsyncOperation_SpeechSynthesisStream **operation )
399 TRACE("iface %p, ssml %p, operation %p.\n", iface, ssml, operation);
400 return async_operation_inspectable_create(&IID_IAsyncOperation_SpeechSynthesisStream, NULL,
401 synthesizer_synthesize_ssml_to_stream_async, (IAsyncOperation_IInspectable **)operation);
404 static HRESULT WINAPI synthesizer_put_Voice( ISpeechSynthesizer *iface, IVoiceInformation *value )
406 FIXME("iface %p, value %p stub.\n", iface, value);
407 return E_NOTIMPL;
410 static HRESULT WINAPI synthesizer_get_Voice( ISpeechSynthesizer *iface, IVoiceInformation **value )
412 FIXME("iface %p, value %p stub.\n", iface, value);
413 return E_NOTIMPL;
416 static const struct ISpeechSynthesizerVtbl synthesizer_vtbl =
418 /* IUnknown methods */
419 synthesizer_QueryInterface,
420 synthesizer_AddRef,
421 synthesizer_Release,
422 /* IInspectable methods */
423 synthesizer_GetIids,
424 synthesizer_GetRuntimeClassName,
425 synthesizer_GetTrustLevel,
426 /* ISpeechSynthesizer methods */
427 synthesizer_SynthesizeTextToStreamAsync,
428 synthesizer_SynthesizeSsmlToStreamAsync,
429 synthesizer_put_Voice,
430 synthesizer_get_Voice,
435 * ISpeechSynthesizer2 for SpeechSynthesizer runtimeclass
439 DEFINE_IINSPECTABLE(synthesizer2, ISpeechSynthesizer2, struct synthesizer, ISpeechSynthesizer_iface)
441 static HRESULT WINAPI synthesizer2_get_Options( ISpeechSynthesizer2 *iface, ISpeechSynthesizerOptions **value )
443 FIXME("iface %p, value %p stub.\n", iface, value);
444 return E_NOTIMPL;
447 static const struct ISpeechSynthesizer2Vtbl synthesizer2_vtbl =
449 /* IUnknown methods */
450 synthesizer2_QueryInterface,
451 synthesizer2_AddRef,
452 synthesizer2_Release,
453 /* IInspectable methods */
454 synthesizer2_GetIids,
455 synthesizer2_GetRuntimeClassName,
456 synthesizer2_GetTrustLevel,
457 /* ISpeechSynthesizer2 methods */
458 synthesizer2_get_Options,
463 * IClosable for SpeechSynthesizer runtimeclass
467 DEFINE_IINSPECTABLE(closable, IClosable, struct synthesizer, ISpeechSynthesizer_iface)
469 static HRESULT WINAPI closable_Close( IClosable *iface )
471 FIXME("iface %p stub.\n", iface);
472 return E_NOTIMPL;
475 static const struct IClosableVtbl closable_vtbl =
477 /* IUnknown methods */
478 closable_QueryInterface,
479 closable_AddRef,
480 closable_Release,
481 /* IInspectable methods */
482 closable_GetIids,
483 closable_GetRuntimeClassName,
484 closable_GetTrustLevel,
485 /* IClosable methods */
486 closable_Close,
491 * Static interfaces for SpeechSynthesizer runtimeclass
495 struct synthesizer_statics
497 IActivationFactory IActivationFactory_iface;
498 IInstalledVoicesStatic IInstalledVoicesStatic_iface;
499 LONG ref;
504 * IActivationFactory for SpeechSynthesizer runtimeclass
508 static inline struct synthesizer_statics *impl_from_IActivationFactory( IActivationFactory *iface )
510 return CONTAINING_RECORD(iface, struct synthesizer_statics, IActivationFactory_iface);
513 static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out )
515 struct synthesizer_statics *impl = impl_from_IActivationFactory(iface);
517 TRACE("iface %p, iid %s, out %p stub!\n", iface, debugstr_guid(iid), out);
519 if (IsEqualGUID(iid, &IID_IUnknown) ||
520 IsEqualGUID(iid, &IID_IInspectable) ||
521 IsEqualGUID(iid, &IID_IAgileObject) ||
522 IsEqualGUID(iid, &IID_IActivationFactory))
524 IInspectable_AddRef((*out = &impl->IActivationFactory_iface));
525 return S_OK;
528 if (IsEqualGUID(iid, &IID_IInstalledVoicesStatic))
530 IInspectable_AddRef((*out = &impl->IInstalledVoicesStatic_iface));
531 return S_OK;
534 FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid));
535 *out = NULL;
536 return E_NOINTERFACE;
539 static ULONG WINAPI factory_AddRef( IActivationFactory *iface )
541 struct synthesizer_statics *impl = impl_from_IActivationFactory(iface);
542 ULONG ref = InterlockedIncrement(&impl->ref);
543 TRACE("iface %p, ref %lu.\n", iface, ref);
544 return ref;
547 static ULONG WINAPI factory_Release( IActivationFactory *iface )
549 struct synthesizer_statics *impl = impl_from_IActivationFactory(iface);
550 ULONG ref = InterlockedDecrement(&impl->ref);
551 TRACE("iface %p, ref %lu.\n", iface, ref);
552 return ref;
555 static HRESULT WINAPI factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids )
557 FIXME("iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids);
558 return E_NOTIMPL;
561 static HRESULT WINAPI factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name )
563 FIXME("iface %p, class_name %p stub!\n", iface, class_name);
564 return E_NOTIMPL;
567 static HRESULT WINAPI factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level )
569 FIXME("iface %p, trust_level %p stub!\n", iface, trust_level);
570 return E_NOTIMPL;
573 static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance )
575 struct synthesizer *impl;
577 TRACE("iface %p, instance %p.\n", iface, instance);
579 if (!(impl = calloc(1, sizeof(*impl))))
581 *instance = NULL;
582 return E_OUTOFMEMORY;
585 impl->ISpeechSynthesizer_iface.lpVtbl = &synthesizer_vtbl;
586 impl->ISpeechSynthesizer2_iface.lpVtbl = &synthesizer2_vtbl;
587 impl->IClosable_iface.lpVtbl = &closable_vtbl;
588 impl->ref = 1;
590 *instance = (IInspectable *)&impl->ISpeechSynthesizer_iface;
591 return S_OK;
594 static const struct IActivationFactoryVtbl factory_vtbl =
596 factory_QueryInterface,
597 factory_AddRef,
598 factory_Release,
599 /* IInspectable methods */
600 factory_GetIids,
601 factory_GetRuntimeClassName,
602 factory_GetTrustLevel,
603 /* IActivationFactory methods */
604 factory_ActivateInstance,
609 * IInstalledVoicesStatic for SpeechSynthesizer runtimeclass
613 DEFINE_IINSPECTABLE(installed_voices_static, IInstalledVoicesStatic, struct synthesizer_statics, IActivationFactory_iface)
615 static HRESULT WINAPI installed_voices_static_get_AllVoices( IInstalledVoicesStatic *iface, IVectorView_VoiceInformation **value )
617 TRACE("iface %p, value %p.\n", iface, value);
618 *value = &all_voices.IVectorView_VoiceInformation_iface;
619 IVectorView_VoiceInformation_AddRef(*value);
620 return S_OK;
623 static HRESULT WINAPI installed_voices_static_get_DefaultVoice( IInstalledVoicesStatic *iface, IVoiceInformation **value )
625 FIXME("iface %p, value %p stub!\n", iface, value);
626 return E_NOTIMPL;
629 static const struct IInstalledVoicesStaticVtbl installed_voices_static_vtbl =
631 installed_voices_static_QueryInterface,
632 installed_voices_static_AddRef,
633 installed_voices_static_Release,
634 /* IInspectable methods */
635 installed_voices_static_GetIids,
636 installed_voices_static_GetRuntimeClassName,
637 installed_voices_static_GetTrustLevel,
638 /* IInstalledVoicesStatic methods */
639 installed_voices_static_get_AllVoices,
640 installed_voices_static_get_DefaultVoice,
643 static struct synthesizer_statics synthesizer_statics =
645 .IActivationFactory_iface = {&factory_vtbl},
646 .IInstalledVoicesStatic_iface = {&installed_voices_static_vtbl},
647 .ref = 1
650 IActivationFactory *synthesizer_factory = &synthesizer_statics.IActivationFactory_iface;