diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-10-16 20:34:18 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-10-16 20:34:18 -0400 |
commit | ce40ef42ff68f5209a37304eaddf4123b7cc013a (patch) | |
tree | 7753e80f15f7bbd7f6c9d30113a38c8818fe2fea /firmware/drivers/audio/erosqlinux_codec.c | |
parent | d993448c9f3a8ddcf92d1e025183e6f3c4db7bc3 (diff) | |
download | rockbox-ce40ef42ff.tar.gz rockbox-ce40ef42ff.tar.bz2 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/erosqlinux_codec.c')
-rw-r--r-- | firmware/drivers/audio/erosqlinux_codec.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/firmware/drivers/audio/erosqlinux_codec.c b/firmware/drivers/audio/erosqlinux_codec.c index c8a104efd6..268da54280 100644 --- a/firmware/drivers/audio/erosqlinux_codec.c +++ b/firmware/drivers/audio/erosqlinux_codec.c @@ -37,8 +37,7 @@ #include "logf.h" -static int fd_hw; -static int inited = 0; +static int fd_hw = -1; static long int vol_l_hw = 255; static long int vol_r_hw = 255; @@ -54,6 +53,7 @@ static void hw_open(void) static void hw_close(void) { close(fd_hw); + fd_hw = -1; } static int muted = -1; @@ -62,7 +62,7 @@ void audiohw_mute(int mute) { logf("mute %d", mute); - if (muted == mute) + if (fd_hw < 0 || muted == mute) return; muted = mute; @@ -84,7 +84,7 @@ int erosq_get_outputs(void) { int status = 0; - if (!inited) return ps; + if (fd_hw < 0) return ps; const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state"; const char * const sysfs_hs_switch = "/sys/class/switch/headset/state"; @@ -102,7 +102,7 @@ int erosq_get_outputs(void) { void erosq_set_output(int ps) { - if (!inited || muted) return; + if (fd_hw < 0 || muted) return; if (last_ps != ps) { @@ -119,9 +119,7 @@ void audiohw_preinit(void) logf("hw preinit"); alsa_controls_init(); hw_open(); -// audiohw_mute(true); /* Start muted to avoid the POP */ - audiohw_mute(false); - inited = 1; + audiohw_mute(false); /* No need to stay muted */ } void audiohw_postinit(void) @@ -132,7 +130,6 @@ void audiohw_postinit(void) void audiohw_close(void) { logf("hw close"); - inited = 0; hw_close(); alsa_controls_close(); } |