Restrict the format to 2 channels

This commit is contained in:
Pierre Krieger 2015-09-27 14:31:23 +02:00
parent d920872bb1
commit 53143b5f02

View file

@ -75,29 +75,14 @@ impl Engine {
let f1 = f1.unwrap(); let f1 = f1.unwrap();
// we privilege f32 formats to avoid a conversion // we privilege f32 formats to avoid a conversion
if f1.data_type == cpal::SampleFormat::F32 && f2.data_type != cpal::SampleFormat::F32 {
return Some(f1);
}
if f2.data_type == cpal::SampleFormat::F32 && f1.data_type != cpal::SampleFormat::F32 { if f2.data_type == cpal::SampleFormat::F32 && f1.data_type != cpal::SampleFormat::F32 {
return Some(f2); return Some(f2);
} }
if f1.channels.len() < f2.channels.len() { // priviledge outputs with 2 channels for now
if f2.channels.len() == 2 && f1.channels.len() != 2 {
return Some(f2); return Some(f2);
} }
if f2.channels.len() < f1.channels.len() {
return Some(f1);
}
if f2.channels.len() > 7 { // TODO: not proper
return Some(f1);
}
if f1.samples_rate.0 < 44100 && f2.samples_rate.0 >= 44100 {
return Some(f2);
}
if f2.samples_rate.0 < 44100 && f1.samples_rate.0 >= 44100 {
return Some(f1);
}
Some(f1) Some(f1)
}).expect("The endpoint doesn't support any format!?"); }).expect("The endpoint doesn't support any format!?");