[gnome-music] player: Check GstElement query success
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] player: Check GstElement query success
- Date: Mon, 13 Feb 2017 21:30:49 +0000 (UTC)
commit 9c2f0ab517ece5e450c04bfe0877b0a0b439f666
Author: theawless <theawless gmail com>
Date: Sat Jan 21 17:31:13 2017 +0530
player: Check GstElement query success
If the gstreamer pipeline duration query (song length) fails then there
is the possibility that duration returns a negative value and hence
calls to GLib.timeout_add with this value crash the application. The
query also returns a boolean indicating success, use it to make sure we
get a valid duration or use a set positive value instead.
https://bugzilla.gnome.org/show_bug.cgi?id=777541
gnomemusic/player.py | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 2b9ca44..1a68a38 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -867,8 +867,10 @@ class Player(GObject.GObject):
padding = self.progressScale.get_style_context().get_padding(
Gtk.StateFlags.NORMAL)
width -= padding.left + padding.right
- duration = self.player.query_duration(Gst.Format.TIME)[1] / 10**9
- timeout_period = min(1000 * duration // width, 1000)
+ success, duration = self.player.query_duration(Gst.Format.TIME)
+ timeout_period = 1000
+ if success:
+ timeout_period = min(1000 * (duration / 10**9) // width, 1000)
if self.timeout:
GLib.source_remove(self.timeout)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]