[pitivi] pipeline: Fix infinite loop when a seek times out



commit c1985ca3c5b9b1035a40e54322d202eb29d824e3
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Tue Mar 14 23:15:23 2017 +0100

    pipeline: Fix infinite loop when a seek times out
    
    When simple_seek was called and the operation was "successful", it was
    setting the _last_position field. Then if the async operation timed out,
    a recover cycle was being started and most probably the pipeline was
    being set to PAUSED fine, then a new seek was attempted .. at
    _last_position, then again and again.
    
    The meaning of _last_position is clarified in this commit to be the last
    position obtained successfully from the pipeline, so that such infinite
    cycles cannot appear anymore.
    
    Reviewed-by: Thibault Saunier <tsaunier gnome org>
    Differential Revision: https://phabricator.freedesktop.org/D1691

 pitivi/utils/pipeline.py |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/pitivi/utils/pipeline.py b/pitivi/utils/pipeline.py
index 13ad99c..1530c6d 100644
--- a/pitivi/utils/pipeline.py
+++ b/pitivi/utils/pipeline.py
@@ -91,7 +91,8 @@ class SimplePipeline(GObject.Object, Loggable):
         self._listeningInterval = DEFAULT_POSITION_LISTENNING_INTERVAL
         self._listeningSigId = 0
         self._duration = Gst.CLOCK_TIME_NONE
-        self._last_position = int(0 * Gst.SECOND)
+        # The last known position.
+        self._last_position = 0 * Gst.SECOND
         self._recovery_state = self.RecoveryState.NOT_RECOVERING
         self._attempted_recoveries = 0
         self._next_seek = None
@@ -224,7 +225,9 @@ class SimplePipeline(GObject.Object, Loggable):
             self.handleException(e)
             raise PipelineError("Couldn't get position")
 
-        if not res:
+        if res:
+            self._last_position = cur
+        else:
             if fails:
                 raise PipelineError("Position not available")
 
@@ -275,8 +278,7 @@ class SimplePipeline(GObject.Object, Loggable):
                 self.warning("Could not get position because: %s", e)
             else:
                 if position != Gst.CLOCK_TIME_NONE:
-                    self.emit('position', position)
-                    self._last_position = position
+                    self.emit("position", position)
         finally:
             return True
 
@@ -358,7 +360,6 @@ class SimplePipeline(GObject.Object, Loggable):
             raise PipelineError(self.get_name() + " seek failed: " + str(position))
 
         self._addWaitingForAsyncDoneTimeout()
-        self._last_position = position
 
         self.debug("seeking successful")
         self.emit('position', position)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]