Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrançois Laignel <fengalin@free.fr>2020-10-19 18:03:10 +0300
committerFrançois Laignel <fengalin@free.fr>2020-10-21 00:45:01 +0300
commit7c3e69bb4aba6e3a5da95e3c610b85d5b629fb72 (patch)
tree47bfcd0c119d68c7c23bf36cb03bf4e0d11d8244 /generic/threadshare/src/jitterbuffer/jitterbuffer.rs
parentbbc18d6349aaaabd9ae43a08c3874718a929e12b (diff)
Fix ClockTime comparisons not being Ord and use saturating_sub
See: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/607
Diffstat (limited to 'generic/threadshare/src/jitterbuffer/jitterbuffer.rs')
-rw-r--r--generic/threadshare/src/jitterbuffer/jitterbuffer.rs23
1 files changed, 11 insertions, 12 deletions
diff --git a/generic/threadshare/src/jitterbuffer/jitterbuffer.rs b/generic/threadshare/src/jitterbuffer/jitterbuffer.rs
index 7191d90b5..3579f9f3a 100644
--- a/generic/threadshare/src/jitterbuffer/jitterbuffer.rs
+++ b/generic/threadshare/src/jitterbuffer/jitterbuffer.rs
@@ -295,9 +295,10 @@ impl SinkHandler {
let new_packet_spacing = pts - inner.ips_pts;
let old_packet_spacing = state.packet_spacing;
+ assert!(old_packet_spacing.is_some());
if old_packet_spacing > new_packet_spacing {
state.packet_spacing = (new_packet_spacing + 3 * old_packet_spacing) / 4;
- } else if old_packet_spacing > gst::ClockTime(Some(0)) {
+ } else if !old_packet_spacing.is_zero() {
state.packet_spacing = (3 * new_packet_spacing + old_packet_spacing) / 4;
} else {
state.packet_spacing = new_packet_spacing;
@@ -412,13 +413,13 @@ impl SinkHandler {
pt
);
- if dts == gst::CLOCK_TIME_NONE {
+ if dts.is_none() {
dts = pts;
- } else if pts == gst::CLOCK_TIME_NONE {
+ } else if pts.is_none() {
pts = dts;
}
- if dts == gst::CLOCK_TIME_NONE {
+ if dts.is_none() {
dts = element.get_current_running_time();
pts = dts;
@@ -957,13 +958,11 @@ impl SrcHandler {
let next_wakeup = state.earliest_pts + latency - state.packet_spacing - context_wait / 2;
- let delay = {
- if next_wakeup > now {
- (next_wakeup - now).nseconds().unwrap()
- } else {
- 0
- }
- };
+ let delay = next_wakeup
+ .saturating_sub(now)
+ .unwrap_or_else(gst::ClockTime::zero)
+ .nseconds()
+ .unwrap();
gst_debug!(
CAT,
@@ -1121,7 +1120,7 @@ impl Default for State {
segment: gst::FormattedSegment::<gst::ClockTime>::new(),
clock_rate: None,
- packet_spacing: gst::ClockTime(Some(0)),
+ packet_spacing: gst::ClockTime::zero(),
equidistant: 0,
discont: true,