[pitivi] mediafileprevier: Allow file discovering to be sync
- From: Thibault Saunier <tsaunier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] mediafileprevier: Allow file discovering to be sync
- Date: Mon, 9 Jan 2017 01:30:14 +0000 (UTC)
commit 376d4db929d93bc270d0aee8387438da7758ec88
Author: Thibault Saunier <tsaunier gnome org>
Date: Tue Jan 3 20:18:15 2017 +0000
mediafileprevier: Allow file discovering to be sync
In the special case we are already blocked on the
main mainloop (as we are handling the missing asset failure)
which means that we can not start another ASYNC discovery in GstDicoverer.
In the normal case, discovery is still async.
Also make the GES discovering timeout after 5 seconds only, we should not
block the UI for more than that (default is 60secs in GES).
Fixes T7645
Reviewed-by: Alex Băluț <alexandru balut gmail com>
Differential Revision: https://phabricator.freedesktop.org/D1578
pitivi/check.py | 3 +++
pitivi/mainwindow.py | 2 +-
pitivi/mediafilespreviewer.py | 20 +++++++++++++++-----
3 files changed, 19 insertions(+), 6 deletions(-)
---
diff --git a/pitivi/check.py b/pitivi/check.py
index e05fde4..6a5467a 100644
--- a/pitivi/check.py
+++ b/pitivi/check.py
@@ -327,6 +327,9 @@ def initialize_modules():
from pitivi.configure import get_audiopresets_dir, get_videopresets_dir
Gst.init(None)
+ if not os.environ.get("GES_DISCOVERY_TIMEOUT"):
+ os.environ["GES_DISCOVERY_TIMEOUT"] = "5"
+
require_version("GES", GST_API_VERSION)
from gi.repository import GES
res, sys.argv = GES.init_check(sys.argv)
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index 8f4b3cf..10550c0 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -971,7 +971,7 @@ class MainWindow(Gtk.ApplicationWindow, Loggable):
chooser = Gtk.FileChooserWidget(action=Gtk.FileChooserAction.OPEN)
chooser.set_select_multiple(False)
- previewer = PreviewWidget(self.settings)
+ previewer = PreviewWidget(self.settings, discover_sync=True)
chooser.set_preview_widget(previewer)
chooser.set_use_preview_label(False)
chooser.connect('update-preview', previewer.update_preview_cb)
diff --git a/pitivi/mediafilespreviewer.py b/pitivi/mediafilespreviewer.py
index 6a94433..ab371e0 100644
--- a/pitivi/mediafilespreviewer.py
+++ b/pitivi/mediafilespreviewer.py
@@ -75,7 +75,7 @@ class PreviewWidget(Gtk.Grid, Loggable):
settings (GlobalSettings): The settings of the app.
"""
- def __init__(self, settings, minimal=False):
+ def __init__(self, settings, minimal=False, discover_sync=False):
Gtk.Grid.__init__(self)
Loggable.__init__(self)
@@ -170,6 +170,7 @@ class PreviewWidget(Gtk.Grid, Loggable):
self.bbox.remove(self.b_zoom_out)
self.clear_preview()
+ self._discover_sync = discover_sync
def update_preview_cb(self, file_chooser):
"""Previews the URI of the specified file chooser.
@@ -188,12 +189,18 @@ class PreviewWidget(Gtk.Grid, Loggable):
self.log("Preview request for %s", uri)
self.clear_preview()
self.current_selected_uri = uri
- GES.UriClipAsset.new(uri, None, self.__asset_loaded_cb)
- def __asset_loaded_cb(self, source, res):
- uri = source.get_id()
+ if not self._discover_sync:
+ GES.UriClipAsset.new(uri, None, self.__asset_loaded_cb)
+ else:
+ self._handle_new_asset(uri=uri)
+
+ def _handle_new_asset(self, async_result=None, uri=None):
try:
- asset = GES.Asset.request_finish(res)
+ if uri:
+ asset = GES.UriClipAsset.request_sync(uri)
+ else:
+ asset = GES.Asset.request_finish(async_result)
except GLib.Error as error:
self.log("Failed discovering %s: %s", uri, error.message)
self._show_error(error.message)
@@ -206,6 +213,9 @@ class PreviewWidget(Gtk.Grid, Loggable):
self.play_on_discover = False
self.play()
+ def __asset_loaded_cb(self, source, res):
+ self._handle_new_asset(async_result=res)
+
def _show_preview(self, uri, info):
self.log("Show preview for %s", uri)
duration = info.get_duration()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]