ALSA: Don't panic when handling invalid stream timestamps. (#886)
This commit is contained in:
parent
8615160344
commit
0246442da2
1 changed files with 8 additions and 4 deletions
|
|
@ -872,19 +872,23 @@ fn stream_timestamp(
|
||||||
let ts = status.get_htstamp();
|
let ts = status.get_htstamp();
|
||||||
let nanos = timespec_diff_nanos(ts, trigger_ts);
|
let nanos = timespec_diff_nanos(ts, trigger_ts);
|
||||||
if nanos < 0 {
|
if nanos < 0 {
|
||||||
panic!(
|
let description = format!(
|
||||||
"get_htstamp `{}.{}` was earlier than get_trigger_htstamp `{}.{}`",
|
"get_htstamp `{}.{}` was earlier than get_trigger_htstamp `{}.{}`",
|
||||||
ts.tv_sec, ts.tv_nsec, trigger_ts.tv_sec, trigger_ts.tv_nsec
|
ts.tv_sec, ts.tv_nsec, trigger_ts.tv_sec, trigger_ts.tv_nsec
|
||||||
);
|
);
|
||||||
|
return Err(BackendSpecificError { description });
|
||||||
}
|
}
|
||||||
Ok(crate::StreamInstant::from_nanos(nanos))
|
Ok(crate::StreamInstant::from_nanos(nanos))
|
||||||
}
|
}
|
||||||
Some(creation) => {
|
Some(creation) => {
|
||||||
let now = std::time::Instant::now();
|
let now = std::time::Instant::now();
|
||||||
let duration = now.duration_since(creation);
|
let duration = now.duration_since(creation);
|
||||||
let instant = crate::StreamInstant::from_nanos_i128(duration.as_nanos() as i128)
|
crate::StreamInstant::from_nanos_i128(duration.as_nanos() as i128).ok_or(
|
||||||
.expect("stream duration has exceeded `StreamInstant` representation");
|
BackendSpecificError {
|
||||||
Ok(instant)
|
description: "stream duration has exceeded `StreamInstant` representation"
|
||||||
|
.to_string(),
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue