From dd6fa6121e17c393681ed95c5397035696e63423 Mon Sep 17 00:00:00 2001 From: Edison Jwa Date: Thu, 11 Jun 2026 13:30:52 +0900 Subject: [PATCH] feat(bridge,core): add is_hard_muted and get_output_gain readback (TODO-037) Add bridge read-back functions for hard-mute state and output gain. Add core output_gain() getter. Document feature gaps in SRS. --- core/chanora_core/src/lib.rs | 15 +++++++++++++++ crates/chanora_bridge/src/api.rs | 20 +++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/core/chanora_core/src/lib.rs b/core/chanora_core/src/lib.rs index 8f121ec..f9d7eb3 100644 --- a/core/chanora_core/src/lib.rs +++ b/core/chanora_core/src/lib.rs @@ -1113,6 +1113,21 @@ impl ChanoraSession { Ok(()) } + /// Read the current master output gain. Returns `1.0` (unity) if + /// audio is not started. + pub async fn output_gain(&self) -> f32 { + let guard = self.inner.lock().await; + let state = match guard.as_ref() { + Some(s) => s, + None => return 1.0, + }; + let audio = match state.audio.as_ref() { + Some(a) => a, + None => return 1.0, + }; + audio.output_gain() + } + /// Set per-client output volume (SRS-075). `1.0` is unity, `0.0` /// mutes. No-op if audio is not started or client has no active /// voice queue. diff --git a/crates/chanora_bridge/src/api.rs b/crates/chanora_bridge/src/api.rs index 50f04fa..fe0dae6 100644 --- a/crates/chanora_bridge/src/api.rs +++ b/crates/chanora_bridge/src/api.rs @@ -837,6 +837,15 @@ pub async fn set_hard_mute(muted: bool) -> Result<(), BridgeError> { Ok(()) } +/// Read the current hard-mute state. Returns `true` when the audio +/// engine is clamped and transmits nothing regardless of mode. +pub async fn is_hard_muted() -> bool { + runtime() + .spawn(async { session().hard_mute() }) + .await + .unwrap_or(false) +} + /// Coarse PTT input class (gen2 v0.9.3 / DEC-026). Stable strings; /// the bridge never carries raw key codes. #[derive(Debug, Clone, Copy)] @@ -999,6 +1008,15 @@ pub async fn set_output_gain(gain: f32) -> Result<(), BridgeError> { Ok(()) } +/// Read the current master output gain. Returns `1.0` (unity) when +/// audio is not started. +pub async fn get_output_gain() -> f32 { + runtime() + .spawn(async { session().output_gain().await }) + .await + .unwrap_or(1.0) +} + /// Set per-client output volume (SRS-075). `1.0` is unity, `0.0` /// mutes. No-op when client has no active voice queue. Volume is /// applied directly to the tsclientlib AudioQueue and takes effect @@ -2394,7 +2412,7 @@ pub async fn enable_audio_debug_wav_dump(enabled: bool) -> Result<(), BridgeErro .spawn(async move { session().set_audio_debug_wav_dump(enabled).await }) .await .map_err(|e| task_join_error("enable_audio_debug_wav_dump", e))? - .map_err(|e| BridgeError::Unmapped(format!("enable_audio_debug_wav_dump: {e}")))?; + .map_err(|e| BridgeError::unmapped_ctx("enable_audio_debug_wav_dump", e))?; Ok(()) }