fix: 异步播放提示音,防止阻塞

This commit is contained in:
Del Wang
2026-01-01 14:28:32 +08:00
parent 118c34eb5c
commit 3017473850
+7 -4
View File
@@ -9,7 +9,6 @@ use crate::net::protocol::{AudioPacket, ChannelRole, ControlPacket};
use crate::utils::jitter_buffer::JitterBuffer;
use crate::utils::sync::{ClockSync, now_us};
use anyhow::{Result, anyhow};
use std::process::Command;
use std::sync::Arc;
use std::time::Duration;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
@@ -133,13 +132,17 @@ async fn handle_connection(role: ChannelRole) -> Result<()> {
// 8. 播放主循环
println!("✅ 主节点已连接,音频串流中...");
let _ = Command::new("sh")
let role_str = role.to_string();
tokio::spawn(async move {
let _ = tokio::process::Command::new("sh")
.arg("-c")
.arg(format!(
"/usr/sbin/tts_play.sh \"主节点已连接,{}\" >/dev/null 2>&1",
role.to_string()
role_str
))
.status();
.status()
.await;
});
let mut pcm_buf = vec![0i16; config.frame_size];
let mut last_seq: Option<u32> = None;