mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Fix GStreamer buffer pool size [ref #660 review]
This commit is contained in:
parent
770ea15498
commit
b94879de62
1 changed files with 6 additions and 4 deletions
|
@ -26,10 +26,12 @@ impl Open for GstreamerSink {
|
||||||
AudioFormat::S24_3 => "S24".to_string(),
|
AudioFormat::S24_3 => "S24".to_string(),
|
||||||
_ => format!("{:?}", format),
|
_ => format!("{:?}", format),
|
||||||
};
|
};
|
||||||
|
let sample_size = format.size();
|
||||||
|
let gst_bytes = 2048 * sample_size;
|
||||||
|
|
||||||
let pipeline_str_preamble = format!(
|
let pipeline_str_preamble = format!(
|
||||||
"appsrc caps=\"audio/x-raw,format={}LE,layout=interleaved,channels={},rate={}\" block=true max-bytes=4096 name=appsrc0 ",
|
"appsrc caps=\"audio/x-raw,format={}LE,layout=interleaved,channels={},rate={}\" block=true max-bytes={} name=appsrc0 ",
|
||||||
gst_format, NUM_CHANNELS, SAMPLE_RATE
|
gst_format, NUM_CHANNELS, SAMPLE_RATE, gst_bytes
|
||||||
);
|
);
|
||||||
let pipeline_str_rest = r#" ! audioconvert ! autoaudiosink"#;
|
let pipeline_str_rest = r#" ! audioconvert ! autoaudiosink"#;
|
||||||
let pipeline_str: String = match device {
|
let pipeline_str: String = match device {
|
||||||
|
@ -54,7 +56,7 @@ impl Open for GstreamerSink {
|
||||||
let bufferpool = gst::BufferPool::new();
|
let bufferpool = gst::BufferPool::new();
|
||||||
let appsrc_caps = appsrc.get_caps().expect("couldn't get appsrc caps");
|
let appsrc_caps = appsrc.get_caps().expect("couldn't get appsrc caps");
|
||||||
let mut conf = bufferpool.get_config();
|
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
|
bufferpool
|
||||||
.set_config(conf)
|
.set_config(conf)
|
||||||
.expect("couldn't configure the buffer pool");
|
.expect("couldn't configure the buffer pool");
|
||||||
|
@ -62,7 +64,7 @@ impl Open for GstreamerSink {
|
||||||
.set_active(true)
|
.set_active(true)
|
||||||
.expect("couldn't activate buffer pool");
|
.expect("couldn't activate buffer pool");
|
||||||
|
|
||||||
let (tx, rx) = sync_channel::<Vec<u8>>(64 * format.size());
|
let (tx, rx) = sync_channel::<Vec<u8>>(64 * sample_size);
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
for data in rx {
|
for data in rx {
|
||||||
let buffer = bufferpool.acquire_buffer(None);
|
let buffer = bufferpool.acquire_buffer(None);
|
||||||
|
|
Loading…
Reference in a new issue