mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 04:45:36 +00:00
wasapi: Also call CoInitialize in prepare()
This commit is contained in:
parent
3f898bb27f
commit
b8c204fcc1
3 changed files with 10 additions and 14 deletions
|
@ -210,8 +210,6 @@ gst_wasapi_sink_finalize (GObject * object)
|
||||||
|
|
||||||
g_clear_pointer (&self->mix_format, CoTaskMemFree);
|
g_clear_pointer (&self->mix_format, CoTaskMemFree);
|
||||||
|
|
||||||
CoUninitialize ();
|
|
||||||
|
|
||||||
if (self->cached_caps != NULL) {
|
if (self->cached_caps != NULL) {
|
||||||
gst_caps_unref (self->cached_caps);
|
gst_caps_unref (self->cached_caps);
|
||||||
self->cached_caps = NULL;
|
self->cached_caps = NULL;
|
||||||
|
@ -221,6 +219,8 @@ gst_wasapi_sink_finalize (GObject * object)
|
||||||
g_clear_pointer (&self->device_strid, g_free);
|
g_clear_pointer (&self->device_strid, g_free);
|
||||||
self->mute = FALSE;
|
self->mute = FALSE;
|
||||||
|
|
||||||
|
CoUninitialize ();
|
||||||
|
|
||||||
G_OBJECT_CLASS (gst_wasapi_sink_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gst_wasapi_sink_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,6 +474,8 @@ gst_wasapi_sink_prepare (GstAudioSink * asink, GstAudioRingBufferSpec * spec)
|
||||||
guint bpf, rate, devicep_frames;
|
guint bpf, rate, devicep_frames;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
|
CoInitialize (NULL);
|
||||||
|
|
||||||
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,
|
||||||
|
@ -577,9 +579,7 @@ gst_wasapi_sink_unprepare (GstAudioSink * asink)
|
||||||
{
|
{
|
||||||
GstWasapiSink *self = GST_WASAPI_SINK (asink);
|
GstWasapiSink *self = GST_WASAPI_SINK (asink);
|
||||||
|
|
||||||
if (self->sharemode == AUDCLNT_SHAREMODE_EXCLUSIVE &&
|
CoUninitialize ();
|
||||||
!gst_wasapi_sink_can_audioclient3 (self))
|
|
||||||
CoUninitialize ();
|
|
||||||
|
|
||||||
if (self->thread_priority_handle != NULL) {
|
if (self->thread_priority_handle != NULL) {
|
||||||
gst_wasapi_util_revert_thread_characteristics
|
gst_wasapi_util_revert_thread_characteristics
|
||||||
|
|
|
@ -213,12 +213,12 @@ gst_wasapi_src_finalize (GObject * object)
|
||||||
|
|
||||||
g_clear_pointer (&self->mix_format, CoTaskMemFree);
|
g_clear_pointer (&self->mix_format, CoTaskMemFree);
|
||||||
|
|
||||||
CoUninitialize ();
|
|
||||||
|
|
||||||
g_clear_pointer (&self->cached_caps, gst_caps_unref);
|
g_clear_pointer (&self->cached_caps, gst_caps_unref);
|
||||||
g_clear_pointer (&self->positions, g_free);
|
g_clear_pointer (&self->positions, g_free);
|
||||||
g_clear_pointer (&self->device_strid, g_free);
|
g_clear_pointer (&self->device_strid, g_free);
|
||||||
|
|
||||||
|
CoUninitialize ();
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,6 +420,8 @@ gst_wasapi_src_prepare (GstAudioSrc * asrc, GstAudioRingBufferSpec * spec)
|
||||||
guint bpf, rate, devicep_frames, buffer_frames;
|
guint bpf, rate, devicep_frames, buffer_frames;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
|
CoInitialize (NULL);
|
||||||
|
|
||||||
if (gst_wasapi_src_can_audioclient3 (self)) {
|
if (gst_wasapi_src_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,
|
||||||
|
@ -501,9 +503,7 @@ gst_wasapi_src_unprepare (GstAudioSrc * asrc)
|
||||||
{
|
{
|
||||||
GstWasapiSrc *self = GST_WASAPI_SRC (asrc);
|
GstWasapiSrc *self = GST_WASAPI_SRC (asrc);
|
||||||
|
|
||||||
if (self->sharemode == AUDCLNT_SHAREMODE_EXCLUSIVE &&
|
CoUninitialize ();
|
||||||
!gst_wasapi_src_can_audioclient3 (self))
|
|
||||||
CoUninitialize ();
|
|
||||||
|
|
||||||
if (self->thread_priority_handle != NULL) {
|
if (self->thread_priority_handle != NULL) {
|
||||||
gst_wasapi_util_revert_thread_characteristics
|
gst_wasapi_util_revert_thread_characteristics
|
||||||
|
|
|
@ -870,10 +870,6 @@ gst_wasapi_util_initialize_audioclient (GstElement * self,
|
||||||
min_period, &device_period, &device_buffer_duration);
|
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);
|
|
||||||
|
|
||||||
hr = IAudioClient_Initialize (client, sharemode,
|
hr = IAudioClient_Initialize (client, sharemode,
|
||||||
AUDCLNT_STREAMFLAGS_EVENTCALLBACK, device_buffer_duration,
|
AUDCLNT_STREAMFLAGS_EVENTCALLBACK, device_buffer_duration,
|
||||||
/* This must always be 0 in shared mode */
|
/* This must always be 0 in shared mode */
|
||||||
|
|
Loading…
Reference in a new issue