From 8eee442715ce38b4ac6f8df99f2733d3c87f3813 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Thu, 4 Nov 2021 16:36:05 +0900 Subject: [PATCH] wasapi2ringbuffer: Fix client object leak Check whether ringbuffer is holding client object already since open_device() may be called multiple times Part-of: --- .../sys/wasapi2/gstwasapi2ringbuffer.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/wasapi2/gstwasapi2ringbuffer.cpp b/subprojects/gst-plugins-bad/sys/wasapi2/gstwasapi2ringbuffer.cpp index 96e95a1136..08ce65a516 100644 --- a/subprojects/gst-plugins-bad/sys/wasapi2/gstwasapi2ringbuffer.cpp +++ b/subprojects/gst-plugins-bad/sys/wasapi2/gstwasapi2ringbuffer.cpp @@ -165,7 +165,6 @@ struct _GstWasapi2RingBuffer guint64 expected_position; gboolean is_first; gboolean running; - gboolean opened; UINT32 buffer_size; UINT32 loopback_buffer_size; @@ -231,8 +230,6 @@ gst_wasapi2_ring_buffer_class_init (GstWasapi2RingBufferClass * klass) static void gst_wasapi2_ring_buffer_init (GstWasapi2RingBuffer * self) { - self->opened = FALSE; - self->volume = 1.0f; self->mute = FALSE; @@ -377,7 +374,7 @@ gst_wasapi2_ring_buffer_open_device (GstAudioRingBuffer * buf) GST_DEBUG_OBJECT (self, "Open"); - if (self->opened) { + if (self->client) { GST_DEBUG_OBJECT (self, "Already opened"); return TRUE; } @@ -430,8 +427,6 @@ gst_wasapi2_ring_buffer_close_device_internal (GstAudioRingBuffer * buf) gst_clear_object (&self->client); gst_clear_object (&self->loopback_client); - self->opened = FALSE; - return TRUE; } @@ -972,7 +967,7 @@ gst_wasapi2_ring_buffer_acquire (GstAudioRingBuffer * buf, GST_DEBUG_OBJECT (buf, "Acquire"); - if (!self->opened && !gst_wasapi2_ring_buffer_open_device (buf)) + if (!self->client && !gst_wasapi2_ring_buffer_open_device (buf)) return FALSE; if (self->device_class == GST_WASAPI2_CLIENT_DEVICE_CLASS_LOOPBACK_CAPTURE) { @@ -982,11 +977,6 @@ gst_wasapi2_ring_buffer_acquire (GstAudioRingBuffer * buf, } } - if (!self->client) { - GST_ERROR_OBJECT (self, "No configured client object"); - goto error; - } - if (!gst_wasapi2_client_ensure_activation (self->client)) { GST_ERROR_OBJECT (self, "Failed to activate audio client"); goto error; -- 2.34.1