mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-10 05:32:40 -05:00
hosted: More PCM muting work
* Track mute state, only call hw if actual change is needed * Don't unmute in audiohw_postinit() * sample rate tracking fixes * erosq: Don't start up muted Change-Id: I004f787a4b7ea73c16b6ec9818ec29a12c89f46b
This commit is contained in:
parent
01dc81cd94
commit
078c34e951
5 changed files with 31 additions and 22 deletions
|
|
@ -42,7 +42,7 @@ static int inited = 0;
|
||||||
|
|
||||||
static long int vol_l_hw = 255;
|
static long int vol_l_hw = 255;
|
||||||
static long int vol_r_hw = 255;
|
static long int vol_r_hw = 255;
|
||||||
static long int last_ps = 0;
|
static long int last_ps = -1;
|
||||||
|
|
||||||
static void hw_open(void)
|
static void hw_open(void)
|
||||||
{
|
{
|
||||||
|
|
@ -62,6 +62,11 @@ void audiohw_mute(int mute)
|
||||||
{
|
{
|
||||||
logf("mute %d", mute);
|
logf("mute %d", mute);
|
||||||
|
|
||||||
|
if (muted == mute)
|
||||||
|
return;
|
||||||
|
|
||||||
|
muted = mute;
|
||||||
|
|
||||||
if(mute)
|
if(mute)
|
||||||
{
|
{
|
||||||
long int ps0 = 0;
|
long int ps0 = 0;
|
||||||
|
|
@ -69,10 +74,8 @@ void audiohw_mute(int mute)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
last_ps = 0;
|
|
||||||
erosq_get_outputs();
|
erosq_get_outputs();
|
||||||
}
|
}
|
||||||
muted = mute;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int erosq_get_outputs(void) {
|
int erosq_get_outputs(void) {
|
||||||
|
|
@ -115,14 +118,14 @@ void audiohw_preinit(void)
|
||||||
logf("hw preinit");
|
logf("hw preinit");
|
||||||
alsa_controls_init();
|
alsa_controls_init();
|
||||||
hw_open();
|
hw_open();
|
||||||
audiohw_mute(true); /* Start muted to avoid the POP */
|
// audiohw_mute(true); /* Start muted to avoid the POP */
|
||||||
|
audiohw_mute(false);
|
||||||
inited = 1;
|
inited = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_postinit(void)
|
void audiohw_postinit(void)
|
||||||
{
|
{
|
||||||
logf("hw postinit");
|
logf("hw postinit");
|
||||||
erosq_get_outputs(); // Unmutes
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_close(void)
|
void audiohw_close(void)
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ static int fd_hw;
|
||||||
static long int vol_l_hw = 255;
|
static long int vol_l_hw = 255;
|
||||||
static long int vol_r_hw = 255;
|
static long int vol_r_hw = 255;
|
||||||
|
|
||||||
|
static int muted = -1;
|
||||||
|
|
||||||
static void hw_open(void)
|
static void hw_open(void)
|
||||||
{
|
{
|
||||||
fd_hw = open("/dev/snd/controlC0", O_RDWR);
|
fd_hw = open("/dev/snd/controlC0", O_RDWR);
|
||||||
|
|
@ -46,6 +48,11 @@ static void hw_close(void)
|
||||||
|
|
||||||
void audiohw_mute(int mute)
|
void audiohw_mute(int mute)
|
||||||
{
|
{
|
||||||
|
if (muted == mute)
|
||||||
|
return;
|
||||||
|
|
||||||
|
muted = mute;
|
||||||
|
|
||||||
if(mute)
|
if(mute)
|
||||||
{
|
{
|
||||||
long int ps0 = 0;
|
long int ps0 = 0;
|
||||||
|
|
@ -67,10 +74,7 @@ void audiohw_preinit(void)
|
||||||
|
|
||||||
void audiohw_postinit(void)
|
void audiohw_postinit(void)
|
||||||
{
|
{
|
||||||
long int hp = 2;
|
logf("hw postinit");
|
||||||
|
|
||||||
/* Output port switch set to Headphones */
|
|
||||||
//alsa_controls_set_ints("Output Port Switch", 1, &hp); // Unmute happens on PCM start
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_close(void)
|
void audiohw_close(void)
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ static int inited = 0;
|
||||||
|
|
||||||
static long int vol_l_hw = 255;
|
static long int vol_l_hw = 255;
|
||||||
static long int vol_r_hw = 255;
|
static long int vol_r_hw = 255;
|
||||||
static long int last_ps = 0;
|
static long int last_ps = -1;
|
||||||
|
|
||||||
static void hw_open(void)
|
static void hw_open(void)
|
||||||
{
|
{
|
||||||
|
|
@ -61,6 +61,11 @@ void audiohw_mute(int mute)
|
||||||
{
|
{
|
||||||
logf("mute %d", mute);
|
logf("mute %d", mute);
|
||||||
|
|
||||||
|
if (muted == mute)
|
||||||
|
return;
|
||||||
|
|
||||||
|
muted = mute;
|
||||||
|
|
||||||
if(mute)
|
if(mute)
|
||||||
{
|
{
|
||||||
long int ps0 = 0;
|
long int ps0 = 0;
|
||||||
|
|
@ -68,10 +73,8 @@ void audiohw_mute(int mute)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
last_ps = 0;
|
|
||||||
xduoo_get_outputs();
|
xduoo_get_outputs();
|
||||||
}
|
}
|
||||||
muted = mute;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int xduoo_get_outputs(void){
|
int xduoo_get_outputs(void){
|
||||||
|
|
@ -124,14 +127,12 @@ void audiohw_preinit(void)
|
||||||
hw_open();
|
hw_open();
|
||||||
audiohw_mute(true); /* Start muted to avoid the POP */
|
audiohw_mute(true); /* Start muted to avoid the POP */
|
||||||
inited = 1;
|
inited = 1;
|
||||||
|
// const char * const codec_pmdown = "/sys/devices/platform/ingenic-x3ii.0/x3ii-ak4490-i2s/pmdown_time"; // in ms, defaults 5000
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_postinit(void)
|
void audiohw_postinit(void)
|
||||||
{
|
{
|
||||||
// const char * const codec_pmdown = "/sys/devices/platform/ingenic-x3ii.0/x3ii-ak4490-i2s/pmdown_time"; // in ms, defaults 5000
|
|
||||||
|
|
||||||
logf("hw postinit");
|
logf("hw postinit");
|
||||||
// xduoo_get_outputs(); // Unmute happens upon playback.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void audiohw_close(void)
|
void audiohw_close(void)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -74, 6, -25)
|
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -74, 6, -25)
|
||||||
|
|
||||||
|
//#define AUDIOHW_NEEDS_INITIAL_UNMUTE
|
||||||
|
|
||||||
void audiohw_mute(int mute);
|
void audiohw_mute(int mute);
|
||||||
void erosq_set_output(int ps);
|
void erosq_set_output(int ps);
|
||||||
|
|
|
||||||
|
|
@ -454,7 +454,6 @@ void cleanup(void)
|
||||||
snd_pcm_close(handle);
|
snd_pcm_close(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void pcm_play_dma_init(void)
|
void pcm_play_dma_init(void)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
@ -532,9 +531,6 @@ static void pcm_dma_apply_settings_nolock(void)
|
||||||
#if defined(HAVE_NWZ_LINUX_CODEC)
|
#if defined(HAVE_NWZ_LINUX_CODEC)
|
||||||
/* Sony NWZ linux driver uses a nonstandard mecanism to set the sampling rate */
|
/* Sony NWZ linux driver uses a nonstandard mecanism to set the sampling rate */
|
||||||
audiohw_set_frequency(pcm_sampr);
|
audiohw_set_frequency(pcm_sampr);
|
||||||
#endif
|
|
||||||
#ifdef AUDIOHW_MUTE_ON_SRATE_CHANGE
|
|
||||||
audiohw_mute(false);
|
|
||||||
#endif
|
#endif
|
||||||
/* (Will be unmuted by pcm resuming) */
|
/* (Will be unmuted by pcm resuming) */
|
||||||
}
|
}
|
||||||
|
|
@ -564,7 +560,7 @@ void pcm_play_dma_stop(void)
|
||||||
snd_pcm_nonblock(handle, 0);
|
snd_pcm_nonblock(handle, 0);
|
||||||
snd_pcm_drain(handle);
|
snd_pcm_drain(handle);
|
||||||
snd_pcm_nonblock(handle, 1);
|
snd_pcm_nonblock(handle, 1);
|
||||||
last_sample_rate = 0;
|
// last_sample_rate = 0;
|
||||||
#ifdef AUDIOHW_MUTE_ON_PAUSE
|
#ifdef AUDIOHW_MUTE_ON_PAUSE
|
||||||
audiohw_mute(true);
|
audiohw_mute(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -579,7 +575,7 @@ void pcm_play_dma_start(const void *addr, size_t size)
|
||||||
pcm_data = addr;
|
pcm_data = addr;
|
||||||
pcm_size = size;
|
pcm_size = size;
|
||||||
|
|
||||||
#if !defined(AUDIOHW_MUTE_ON_PAUSE) || !defined(AUDIOHW_MUTE_ON_SRATE_CHANGE)
|
#if !defined(AUDIOHW_MUTE_ON_PAUSE) && defined(AUDIOHW_MUTE_ON_SRATE_CHANGE)
|
||||||
audiohw_mute(false);
|
audiohw_mute(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -615,7 +611,7 @@ void pcm_play_dma_start(const void *addr, size_t size)
|
||||||
logf("Start error: %s\n", snd_strerror(err));
|
logf("Start error: %s\n", snd_strerror(err));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef AUDIOHW_MUTE_ON_PAUSE
|
#if defined(AUDIOHW_MUTE_ON_PAUSE)
|
||||||
audiohw_mute(false);
|
audiohw_mute(false);
|
||||||
#endif
|
#endif
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
|
|
@ -652,6 +648,10 @@ const void * pcm_play_dma_get_peak_buffer(int *count)
|
||||||
void pcm_play_dma_postinit(void)
|
void pcm_play_dma_postinit(void)
|
||||||
{
|
{
|
||||||
audiohw_postinit();
|
audiohw_postinit();
|
||||||
|
|
||||||
|
#ifdef AUDIOHW_NEEDS_INITIAL_UNMUTE
|
||||||
|
audiohw_mute(false);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void pcm_set_mixer_volume(int volume)
|
void pcm_set_mixer_volume(int volume)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue