summaryrefslogtreecommitdiff
path: root/drivers/alsa/audio_driver_alsa.cpp
diff options
context:
space:
mode:
authorIbrahn Sahir <ibrahn.sahir@gmail.com>2018-07-23 12:55:34 +0100
committerIbrahn Sahir <ibrahn.sahir@gmail.com>2018-07-23 13:14:04 +0100
commit3e85e89dc548401b779c403f182860e5dcd31927 (patch)
tree1f7b44097fa60a5aae5246cacb96f17f13730a54 /drivers/alsa/audio_driver_alsa.cpp
parent1a9603e2bbae97cf558469bb49e421b93595ed5b (diff)
correctly close handle in alsa audio driver.
Diffstat (limited to 'drivers/alsa/audio_driver_alsa.cpp')
-rw-r--r--drivers/alsa/audio_driver_alsa.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp
index ae85ee50d1..08005efa9d 100644
--- a/drivers/alsa/audio_driver_alsa.cpp
+++ b/drivers/alsa/audio_driver_alsa.cpp
@@ -58,7 +58,10 @@ Error AudioDriverALSA::init_device() {
#define CHECK_FAIL(m_cond) \
if (m_cond) { \
fprintf(stderr, "ALSA ERR: %s\n", snd_strerror(status)); \
- snd_pcm_close(pcm_handle); \
+ if (pcm_handle) { \
+ snd_pcm_close(pcm_handle); \
+ pcm_handle = NULL; \
+ } \
ERR_FAIL_COND_V(m_cond, ERR_CANT_OPEN); \
}
@@ -150,7 +153,6 @@ Error AudioDriverALSA::init() {
active = false;
thread_exited = false;
exit_thread = false;
- pcm_open = false;
Error err = init_device();
if (err == OK) {
@@ -313,9 +315,9 @@ void AudioDriverALSA::unlock() {
void AudioDriverALSA::finish_device() {
- if (pcm_open) {
+ if (pcm_handle) {
snd_pcm_close(pcm_handle);
- pcm_open = NULL;
+ pcm_handle = NULL;
}
}