diff --git a/playback/src/audio_backend/gstreamer.rs b/playback/src/audio_backend/gstreamer.rs index 3695857e..d3c736a4 100644 --- a/playback/src/audio_backend/gstreamer.rs +++ b/playback/src/audio_backend/gstreamer.rs @@ -26,10 +26,12 @@ impl Open for GstreamerSink { AudioFormat::S24_3 => "S24".to_string(), _ => format!("{:?}", format), }; + let sample_size = format.size(); + let gst_bytes = 2048 * sample_size; let pipeline_str_preamble = format!( - "appsrc caps=\"audio/x-raw,format={}LE,layout=interleaved,channels={},rate={}\" block=true max-bytes=4096 name=appsrc0 ", - gst_format, NUM_CHANNELS, SAMPLE_RATE + "appsrc caps=\"audio/x-raw,format={}LE,layout=interleaved,channels={},rate={}\" block=true max-bytes={} name=appsrc0 ", + gst_format, NUM_CHANNELS, SAMPLE_RATE, gst_bytes ); let pipeline_str_rest = r#" ! audioconvert ! autoaudiosink"#; let pipeline_str: String = match device { @@ -54,7 +56,7 @@ impl Open for GstreamerSink { let bufferpool = gst::BufferPool::new(); let appsrc_caps = appsrc.get_caps().expect("couldn't get appsrc caps"); let mut conf = bufferpool.get_config(); - conf.set_params(Some(&appsrc_caps), 2048 * format.size() as u32, 0, 0); + conf.set_params(Some(&appsrc_caps), 4096 * sample_size as u32, 0, 0); bufferpool .set_config(conf) .expect("couldn't configure the buffer pool"); @@ -62,7 +64,7 @@ impl Open for GstreamerSink { .set_active(true) .expect("couldn't activate buffer pool"); - let (tx, rx) = sync_channel::>(64 * format.size()); + let (tx, rx) = sync_channel::>(64 * sample_size); thread::spawn(move || { for data in rx { let buffer = bufferpool.acquire_buffer(None);