From f9750875e332a4ccf2c19745920a2cbc7dfc652f Mon Sep 17 00:00:00 2001 From: xperia64 Date: Thu, 21 May 2020 20:34:00 -0400 Subject: [PATCH] Avoid leaking the cubeb input stream --- src/audio_core/cubeb_input.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/audio_core/cubeb_input.cpp b/src/audio_core/cubeb_input.cpp index 794c367aba..c96e13395d 100644 --- a/src/audio_core/cubeb_input.cpp +++ b/src/audio_core/cubeb_input.cpp @@ -37,7 +37,7 @@ CubebInput::~CubebInput() { if (!impl->ctx) return; - if (cubeb_stream_stop(impl->stream) != CUBEB_OK) { + if (impl->stream && cubeb_stream_stop(impl->stream) != CUBEB_OK) { LOG_ERROR(Audio, "Error stopping cubeb input stream."); } @@ -103,8 +103,11 @@ void CubebInput::StartSampling(const Frontend::Mic::Parameters& params) { } void CubebInput::StopSampling() { + // TODO(xperia64): Destroy the stream for now to avoid a leak because StartSampling reinitializes the stream every time if (impl->stream) { cubeb_stream_stop(impl->stream); + cubeb_stream_destroy(impl->stream); + impl->stream = nullptr; } is_sampling = false; }