[gnome-media] Only push the volume changes if they changed



commit 07dc5e8db4314f1f2dd2c8b3a856e5361d72e16e
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Aug 18 12:56:41 2009 +0100

    Only push the volume changes if they changed
    
    This fixes problems with us pushing the volume
    twice when changing the bars once.

 gnome-volume-control/src/gvc-mixer-dialog.c       |    5 +++--
 gnome-volume-control/src/gvc-mixer-stream.c       |    3 ++-
 gnome-volume-control/src/gvc-stream-status-icon.c |    8 +++++---
 3 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/gnome-volume-control/src/gvc-mixer-dialog.c b/gnome-volume-control/src/gvc-mixer-dialog.c
index 48ba25d..fd88877 100644
--- a/gnome-volume-control/src/gvc-mixer-dialog.c
+++ b/gnome-volume-control/src/gvc-mixer-dialog.c
@@ -664,8 +664,9 @@ on_adjustment_value_changed (GtkAdjustment  *adjustment,
 
                 /* FIXME would need to do that in the balance bar really... */
                 gvc_mixer_stream_set_is_muted (stream, volume == 0);
-                gvc_mixer_stream_set_volume(stream, (pa_volume_t) rounded);
-                gvc_mixer_stream_push_volume (stream);
+                /* Only push the volume if it's actually changed */
+                if (gvc_mixer_stream_set_volume(stream, (pa_volume_t) rounded) != FALSE)
+                        gvc_mixer_stream_push_volume (stream);
         }
 }
 
diff --git a/gnome-volume-control/src/gvc-mixer-stream.c b/gnome-volume-control/src/gvc-mixer-stream.c
index 2a9a7ce..4662d46 100644
--- a/gnome-volume-control/src/gvc-mixer-stream.c
+++ b/gnome-volume-control/src/gvc-mixer-stream.c
@@ -155,9 +155,10 @@ gvc_mixer_stream_set_volume (GvcMixerStream *stream,
         if (!pa_cvolume_equal(gvc_channel_map_get_cvolume(stream->priv->channel_map), &cv)) {
                 gvc_channel_map_volume_changed(stream->priv->channel_map, &cv, FALSE);
                 g_object_notify (G_OBJECT (stream), "volume");
+                return TRUE;
         }
 
-        return TRUE;
+        return FALSE;
 }
 
 gboolean
diff --git a/gnome-volume-control/src/gvc-stream-status-icon.c b/gnome-volume-control/src/gvc-stream-status-icon.c
index 6858726..37131ea 100644
--- a/gnome-volume-control/src/gvc-stream-status-icon.c
+++ b/gnome-volume-control/src/gvc-stream-status-icon.c
@@ -71,9 +71,11 @@ on_adjustment_value_changed (GtkAdjustment *adjustment,
 
         volume = gtk_adjustment_get_value (adjustment);
 
-        gvc_mixer_stream_set_volume(icon->priv->mixer_stream,
-                                    (pa_volume_t) round (volume));
-        gvc_mixer_stream_push_volume(icon->priv->mixer_stream);
+        /* Only push the volume if it's actually changed */
+        if (gvc_mixer_stream_set_volume(icon->priv->mixer_stream,
+                                    (pa_volume_t) round (volume)) != FALSE) {
+                gvc_mixer_stream_push_volume(icon->priv->mixer_stream);
+        }
 }
 
 static void



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