[pitivi] Expect ASYNC_DONE after commiting
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Expect ASYNC_DONE after commiting
- Date: Sat, 13 Dec 2014 19:11:21 +0000 (UTC)
commit f7c819fe3a0d805c65b0bdb0f100db8e0ccbe82b
Author: Thibault Saunier <tsaunier gnome org>
Date: Sun Nov 30 22:02:03 2014 +0100
Expect ASYNC_DONE after commiting
And make sure no seek is launch meanwhile otherwise bad things can
happen
pitivi/timeline/controls.py | 2 +-
pitivi/timeline/timeline.py | 22 +++++++++++-----------
pitivi/utils/pipeline.py | 35 +++++++++++++++++++++++++++++++++++
pitivi/utils/timeline.py | 2 +-
4 files changed, 48 insertions(+), 13 deletions(-)
---
diff --git a/pitivi/timeline/controls.py b/pitivi/timeline/controls.py
index e443bad..7e37b94 100644
--- a/pitivi/timeline/controls.py
+++ b/pitivi/timeline/controls.py
@@ -143,7 +143,7 @@ class ControlContainer(Clutter.ScrollActor):
movedLayer.props.priority = target
self._reorderLayerActors()
- self.timeline.bTimeline.commit()
+ self.timeline.bTimeline.get_asset().pipeline.commit_timeline()
def addTrackControl(self, layer, is_audio):
if is_audio:
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index f393a11..af06746 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -213,7 +213,7 @@ class TimelineStage(Clutter.ScrollActor, Zoomable, Loggable):
layer = self.bTimeline.append_layer()
layer.props.priority = ghostclip.priority
- self.bTimeline.commit()
+ self._project.pipeline.commit_timeline()
self._container.controls._reorderLayerActors()
return layer
@@ -272,7 +272,7 @@ class TimelineStage(Clutter.ScrollActor, Zoomable, Loggable):
clip_duration,
ghostclip.asset.get_supported_formats())
placement += clip_duration
- self.bTimeline.commit()
+ self._project.pipeline.commit_timeline()
def _getLayerForGhostClip(self, ghostclip):
"""
@@ -293,7 +293,7 @@ class TimelineStage(Clutter.ScrollActor, Zoomable, Loggable):
for ghostclip in ghostCouple:
if ghostclip and ghostclip.get_parent():
self.remove_child(ghostclip)
- self.bTimeline.commit()
+ self._project.pipeline.commit_timeline()
def getActorUnderPointer(self):
return self.mouse.get_pointer_actor()
@@ -738,7 +738,7 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
Zoomable.nsToPixel(self.bTimeline.props.duration))
self.app.action_log.commit()
- self.bTimeline.commit()
+ self._project.pipeline.commit_timeline()
def purgeObject(self, asset_id):
"""Remove all instances of an asset from the timeline."""
@@ -747,7 +747,7 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
for tlobj in layer.get_clips():
if asset_id == tlobj.get_id():
layer.remove_clip(tlobj)
- self.bTimeline.commit()
+ self._project.pipeline.commit_timeline()
def setProjectManager(self, projectmanager):
if self._projectmanager is not None:
@@ -1173,7 +1173,7 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
layer = clip.get_layer()
layer.remove_clip(clip)
- self.bTimeline.commit()
+ self._project.pipeline.commit_timeline()
self.app.action_log.commit()
def _ungroupSelected(self, unused_action):
@@ -1193,12 +1193,12 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
for container in containers:
GES.Container.ungroup(container, False)
- self.timeline.bTimeline.commit()
+ self._project.pipeline.commit_timeline()
self.timeline.createSelectionGroup()
self.app.action_log.commit()
- self.bTimeline.commit()
+ self._project.pipeline.commit_timeline()
def _groupSelected(self, unused_action):
if self.bTimeline:
@@ -1219,7 +1219,7 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
group = GES.Container.group(list(containers))
self.timeline.createSelectionGroup()
- self.bTimeline.commit()
+ self._project.pipeline.commit_timeline()
self.app.action_log.commit()
def _alignSelected(self, unused_action):
@@ -1234,7 +1234,7 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
def alignedCb(): # Called when alignment is complete
self.app.action_log.commit()
- self.bTimeline.commit()
+ self._project.pipeline.commit_timeline()
progress_dialog.window.destroy()
auto_aligner = AutoAligner(self.timeline.selection, alignedCb)
@@ -1258,7 +1258,7 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
for track in self.bTimeline.get_tracks():
self._splitElements(track.get_elements())
- self.bTimeline.commit()
+ self._project.pipeline.commit_timeline()
def _splitElements(self, elements):
position = self._project.pipeline.getPosition()
diff --git a/pitivi/utils/pipeline.py b/pitivi/utils/pipeline.py
index 3b1ccbf..60ca758 100644
--- a/pitivi/utils/pipeline.py
+++ b/pitivi/utils/pipeline.py
@@ -589,6 +589,9 @@ class Pipeline(GES.Pipeline, SimplePipeline):
self.app = app
+ self._was_empty = False
+ self._commit_wanted = False
+
self._timeline = None
self._seeker = Seeker()
self._seeker.connect("seek", self._seekCb)
@@ -670,3 +673,35 @@ class Pipeline(GES.Pipeline, SimplePipeline):
self.app.write_action(st)
SimplePipeline.simple_seek(self, position)
+
+ def _busMessageCb(self, bus, message):
+ if message.type == Gst.MessageType.ASYNC_DONE and\
+ self._commit_wanted:
+ self.debug("Commiting now that ASYNC is DONE")
+ self._addWaitingForAsyncDoneTimeout()
+ self._timeline.commit()
+ self._commit_wanted = False
+ else:
+ super(Pipeline, self)._busMessageCb(bus, message)
+
+ def commit_timeline(self):
+ if self._waiting_for_async_done and not self._was_empty\
+ and not self._timeline.is_empty():
+ self._commit_wanted = True
+ self._was_empty = False
+ self.debug("commit wanted")
+ else:
+ self._addWaitingForAsyncDoneTimeout()
+ self._timeline.commit()
+ self.debug("Commiting right now")
+ if self._timeline.is_empty():
+ self._was_empty = True
+ else:
+ self._was_empty = False
+
+ def setState(self, state):
+ super(Pipeline, self).setState(state)
+ if state >= Gst.State.PAUSED and self._timeline.is_empty():
+ self.debug("No ASYNC_DONE will be emited on empty timelines")
+ self._was_empty = True
+ self._removeWaitingForAsyncDoneTimeout()
diff --git a/pitivi/utils/timeline.py b/pitivi/utils/timeline.py
index b77f606..a4d3dea 100644
--- a/pitivi/utils/timeline.py
+++ b/pitivi/utils/timeline.py
@@ -252,7 +252,7 @@ class EditingContext(GObject.Object):
def finish(self):
self.action_log.commit()
- self.timeline.commit()
+ self.timeline.get_asset().pipeline.commit_timeline()
self.emit("clip-trim-finished")
def setMode(self, mode):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]