mirror of
https://github.com/RustAudio/rodio
synced 2024-12-13 13:42:34 +00:00
Merge pull request #33 from tomaka/better-format-choice
Restrict the format to 2 channels
This commit is contained in:
commit
7dd34496b7
1 changed files with 2 additions and 17 deletions
|
@ -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!?");
|
||||
|
|
Loading…
Reference in a new issue