wasapi: fix reinit of audioclient in prepare()

When the sink goes from PLAYING to READY and then back to PLAYING,
the initialization of the audioclient in prepare() fails with the
error AUDCLNT_E_ALREADY_INITIALIZED. As a result, the playback
stops.

To fix this, we need to drop the AudioClient in unprepare() and
grab a new one in prepare() to be able to initialize it again
with the new buffer spec.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2096>
This commit is contained in:
Jakub Janků 2021-03-18 10:55:58 +01:00 committed by Jakub Janků
parent 766a126380
commit 211f968981

View file

@ -487,6 +487,13 @@ gst_wasapi_sink_prepare (GstAudioSink * asink, GstAudioRingBufferSpec * spec)
CoInitializeEx (NULL, COINIT_MULTITHREADED); CoInitializeEx (NULL, COINIT_MULTITHREADED);
if (!self->client) {
GST_DEBUG_OBJECT (self, "no IAudioClient, creating a new one");
if (!gst_wasapi_util_get_audio_client (GST_ELEMENT (self),
self->device, &self->client))
goto beach;
}
if (gst_wasapi_sink_can_audioclient3 (self)) { if (gst_wasapi_sink_can_audioclient3 (self)) {
if (!gst_wasapi_util_initialize_audioclient3 (GST_ELEMENT (self), spec, if (!gst_wasapi_util_initialize_audioclient3 (GST_ELEMENT (self), spec,
(IAudioClient3 *) self->client, self->mix_format, self->low_latency, (IAudioClient3 *) self->client, self->mix_format, self->low_latency,
@ -592,7 +599,8 @@ gst_wasapi_sink_unprepare (GstAudioSink * asink)
GstWasapiSink *self = GST_WASAPI_SINK (asink); GstWasapiSink *self = GST_WASAPI_SINK (asink);
if (self->client != NULL) { if (self->client != NULL) {
IAudioClient_Stop (self->client); IUnknown_Release (self->client);
self->client = NULL;
} }
if (self->render_client != NULL) { if (self->render_client != NULL) {