fix(server): decode mic uplink before UAC sink

This commit is contained in:
Brad Stein 2026-04-22 16:18:46 -03:00
parent 4084c5c781
commit 5e6935121a
2 changed files with 37 additions and 2 deletions

View File

@ -510,6 +510,14 @@ impl Voice {
.unwrap();
// dedicated AppSrc helpers exist and avoid the needless `?`
appsrc.set_caps(Some(
&gst::Caps::builder("audio/mpeg")
.field("mpegversion", 4i32)
.field("stream-format", "adts")
.field("rate", 48_000i32)
.field("channels", 2i32)
.build(),
));
appsrc.set_format(gst::Format::Time);
appsrc.set_is_live(true);
@ -570,6 +578,33 @@ impl Voice {
let _ = pad.link(&convert_sink);
});
let bus = pipeline.bus().context("voice pipeline bus")?;
std::thread::spawn(move || {
for msg in bus.iter_timed(gst::ClockTime::NONE) {
match msg.view() {
Error(e) => error!(
"🎤💥 voice pipeline from {:?}: {} ({})",
msg.src().map(gst::prelude::GstObjectExt::path_string),
e.error(),
e.debug().unwrap_or_default()
),
Warning(w) => warn!(
"🎤⚠️ voice pipeline from {:?}: {} ({})",
msg.src().map(gst::prelude::GstObjectExt::path_string),
w.error(),
w.debug().unwrap_or_default()
),
StateChanged(s)
if s.current() == gst::State::Playing
&& msg.src().map(|s| s.is::<gst::Pipeline>()).unwrap_or(false) =>
{
debug!("🎤 voice pipeline ▶️")
}
_ => {}
}
}
});
// underrun ≠ error just show a warning
// let _id = alsa_sink.connect("underrun", false, |_| {
// tracing::warn!("⚠️ USB playback underrun host muted/not reading");

View File

@ -686,8 +686,8 @@ impl Relay for Handler {
while let Some(pkt) = inbound.next().await.transpose()? {
let n = CNT.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
if n < 10 || n % 300 == 0 {
tracing::trace!(rpc_id, "🎤⬇ srv pkt#{n} {} bytes", pkt.data.len());
if n < 5 || n % 3_000 == 0 {
tracing::info!(rpc_id, "🎤⬇ srv pkt#{n} {} bytes", pkt.data.len());
}
sink.push(&pkt);
}