[gnome-music/wip/jfelder/smoothscale-player: 8/14] gstplayer: Filter duplicate state changes



commit ab64880931af76ab8be7ed8fb963ecebf7846b54
Author: Jean Felder <jfelder src gnome org>
Date:   Mon Oct 15 16:03:20 2018 +0200

    gstplayer: Filter duplicate state changes
    
    GStreamer pipeline is really verbose. It can lead to a lot of
    duplications: a state change property is notified even if the value
    has not changed.
    Check for the previous state to filter the duplicate state changes.

 gnomemusic/gstplayer.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/gnomemusic/gstplayer.py b/gnomemusic/gstplayer.py
index ec67891c..6c39f777 100644
--- a/gnomemusic/gstplayer.py
+++ b/gnomemusic/gstplayer.py
@@ -89,6 +89,7 @@ class GstPlayer(GObject.GObject):
             'message::duration-changed', self._on_duration_changed)
         self._bus.connect('message::new-clock', self._on_new_clock)
 
+        self._previous_state = Playback.STOPPED
         self.state = Playback.STOPPED
 
     @log
@@ -149,7 +150,12 @@ class GstPlayer(GObject.GObject):
 
         # Setting self.state triggers the property signal, which is
         # used down the line.
-        self.state = self.state
+        current_state = self.props.state
+        if current_state == self._previous_state:
+            return
+
+        self._previous_state = current_state
+        self.notify('state')
 
     @log
     def _on_duration_changed(self, bus, message):


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