Merge pull request #33 from tomaka/better-format-choice

Restrict the format to 2 channels
This commit is contained in:
tomaka 2015-09-27 14:39:00 +02:00
commit 7dd34496b7

View file

@ -75,29 +75,14 @@ impl Engine {
let f1 = f1.unwrap();
// 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 {
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);
}
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)
}).expect("The endpoint doesn't support any format!?");