From 668783f0ce26e610a2240f62af385b1b45292656 Mon Sep 17 00:00:00 2001 From: Jacob Marble Date: Fri, 29 Jul 2022 17:36:57 -0700 Subject: [PATCH] chore: close ALSA handle before throwing Exception --- darkice/trunk/src/AlsaDspSource.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/darkice/trunk/src/AlsaDspSource.cpp b/darkice/trunk/src/AlsaDspSource.cpp index eb568ea..4c55bf3 100644 --- a/darkice/trunk/src/AlsaDspSource.cpp +++ b/darkice/trunk/src/AlsaDspSource.cpp @@ -262,13 +262,17 @@ AlsaDspSource :: read ( void * buf, } while (ret == -EAGAIN); if ( ret == -EBADFD ) { - throw Exception(__FILE__, __LINE__, - "ALSA/PCM device is in a bad state: ", - std::to_string(snd_pcm_state(captureHandle)).c_str()); + Exception e = Exception(__FILE__, __LINE__, + "ALSA/PCM device is in a bad state: ", + std::to_string(snd_pcm_state(captureHandle)).c_str()); + close(); + throw e; } if ( ret < 0 ) { - throw Exception(__FILE__, __LINE__, snd_strerror(ret)); + Exception e = Exception(__FILE__, __LINE__, snd_strerror(ret)); + close(); + throw e; } running = true;