[pitivi] pipeline: Allow pipeline to wait to be ready for querying position



commit 3ddcbf9990ddd9c04cd17f33a6661ea7d7652132
Author: Thibault Saunier <tsaunier gnome org>
Date:   Fri Jul 17 00:36:53 2015 +0200

    pipeline: Allow pipeline to wait to be ready for querying position
    
    Summary:
    And make use of it when getting poisition before trimming
    clips and setting the special previewing pipeline
    
    Depends on D262
    
    Reviewers: Mathieu_Du, aleb
    
    Differential Revision: https://phabricator.freedesktop.org/D263

 pitivi/utils/pipeline.py |    8 +++++++-
 pitivi/viewer.py         |    2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/pitivi/utils/pipeline.py b/pitivi/utils/pipeline.py
index d95d051..87cdd71 100644
--- a/pitivi/utils/pipeline.py
+++ b/pitivi/utils/pipeline.py
@@ -299,7 +299,7 @@ class SimplePipeline(GObject.Object, Loggable):
 
     # Position and Seeking methods
 
-    def getPosition(self):
+    def getPosition(self, blocks=False):
         """
         Get the current position of the L{Pipeline}.
 
@@ -307,6 +307,12 @@ class SimplePipeline(GObject.Object, Loggable):
         @rtype: L{long}
         @raise PipelineError: If the position couldn't be obtained.
         """
+        maincontext = GLib.main_context_default()
+        if blocks and self._recovery_state == self.RecoveryState.NOT_RECOVERING:
+            while self._waiting_for_async_done and self._recovery_state == self.RecoveryState.NOT_RECOVERING:
+                self.info("Iterating mainloop waiting for the pipeline to be ready to be queried")
+                maincontext.iteration(True)
+
         try:
             res, cur = self._pipeline.query_position(Gst.Format.TIME)
         except Exception as e:
diff --git a/pitivi/viewer.py b/pitivi/viewer.py
index eff8627..271542b 100644
--- a/pitivi/viewer.py
+++ b/pitivi/viewer.py
@@ -425,7 +425,7 @@ class ViewerContainer(Gtk.Box, Loggable):
         if self.pipeline == self.app.project_manager.current_project.pipeline:
             self.debug("Creating temporary pipeline for clip %s, position %s",
                        clip_uri, format_ns(position))
-            self._oldTimelinePos = self.pipeline.getPosition()
+            self._oldTimelinePos = self.pipeline.getPosition(True)
             self.pipeline.set_state(Gst.State.NULL)
             self.setPipeline(AssetPipeline(clip))
             self._lastClipTrimTime = cur_time


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