[pitivi] pipeline: Remove seek on_idle functionality



commit 6dec3531743517ec7df16ce253654c320b85698d
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Fri Nov 13 12:16:32 2015 +0100

    pipeline: Remove seek on_idle functionality
    
    "The proper thing is done in the pipeline."
    
    Reviewed-by: Thibault Saunier <tsaunier gnome org>
    Differential Revision: https://phabricator.freedesktop.org/D564

 pitivi/timeline/ruler.py |    4 +-
 pitivi/utils/pipeline.py |   88 +++++++++------------------------------------
 2 files changed, 20 insertions(+), 72 deletions(-)
---
diff --git a/pitivi/timeline/ruler.py b/pitivi/timeline/ruler.py
index 99b4e61..52af7ff 100644
--- a/pitivi/timeline/ruler.py
+++ b/pitivi/timeline/ruler.py
@@ -190,7 +190,7 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
     def do_button_press_event(self, event):
         self.debug("button pressed at x:%d", event.x)
         position = self.pixelToNs(event.x + self.pixbuf_offset)
-        self._seeker.seek(position, on_idle=True)
+        self._seeker.seek(position)
         return False
 
     def do_button_release_event(self, event):
@@ -204,7 +204,7 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
                      Gdk.ModifierType.BUTTON1_MASK)
         if event.state & seek_mask:
             self.debug("motion at event.x %d", event.x)
-            self._seeker.seek(position, on_idle=True)
+            self._seeker.seek(position)
 
         human_time = beautify_length(position)
         cur_frame = int(position / self.ns_per_frame) + 1
diff --git a/pitivi/utils/pipeline.py b/pitivi/utils/pipeline.py
index a7e0b30..c7323aa 100644
--- a/pitivi/utils/pipeline.py
+++ b/pitivi/utils/pipeline.py
@@ -80,79 +80,27 @@ class Seeker(GObject.Object, Loggable):
             cls._instance = super(Seeker, cls).__new__(cls, *args, **kwargs)
         return cls._instance
 
-    def __init__(self, timeout=80):
-        """
-        @param timeout (optional): the amount of miliseconds for a seek attempt
-        """
+    def __init__(self):
         GObject.Object.__init__(self)
         Loggable.__init__(self)
 
-        self.timeout = timeout
-        self.pending_seek_id = None
-        self.position = None
-        self._time = None
-        self.pending_position = None
-
-    def seek(self, position, on_idle=False):
-        self.position = position
-
-        if self.pending_seek_id is None:
-            if on_idle:
-                self.pending_seek_id = self._scheduleSeek(
-                    self.timeout, self._seekTimeoutCb, relative=False)
-            else:
-                self._seek(relative=False)
-        else:
-            self.pending_position = position
-
-    def seekRelative(self, time, on_idle=False):
-        if self.pending_seek_id is None:
-            self._time = int(time)
-            if on_idle:
-                self.pending_seek_id = self._scheduleSeek(
-                    self.timeout, self._seekTimeoutCb, relative=True)
-            else:
-                self._seek(relative=True)
-
-    def flush(self, on_idle=False):
-        self.seekRelative(0, on_idle)
-
-    def _scheduleSeek(self, timeout, callback, relative=False):
-        return GLib.timeout_add(timeout, callback, relative)
-
-    def _seekTimeoutCb(self, relative):
-        self._seek(relative)
-
-    def _seek(self, relative):
-        self.pending_seek_id = None
-
-        if relative:
-            try:
-                self.emit('seek-relative', self._time)
-            except PipelineError:
-                self.error("Error while seeking %s relative", self._time)
-                # if an exception happened while seeking, properly
-                # reset ourselves
-                return False
-
-            self._time = None
-        elif self.position is not None:
-            position = max(0, self.position)
-            self.position = None
-            try:
-                self.emit('seek', position)
-            except PipelineError as e:
-                self.error("Error while seeking to position: %s, reason: %s",
-                           format_ns(position), e)
-                # if an exception happened while seeking, properly
-                # reset ourselves
-                return False
+    def seek(self, position):
+        position = max(0, position)
+        try:
+            self.emit('seek', position)
+        except PipelineError as e:
+            self.error("Error while seeking to position: %s, reason: %s",
+                       format_ns(position), e)
 
-        if self.pending_position:
-            self.seek(self.pending_position, on_idle=True)
-            self.pending_position = None
+    def seekRelative(self, time):
+        time = int(time)
+        try:
+            self.emit('seek-relative', time)
+        except PipelineError:
+            self.error("Error while seeking %s relative", time)
 
-        return False
+    def flush(self):
+        self.seekRelative(0)
 
 
 class SimplePipeline(GObject.Object, Loggable):


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