wasapi2: Fix task memory leak

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6218>
This commit is contained in:
Seungha Yang 2024-02-21 21:46:49 +09:00 committed by GStreamer Marge Bot
parent b793c3e03b
commit 3bc068473b

View file

@ -973,6 +973,7 @@ gst_wasapi2_ring_buffer_prepare_loopback_client (GstWasapi2RingBuffer * self)
hr = gst_wasapi2_ring_buffer_initialize_audio_client (self, client_handle,
mix_format, &period, 0, GST_WASAPI2_CLIENT_DEVICE_CLASS_RENDER,
nullptr, FALSE);
CoTaskMemFree (mix_format);
if (!gst_wasapi2_result (hr)) {
GST_ERROR_OBJECT (self, "Failed to initialize audio client");
@ -1117,8 +1118,6 @@ gst_wasapi2_ring_buffer_acquire (GstAudioRingBuffer * buf,
gst_audio_ring_buffer_set_channel_positions (buf, position);
g_free (position);
CoTaskMemFree (mix_format);
if (!gst_wasapi2_result (hr)) {
GST_ERROR_OBJECT (self, "Failed to init audio client");
goto error;
@ -1184,12 +1183,15 @@ gst_wasapi2_ring_buffer_acquire (GstAudioRingBuffer * buf,
gst_audio_format_info_fill_silence (buf->spec.info.finfo,
buf->memory, buf->size);
CoTaskMemFree (mix_format);
return TRUE;
error:
GST_WASAPI2_CLEAR_COM (self->render_client);
GST_WASAPI2_CLEAR_COM (self->capture_client);
GST_WASAPI2_CLEAR_COM (self->volume_object);
CoTaskMemFree (mix_format);
gst_wasapi2_ring_buffer_post_open_error (self);