summaryrefslogtreecommitdiffstats
path: root/firmware/drivers/audio/rocker_codec.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/audio/rocker_codec.c')
-rw-r--r--firmware/drivers/audio/rocker_codec.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/firmware/drivers/audio/rocker_codec.c b/firmware/drivers/audio/rocker_codec.c
index f4135fdaa5..abe13be285 100644
--- a/firmware/drivers/audio/rocker_codec.c
+++ b/firmware/drivers/audio/rocker_codec.c
@@ -27,7 +27,7 @@
#include "panic.h"
#include "alsa-controls.h"
-static int fd_hw;
+static int fd_hw = -1;
static long int vol_l_hw = 255;
static long int vol_r_hw = 255;
@@ -44,11 +44,13 @@ static void hw_open(void)
static void hw_close(void)
{
close(fd_hw);
+ fd_hw = -1;
+ muted = -1;
}
void audiohw_mute(int mute)
{
- if (muted == mute)
+ if (fd_hw < 0 || muted == mute)
return;
muted = mute;
@@ -92,6 +94,9 @@ void audiohw_set_volume(int vol_l, int vol_r)
vol_l_hw = -vol_l/5;
vol_r_hw = -vol_r/5;
+ if (fd_hw < 0)
+ return;
+
alsa_controls_set_ints("Left Playback Volume", 1, &vol_l_hw);
alsa_controls_set_ints("Right Playback Volume", 1, &vol_r_hw);
}