Since fe415420f3 the palette set in the local
format is not set on the output region format.
The palette of the region is created in subpicture_region_New() and the
same pointer is used between the region format and the picture format.
The input region is a text region, it should not have a palette. We would
overwrite the input palette with out own values!
subpicture_region_New() takes care of creating a palette if the format
doesn't have one.
Move the RenderTextMTA function up to remove the forward declaration.
The function is not 100% identical because an early return has been
added on the check for lastString.
Move the Speech synthesis API calls into a dedicated MTA COM thread so
that it's always guaranteed that those objects live in such thread.
We use a producer-consumer fifo of one slot to prevent storing the text
regions inside the COM thread, and in particular prevent duplicating
them, through we currently keep duplicating the last text rendered for
simplicity.
The setup feels weird, given that we give a single instruction to a
dedicated thread and then wait for that thread to process it. But
everything boils down to thread COM model being global to a thread and
not local to a scope, which means that we must control in which thread
the allocated COM objects will be used and released (ie. the same as
the one creating them).
We use a std::unique_ptr<> to handle the lifecycle of the sys pointer
with the error cases at the same time, since it will default to using
`delete` and will correctly release what's being new()-ed.
This pattern effectively replace the vlc_obj_malloc/free() primitive in
C++ code.
Using a less generic name allows referencing that name in a debugguer or
code completion tool, and prevent potential ODR when linkage is not done
correctly (eg. before when no namespace{} was present).
Separating the content of SelectVoice in a different function will allow
to easily make use of early return and greatly simplify the final code.
It also separates what is really the setup for Create() and potentially
dynamic features like voice selection.
Co-locate the error handling with the call generating the error,
allowing to simplify an indentation level from the success path and
improve readibility of the failible function call.
We can also remove the goto, which is not a good idea in C++ because of
RAII mechanisms.