forked from len0rd/rockbox
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
This commit is contained in:
parent
d993448c9f
commit
ce40ef42ff
4 changed files with 40 additions and 24 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue