Merge pull request #474 from rfwatson/webaudio-default-output-device
webaudio: Fix default_output_config
This commit is contained in:
commit
c65fa84c24
2 changed files with 10 additions and 10 deletions
|
|
@ -103,13 +103,13 @@ impl Device {
|
||||||
|
|
||||||
fn default_output_config(&self) -> Result<SupportedStreamConfig, DefaultStreamConfigError> {
|
fn default_output_config(&self) -> Result<SupportedStreamConfig, DefaultStreamConfigError> {
|
||||||
const EXPECT: &str = "expected at least one valid webaudio stream config";
|
const EXPECT: &str = "expected at least one valid webaudio stream config";
|
||||||
let mut configs: Vec<_> = self.supported_output_configs().expect(EXPECT).collect();
|
let config = self
|
||||||
configs.sort_by(|a, b| a.cmp_default_heuristics(b));
|
.supported_output_configs()
|
||||||
let config = configs
|
|
||||||
.into_iter()
|
|
||||||
.next()
|
|
||||||
.expect(EXPECT)
|
.expect(EXPECT)
|
||||||
|
.max_by(|a, b| a.cmp_default_heuristics(b))
|
||||||
|
.unwrap()
|
||||||
.with_sample_rate(DEFAULT_SAMPLE_RATE);
|
.with_sample_rate(DEFAULT_SAMPLE_RATE);
|
||||||
|
|
||||||
Ok(config)
|
Ok(config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,13 +121,13 @@ impl Device {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn default_output_config(&self) -> Result<SupportedStreamConfig, DefaultStreamConfigError> {
|
fn default_output_config(&self) -> Result<SupportedStreamConfig, DefaultStreamConfigError> {
|
||||||
const EXPECT: &str = "expected at least one valid webaudio stream config";
|
const EXPECT: &str = "expected at least one valid webaudio stream config";
|
||||||
let mut configs: Vec<_> = self.supported_output_configs().expect(EXPECT).collect();
|
let config = self
|
||||||
configs.sort_by(|a, b| a.cmp_default_heuristics(b));
|
.supported_output_configs()
|
||||||
let config = configs
|
|
||||||
.into_iter()
|
|
||||||
.next()
|
|
||||||
.expect(EXPECT)
|
.expect(EXPECT)
|
||||||
|
.max_by(|a, b| a.cmp_default_heuristics(b))
|
||||||
|
.unwrap()
|
||||||
.with_sample_rate(DEFAULT_SAMPLE_RATE);
|
.with_sample_rate(DEFAULT_SAMPLE_RATE);
|
||||||
|
|
||||||
Ok(config)
|
Ok(config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue