summaryrefslogtreecommitdiffstats
path: root/firmware/drivers/audio/rocker_codec.c
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-10-16 20:34:18 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-10-16 20:34:18 -0400
commitce40ef42ff68f5209a37304eaddf4123b7cc013a (patch)
tree7753e80f15f7bbd7f6c9d30113a38c8818fe2fea /firmware/drivers/audio/rocker_codec.c
parentd993448c9f3a8ddcf92d1e025183e6f3c4db7bc3 (diff)
downloadrockbox-ce40ef42ff.tar.gz
rockbox-ce40ef42ff.zip
hosted: Make sure we don't call mixer/etc controls when we're not ready
(Might fix the rocker crash-on-shutdown bug) Change-Id: Id375fc5053adef18d7ec812bdba36ee002e706ef
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);
}