[pitivi: 7/10] Block video pads to prepare for seeking only once they are negotiated. Fixes #611761.



commit 023931ada21b9ce2ff702e9b1f8fcf847b9fee58
Author: Alessandro Decina <alessandro d gmail com>
Date:   Fri Mar 5 00:10:32 2010 +0100

    Block video pads to prepare for seeking only once they are negotiated. Fixes #611761.

 pitivi/discoverer.py |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/pitivi/discoverer.py b/pitivi/discoverer.py
index 3a647f4..9ec475e 100644
--- a/pitivi/discoverer.py
+++ b/pitivi/discoverer.py
@@ -541,6 +541,22 @@ class Discoverer(Signallable, Loggable):
         if blocked:
             gobject.timeout_add(0, self._videoPadSeekCb, pad)
 
+    def _addVideoBufferProbe(self, pad):
+        closure = {}
+        closure['probe_id'] = pad.add_buffer_probe(self._videoBufferProbeCb,
+                closure)
+
+    def _removeVideoBufferProbe(self, pad, closure):
+        pad.remove_buffer_probe(closure['probe_id'])
+
+    def _videoBufferProbeCb(self, pad, buf, closure):
+        self.debug("video buffer probe for pad %s", pad)
+        self._removeVideoBufferProbe(pad, closure)
+
+        pad.set_blocked_async(True, self._videoPadBlockCb)
+
+        return False
+
     def _newVideoPadCb(self, pad):
         """ a new video pad was found """
         self.debug("pad %r", pad)
@@ -549,8 +565,6 @@ class Discoverer(Signallable, Loggable):
         self.thumbnails[pad] = thumbnail
         have_thumbnail = os.path.exists(thumbnail)
 
-        pad.set_blocked_async(True, self._videoPadBlockCb)
-
         if have_thumbnail:
             self.debug("we already have a thumbnail %s for %s", thumbnail, pad)
             sink = gst.element_factory_make("fakesink")
@@ -565,6 +579,10 @@ class Discoverer(Signallable, Loggable):
 
             return
 
+        stream = get_stream_for_pad(pad)
+        if isinstance(stream, VideoStream) and not stream.is_image:
+            self._addVideoBufferProbe(pad)
+
         queue = gst.element_factory_make("queue")
         queue.props.max_size_bytes = 5 * 1024 * 1024
         queue.props.max_size_time = 5 * gst.SECOND



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