Audio Fix

This commit is contained in:
Brad Stein 2025-06-30 02:03:01 -05:00
parent 139ca96954
commit 263417844f
2 changed files with 24 additions and 4 deletions

View File

@ -65,6 +65,22 @@ pub async fn eye_ear(alsa_dev: &str, id: u32) -> anyhow::Result<AudioStream> {
let (tx, rx) = tokio::sync::mpsc::channel(8192);
let bus = pipeline.bus().expect("no bus");
std::thread::spawn(move || {
for msg in bus.iter_timed(gst::ClockTime::NONE) {
use gst::MessageView::*;
match msg.view() {
Error(e) => error!("💥 audio pipeline: {} ({})",
e.error(), e.debug().unwrap_or_default()),
Warning(w) => warn!("⚠️ audio pipeline: {} ({})",
w.error(), w.debug().unwrap_or_default()),
StateChanged(s) if s.current() == gst::State::Playing =>
debug!("🎶 audio pipeline PLAYING"),
_ => {}
}
}
});
/*──────────── callbacks ────────────*/
sink.set_callbacks(
gst_app::AppSinkCallbacks::builder()
@ -113,14 +129,18 @@ pub async fn eye_ear(alsa_dev: &str, id: u32) -> anyhow::Result<AudioStream> {
}
fn build_pipeline_desc(dev: &str) -> anyhow::Result<String> {
use gst::ElementFactory; // <- simpler probe
let enc = ["voaacenc", "avenc_aac", "fdkaacenc"]
.into_iter()
.find(|&e| ElementFactory::find(e).is_some())
.ok_or_else(|| anyhow::anyhow!("no AAC encoder plugin available"))?;
Ok(format!(
"alsasrc name=audsrc device=\"{dev}\" do-timestamp=true ! \
audio/x-raw,channels=2,rate=48000 ! {enc} bitrate=192000 ! \
aacparse ! queue ! appsink name=asink emit-signals=true max-buffers=64 drop=true"
// ➊ provide-clock=false lets the USB gadget be master
// ➋ audioconvert+audioresample make sure caps match encoder
"alsasrc device=\"{dev}\" provide-clock=false do-timestamp=true ! \
audioconvert ! audioresample ! audio/x-raw,channels=2,rate=48000,format=F32LE ! \
{enc} bitrate=192000 ! aacparse ! queue ! \
appsink name=asink emit-signals=true max-buffers=64 drop=true"
))
}

View File

@ -119,7 +119,7 @@ pub async fn eye_ball(
i.error(), i.debug().unwrap_or_default());
}
StateChanged(s) if s.current() == gst::State::Playing => {
info!(target:"lesavka_server::video",
debug!(target:"lesavka_server::video",
eye = %eye_clone,
"🎬 pipeline PLAYING");
}