[gnome-music/wip/mschraal/gst-handle-async-done-3-32-backport: 2/3] smoothscale: Always set a timeout on update
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/gst-handle-async-done-3-32-backport: 2/3] smoothscale: Always set a timeout on update
- Date: Sun, 5 May 2019 17:53:26 +0000 (UTC)
commit 700f4b5e0893c9860cff7b281b0df7d61cfb6216
Author: Marinus Schraal <mschraal gnome org>
Date: Mon Apr 15 09:15:48 2019 +0200
smoothscale: Always set a timeout on update
Async latency could cause the SmoothScale timeout be calculated when the
widget had not yet been realized, as it is based on the widgets realized
size. This could result in no timeout being set and SmoothScale not being
updated for the first song of the playlist on a fresh startup.
Always trigger a timeout being added even when the widget has not yet been
realized, so SmoothScale starts working as soon as the widget is realized.
Set a small minimal timeout, so the updates smooth in evenly.
gnomemusic/widgets/smoothscale.py | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
---
diff --git a/gnomemusic/widgets/smoothscale.py b/gnomemusic/widgets/smoothscale.py
index 103ff800..1fd19167 100644
--- a/gnomemusic/widgets/smoothscale.py
+++ b/gnomemusic/widgets/smoothscale.py
@@ -175,12 +175,7 @@ class SmoothScale(Gtk.Scale):
the slider SmoothScale move smoothly based on the current song
duration and scale length.
"""
- # Do not run until SmoothScale has been realized and GStreamer
- # provides a duration.
- duration = self._player.props.duration
- if (self.get_realized() is False
- or duration == -1.):
- return
+ duration = abs(self._player.props.duration)
# Update self._timeout.
width = self.get_allocated_width()
@@ -188,7 +183,7 @@ class SmoothScale(Gtk.Scale):
Gtk.StateFlags.NORMAL)
width = max(width - (padding.left + padding.right), 1)
- timeout_period = min(1000 * duration // width, 1000)
+ timeout_period = min(1000 * duration // width, 200)
if self._timeout:
GLib.source_remove(self._timeout)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]