[fix](trx-client): preserve vchan commands under scheduler churn

Use an unbounded virtual-channel command queue so background decode and scheduler transitions do not silently drop subscribe or remove commands.\n\nCo-authored-by: OpenAI Codex <codex@openai.com>

Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
2026-03-13 07:10:40 +01:00
parent c178c56f2e
commit 66987a4070
5 changed files with 9 additions and 8 deletions
@@ -238,7 +238,7 @@ impl BackgroundDecodeManager {
fn send_audio_cmd(&self, cmd: VChanAudioCmd) {
if let Ok(guard) = self.context.vchan_audio_cmd.lock() {
if let Some(tx) = guard.as_ref() {
let _ = tx.try_send(cmd);
let _ = tx.send(cmd);
}
}
}
@@ -97,7 +97,7 @@ pub struct ClientChannelManager {
pub change_tx: broadcast::Sender<String>,
pub max_channels: usize,
/// Optional sender to the audio-client task for virtual-channel audio commands.
pub audio_cmd: std::sync::Mutex<Option<tokio::sync::mpsc::Sender<VChanAudioCmd>>>,
pub audio_cmd: std::sync::Mutex<Option<tokio::sync::mpsc::UnboundedSender<VChanAudioCmd>>>,
}
impl ClientChannelManager {
@@ -114,14 +114,14 @@ impl ClientChannelManager {
/// Wire the audio-command sender so the manager can dispatch
/// `VChanAudioCmd` messages when channels are allocated/deleted/changed.
pub fn set_audio_cmd(&self, tx: tokio::sync::mpsc::Sender<VChanAudioCmd>) {
pub fn set_audio_cmd(&self, tx: tokio::sync::mpsc::UnboundedSender<VChanAudioCmd>) {
*self.audio_cmd.lock().unwrap() = Some(tx);
}
/// Fire-and-forget: send a `VChanAudioCmd` to the audio-client task.
fn send_audio_cmd(&self, cmd: VChanAudioCmd) {
if let Some(tx) = self.audio_cmd.lock().unwrap().as_ref() {
let _ = tx.try_send(cmd);
let _ = tx.send(cmd);
}
}