From 41a8e0e9b6721c6fdc5be0fe5f1f52257799be79 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 28 Mar 2025 09:18:00 -0500 Subject: [PATCH] Mute the i2s dac when sound output is inactive --- src/main.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main.c b/src/main.c index 8ef568e..0ce89ac 100644 --- a/src/main.c +++ b/src/main.c @@ -739,7 +739,23 @@ static bool audio_poll() { return true; } +static bool mute_state = false; +static void set_mute_state(bool new_state) { + if(mute_state == new_state) return; + mute_state = new_state; + + setPage(1); + if(mute_state) { + modifyRegister(0x28, 0x04, 0x04); // HP Left not muted + modifyRegister(0x29, 0x04, 0x04); // HP Right not muted + } else { + modifyRegister(0x28, 0x04, 0x0); // HP Left muted + modifyRegister(0x29, 0x04, 0x0); // HP Right muted + } +} + void umac_audio_cfg(int volume, int sndres) { volscale = sndres ? 0 : 65536 * volume / 7; + set_mute_state(volscale != 0); } #endif