summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/audio/rocker_codec.c3
-rw-r--r--firmware/export/rocker_codec.h2
-rw-r--r--firmware/target/hosted/pcm-alsa.c18
3 files changed, 15 insertions, 8 deletions
diff --git a/firmware/drivers/audio/rocker_codec.c b/firmware/drivers/audio/rocker_codec.c
index 5404ff9561..525507494b 100644
--- a/firmware/drivers/audio/rocker_codec.c
+++ b/firmware/drivers/audio/rocker_codec.c
@@ -62,6 +62,7 @@ void audiohw_preinit(void)
{
alsa_controls_init();
hw_open();
+ audiohw_mute(true); /* Start muted to avoid the POP */
}
void audiohw_postinit(void)
@@ -69,7 +70,7 @@ void audiohw_postinit(void)
long int hp = 2;
/* Output port switch set to Headphones */
- alsa_controls_set_ints("Output Port Switch", 1, &hp);
+ alsa_controls_set_ints("Output Port Switch", 1, &hp); /* Unmutes */
}
void audiohw_close(void)
diff --git a/firmware/export/rocker_codec.h b/firmware/export/rocker_codec.h
index 673b12b494..428fd7e890 100644
--- a/firmware/export/rocker_codec.h
+++ b/firmware/export/rocker_codec.h
@@ -5,4 +5,6 @@
AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -127, 0, -30)
#endif
+#define AUDIOHW_MUTE_ON_PAUSE
+
void audiohw_mute(int mute);
diff --git a/firmware/target/hosted/pcm-alsa.c b/firmware/target/hosted/pcm-alsa.c
index 1395d071aa..09b4de0e5e 100644
--- a/firmware/target/hosted/pcm-alsa.c
+++ b/firmware/target/hosted/pcm-alsa.c
@@ -471,10 +471,6 @@ void pcm_play_dma_init(void)
if ((err = snd_pcm_nonblock(handle, 1)))
panicf("Could not set non-block mode: %s\n", snd_strerror(err));
-#if defined(HAVE_XDUOO_LINUX_CODEC) || defined(HAVE_FIIO_LINUX_CODEC) || defined(HAVE_ROCKER_CODEC)
- audiohw_mute(true);
-#endif
-
if ((err = set_hwparams(handle)) < 0)
{
panicf("Setting of hwparams failed: %s\n", snd_strerror(err));
@@ -525,10 +521,12 @@ static void pcm_dma_apply_settings_nolock(void)
logf("PCM DMA Settings %d %d", sample_rate, pcm_sampr);
if (sample_rate != pcm_sampr)
{
+#ifdef AUDIOHW_MUTE_ON_PAUSE
audiohw_mute(true);
+#endif
snd_pcm_drop(handle);
set_hwparams(handle);
-// audiohw_mute(false); /// Play DMA will unmute us.
+ /* Will be unmuted by pcm resuming */
}
}
#else
@@ -555,7 +553,13 @@ void pcm_dma_apply_settings(void)
void pcm_play_dma_pause(bool pause)
{
logf("PCM DMA pause %d", pause);
+#ifdef AUDIOHW_MUTE_ON_PAUSE
+ if (pause) audiohw_mute(true);
+#endif
snd_pcm_pause(handle, pause);
+#ifdef AUDIOHW_MUTE_ON_PAUSE
+ if (!pause) audiohw_mute(false);
+#endif
}
void pcm_play_dma_stop(void)
@@ -564,7 +568,7 @@ void pcm_play_dma_stop(void)
snd_pcm_drain(handle);
snd_pcm_nonblock(handle, 1);
sample_rate = 0;
-#if defined(HAVE_XDUOO_LINUX_CODEC) || defined(HAVE_FIIO_LINUX_CODEC) || defined(HAVE_ROCKER_CODEC)
+#ifdef AUDIOHW_MUTE_ON_PAUSE
audiohw_mute(true);
#endif
logf("PCM DMA stopped");
@@ -610,7 +614,7 @@ void pcm_play_dma_start(const void *addr, size_t size)
logf("Start error: %s\n", snd_strerror(err));
return;
}
-#if defined(HAVE_XDUOO_LINUX_CODEC) || defined(HAVE_FIIO_LINUX_CODEC) || defined(HAVE_ROCKER_CODEC)
+#ifdef AUDIOHW_MUTE_ON_PAUSE
audiohw_mute(false);
#endif
if (err == 0)