wasapi: Call CoIn/Uninitialize() around prepare()

Seems to be required for exclusive mode and also for all
initialization on Windows 7

https://bugzilla.gnome.org/show_bug.cgi?id=795274
This commit is contained in:
Nirbheek Chauhan 2018-04-16 19:35:07 +05:30
parent b476893560
commit ff17a404b3
3 changed files with 9 additions and 11 deletions

View file

@ -474,6 +474,8 @@ gst_wasapi_sink_prepare (GstAudioSink * asink, GstAudioRingBufferSpec * spec)
guint bpf, rate, devicep_frames;
HRESULT hr;
CoInitialize (NULL);
if (gst_wasapi_sink_can_audioclient3 (self)) {
if (!gst_wasapi_util_initialize_audioclient3 (GST_ELEMENT (self), spec,
(IAudioClient3 *) self->client, self->mix_format, self->low_latency,
@ -577,9 +579,7 @@ gst_wasapi_sink_unprepare (GstAudioSink * asink)
{
GstWasapiSink *self = GST_WASAPI_SINK (asink);
if (self->sharemode == AUDCLNT_SHAREMODE_EXCLUSIVE &&
!gst_wasapi_sink_can_audioclient3 (self))
CoUninitialize ();
CoUninitialize ();
if (self->thread_priority_handle != NULL) {
gst_wasapi_util_revert_thread_characteristics
@ -596,6 +596,8 @@ gst_wasapi_sink_unprepare (GstAudioSink * asink)
self->render_client = NULL;
}
CoUninitialize ();
return TRUE;
}

View file

@ -436,6 +436,8 @@ gst_wasapi_src_prepare (GstAudioSrc * asrc, GstAudioRingBufferSpec * spec)
guint bpf, rate, devicep_frames, buffer_frames;
HRESULT hr;
CoInitialize (NULL);
if (gst_wasapi_src_can_audioclient3 (self)) {
if (!gst_wasapi_util_initialize_audioclient3 (GST_ELEMENT (self), spec,
(IAudioClient3 *) self->client, self->mix_format, self->low_latency,
@ -517,10 +519,6 @@ gst_wasapi_src_unprepare (GstAudioSrc * asrc)
{
GstWasapiSrc *self = GST_WASAPI_SRC (asrc);
if (self->sharemode == AUDCLNT_SHAREMODE_EXCLUSIVE &&
!gst_wasapi_src_can_audioclient3 (self))
CoUninitialize ();
if (self->thread_priority_handle != NULL) {
gst_wasapi_util_revert_thread_characteristics
(self->thread_priority_handle);
@ -543,6 +541,8 @@ gst_wasapi_src_unprepare (GstAudioSrc * asrc)
self->client_clock_freq = 0;
CoUninitialize ();
return TRUE;
}

View file

@ -870,10 +870,6 @@ gst_wasapi_util_initialize_audioclient (GstElement * self,
min_period, &device_period, &device_buffer_duration);
}
/* For some reason, we need to call this a second time for exclusive mode */
if (sharemode == AUDCLNT_SHAREMODE_EXCLUSIVE)
CoInitialize (NULL);
stream_flags = AUDCLNT_STREAMFLAGS_EVENTCALLBACK;
if (loopback)
stream_flags |= AUDCLNT_STREAMFLAGS_LOOPBACK;