limit task progress ratio range

to prevent ui crashes when the progress data requested from gstreamer is somehow broken
This commit is contained in:
2020-12-19 16:08:08 +01:00
parent 29a4ca3220
commit b673526098

View File

@@ -454,11 +454,18 @@ async fn transcode(
.and_then(|time| time.nanoseconds()); .and_then(|time| time.nanoseconds());
let ratio = dur.and_then(|dur| { let ratio = dur.and_then(|dur| {
if dur == 0 {
return None;
}
let pos = decodebin let pos = decodebin
.query_position::<ClockTime>() .query_position::<ClockTime>()
.and_then(|time| time.nanoseconds()); .and_then(|time| time.nanoseconds());
pos.map(|pos| pos as f64 / dur as f64) pos.map(|pos| {
let ratio = pos as f64 / dur as f64;
ratio.max(0.0).min(1.0)
})
}); });
if let Some(ratio) = ratio { if let Some(ratio) = ratio {