[gnome-music/wip/jfelder/gstplayer-state-test: 2/3] gstplayer: Filter duplicate state changes
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/gstplayer-state-test: 2/3] gstplayer: Filter duplicate state changes
- Date: Mon, 15 Oct 2018 20:06:04 +0000 (UTC)
commit 52497d60c9ddb3679f8c51248b9c1cc67e7aeb5e
Author: Jean Felder <jfelder src gnome org>
Date: Mon Oct 15 22:03:17 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 | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gnomemusic/gstplayer.py b/gnomemusic/gstplayer.py
index bd52f557..e14af354 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,8 +150,15 @@ class GstPlayer(GObject.GObject):
# Setting self.state triggers the property signal, which is
# used down the line.
- print("gstplayer - bus_state_changed", self.state)
- self.state = self.state
+ current_state = self.props.state
+ if current_state == self._previous_state:
+ return
+
+ print(
+ "gstplayer - bus_state_changed", self.state, "previous state:",
+ self._previous_state)
+ 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]