From 21159dd83a6756b7efc35090684453d96b5fd6ef Mon Sep 17 00:00:00 2001 From: xperia64 Date: Thu, 21 May 2020 21:05:03 -0400 Subject: [PATCH] clang-format, and avoid another potential leak --- src/audio_core/cubeb_input.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/audio_core/cubeb_input.cpp b/src/audio_core/cubeb_input.cpp index c96e13395..04d89e525 100644 --- a/src/audio_core/cubeb_input.cpp +++ b/src/audio_core/cubeb_input.cpp @@ -37,8 +37,12 @@ CubebInput::~CubebInput() { if (!impl->ctx) return; - if (impl->stream && cubeb_stream_stop(impl->stream) != CUBEB_OK) { - LOG_ERROR(Audio, "Error stopping cubeb input stream."); + if (impl->stream) { + if (cubeb_stream_stop(impl->stream) != CUBEB_OK) { + LOG_ERROR(Audio, "Error stopping cubeb input stream."); + } + + cubeb_stream_destroy(impl->stream); } cubeb_destroy(impl->ctx); @@ -103,7 +107,8 @@ 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 + // 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);