diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-10-03 09:19:12 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-10-03 14:41:40 +0000 |
commit | d4a620e85af6c1eae4c99b92c81d8c098f13eae9 (patch) | |
tree | d5ff41ccf6267d847e98e3f906701c48ca363b9d /firmware | |
parent | d18157608d5aba50cf538c4853f42fce7e3731ef (diff) | |
download | rockbox-d4a620e85af6c1eae4c99b92c81d8c098f13eae9.tar.gz rockbox-d4a620e85af6c1eae4c99b92c81d8c098f13eae9.zip |
alsa: introduce AUDIOHW_MUTE_ON_PAUSE, and have rocker use it.
Change-Id: I1edbb8e71a9c73baaeecb01b66cbee6c3f7b5f8f
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/audio/rocker_codec.c | 3 | ||||
-rw-r--r-- | firmware/export/rocker_codec.h | 2 | ||||
-rw-r--r-- | firmware/target/hosted/pcm-alsa.c | 18 |
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) | |||
62 | { | 62 | { |
63 | alsa_controls_init(); | 63 | alsa_controls_init(); |
64 | hw_open(); | 64 | hw_open(); |
65 | audiohw_mute(true); /* Start muted to avoid the POP */ | ||
65 | } | 66 | } |
66 | 67 | ||
67 | void audiohw_postinit(void) | 68 | void audiohw_postinit(void) |
@@ -69,7 +70,7 @@ void audiohw_postinit(void) | |||
69 | long int hp = 2; | 70 | long int hp = 2; |
70 | 71 | ||
71 | /* Output port switch set to Headphones */ | 72 | /* Output port switch set to Headphones */ |
72 | alsa_controls_set_ints("Output Port Switch", 1, &hp); | 73 | alsa_controls_set_ints("Output Port Switch", 1, &hp); /* Unmutes */ |
73 | } | 74 | } |
74 | 75 | ||
75 | void audiohw_close(void) | 76 | 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 @@ | |||
5 | AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -127, 0, -30) | 5 | AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -127, 0, -30) |
6 | #endif | 6 | #endif |
7 | 7 | ||
8 | #define AUDIOHW_MUTE_ON_PAUSE | ||
9 | |||
8 | void audiohw_mute(int mute); | 10 | 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) | |||
471 | if ((err = snd_pcm_nonblock(handle, 1))) | 471 | if ((err = snd_pcm_nonblock(handle, 1))) |
472 | panicf("Could not set non-block mode: %s\n", snd_strerror(err)); | 472 | panicf("Could not set non-block mode: %s\n", snd_strerror(err)); |
473 | 473 | ||
474 | #if defined(HAVE_XDUOO_LINUX_CODEC) || defined(HAVE_FIIO_LINUX_CODEC) || defined(HAVE_ROCKER_CODEC) | ||
475 | audiohw_mute(true); | ||
476 | #endif | ||
477 | |||
478 | if ((err = set_hwparams(handle)) < 0) | 474 | if ((err = set_hwparams(handle)) < 0) |
479 | { | 475 | { |
480 | panicf("Setting of hwparams failed: %s\n", snd_strerror(err)); | 476 | panicf("Setting of hwparams failed: %s\n", snd_strerror(err)); |
@@ -525,10 +521,12 @@ static void pcm_dma_apply_settings_nolock(void) | |||
525 | logf("PCM DMA Settings %d %d", sample_rate, pcm_sampr); | 521 | logf("PCM DMA Settings %d %d", sample_rate, pcm_sampr); |
526 | if (sample_rate != pcm_sampr) | 522 | if (sample_rate != pcm_sampr) |
527 | { | 523 | { |
524 | #ifdef AUDIOHW_MUTE_ON_PAUSE | ||
528 | audiohw_mute(true); | 525 | audiohw_mute(true); |
526 | #endif | ||
529 | snd_pcm_drop(handle); | 527 | snd_pcm_drop(handle); |
530 | set_hwparams(handle); | 528 | set_hwparams(handle); |
531 | // audiohw_mute(false); /// Play DMA will unmute us. | 529 | /* Will be unmuted by pcm resuming */ |
532 | } | 530 | } |
533 | } | 531 | } |
534 | #else | 532 | #else |
@@ -555,7 +553,13 @@ void pcm_dma_apply_settings(void) | |||
555 | void pcm_play_dma_pause(bool pause) | 553 | void pcm_play_dma_pause(bool pause) |
556 | { | 554 | { |
557 | logf("PCM DMA pause %d", pause); | 555 | logf("PCM DMA pause %d", pause); |
556 | #ifdef AUDIOHW_MUTE_ON_PAUSE | ||
557 | if (pause) audiohw_mute(true); | ||
558 | #endif | ||
558 | snd_pcm_pause(handle, pause); | 559 | snd_pcm_pause(handle, pause); |
560 | #ifdef AUDIOHW_MUTE_ON_PAUSE | ||
561 | if (!pause) audiohw_mute(false); | ||
562 | #endif | ||
559 | } | 563 | } |
560 | 564 | ||
561 | void pcm_play_dma_stop(void) | 565 | void pcm_play_dma_stop(void) |
@@ -564,7 +568,7 @@ void pcm_play_dma_stop(void) | |||
564 | snd_pcm_drain(handle); | 568 | snd_pcm_drain(handle); |
565 | snd_pcm_nonblock(handle, 1); | 569 | snd_pcm_nonblock(handle, 1); |
566 | sample_rate = 0; | 570 | sample_rate = 0; |
567 | #if defined(HAVE_XDUOO_LINUX_CODEC) || defined(HAVE_FIIO_LINUX_CODEC) || defined(HAVE_ROCKER_CODEC) | 571 | #ifdef AUDIOHW_MUTE_ON_PAUSE |
568 | audiohw_mute(true); | 572 | audiohw_mute(true); |
569 | #endif | 573 | #endif |
570 | logf("PCM DMA stopped"); | 574 | logf("PCM DMA stopped"); |
@@ -610,7 +614,7 @@ void pcm_play_dma_start(const void *addr, size_t size) | |||
610 | logf("Start error: %s\n", snd_strerror(err)); | 614 | logf("Start error: %s\n", snd_strerror(err)); |
611 | return; | 615 | return; |
612 | } | 616 | } |
613 | #if defined(HAVE_XDUOO_LINUX_CODEC) || defined(HAVE_FIIO_LINUX_CODEC) || defined(HAVE_ROCKER_CODEC) | 617 | #ifdef AUDIOHW_MUTE_ON_PAUSE |
614 | audiohw_mute(false); | 618 | audiohw_mute(false); |
615 | #endif | 619 | #endif |
616 | if (err == 0) | 620 | if (err == 0) |