commit
1f4d7b04c9
3 changed files with 32 additions and 13 deletions
|
|
@ -504,7 +504,13 @@ fn input_stream_worker(
|
||||||
.unwrap_or(PollDescriptorsFlow::Continue);
|
.unwrap_or(PollDescriptorsFlow::Continue);
|
||||||
|
|
||||||
match flow {
|
match flow {
|
||||||
PollDescriptorsFlow::Continue => continue,
|
PollDescriptorsFlow::Continue => {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
PollDescriptorsFlow::XRun => {
|
||||||
|
report_error(stream.channel.prepare(), error_callback);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
PollDescriptorsFlow::Return => return,
|
PollDescriptorsFlow::Return => return,
|
||||||
PollDescriptorsFlow::Ready {
|
PollDescriptorsFlow::Ready {
|
||||||
status,
|
status,
|
||||||
|
|
@ -545,7 +551,14 @@ fn output_stream_worker(
|
||||||
.unwrap_or(PollDescriptorsFlow::Continue);
|
.unwrap_or(PollDescriptorsFlow::Continue);
|
||||||
|
|
||||||
match flow {
|
match flow {
|
||||||
PollDescriptorsFlow::Continue => continue,
|
PollDescriptorsFlow::Continue => {
|
||||||
|
report_error(stream.channel.prepare(), error_callback);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
PollDescriptorsFlow::XRun => {
|
||||||
|
report_error(stream.channel.prepare(), error_callback);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
PollDescriptorsFlow::Return => return,
|
PollDescriptorsFlow::Return => return,
|
||||||
PollDescriptorsFlow::Ready {
|
PollDescriptorsFlow::Ready {
|
||||||
status,
|
status,
|
||||||
|
|
@ -598,6 +611,7 @@ enum PollDescriptorsFlow {
|
||||||
avail_frames: usize,
|
avail_frames: usize,
|
||||||
delay_frames: usize,
|
delay_frames: usize,
|
||||||
},
|
},
|
||||||
|
XRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
// This block is shared between both input and output stream worker functions.
|
// This block is shared between both input and output stream worker functions.
|
||||||
|
|
@ -656,7 +670,12 @@ fn poll_descriptors_and_prepare_buffer(
|
||||||
};
|
};
|
||||||
|
|
||||||
let status = stream.channel.status()?;
|
let status = stream.channel.status()?;
|
||||||
let avail_frames = status.get_avail() as usize;
|
let avail_frames = match stream.channel.avail() {
|
||||||
|
Err(err) if err.errno() == Some(nix::errno::Errno::EPIPE) => {
|
||||||
|
return Ok(PollDescriptorsFlow::XRun)
|
||||||
|
}
|
||||||
|
res => res,
|
||||||
|
}? as usize;
|
||||||
let delay_frames = match status.get_delay() {
|
let delay_frames = match status.get_delay() {
|
||||||
// Buffer underrun. TODO: Notify the user.
|
// Buffer underrun. TODO: Notify the user.
|
||||||
d if d < 0 => 0,
|
d if d < 0 => 0,
|
||||||
|
|
|
||||||
|
|
@ -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