[gnome-media] Fix feedback loops



commit 91b2da893d027ed5d85f9ca18c54eebae9715bd7
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Aug 13 17:55:08 2009 +0100

    Fix feedback loops
    
    Either, the front-end is changing the channel-map directly, and
    then tells us whether we should be setting the hardware as well,
    Or they change the volume/dB on the stream, and push that change
    themselves for the stream.

 gnome-volume-control/src/gvc-balance-bar.c        |    5 +++--
 gnome-volume-control/src/gvc-channel-map.c        |    9 +++++----
 gnome-volume-control/src/gvc-channel-map.h        |    5 +++--
 gnome-volume-control/src/gvc-mixer-control.c      |    2 +-
 gnome-volume-control/src/gvc-mixer-dialog.c       |    9 +++++++--
 gnome-volume-control/src/gvc-mixer-stream.c       |    8 +++++---
 gnome-volume-control/src/gvc-stream-status-icon.c |    1 +
 7 files changed, 25 insertions(+), 14 deletions(-)
---
diff --git a/gnome-volume-control/src/gvc-balance-bar.c b/gnome-volume-control/src/gvc-balance-bar.c
index 9cec457..c40015e 100644
--- a/gnome-volume-control/src/gvc-balance-bar.c
+++ b/gnome-volume-control/src/gvc-balance-bar.c
@@ -133,7 +133,7 @@ _scale_box_new (GvcBalanceBar *bar)
                                     GTK_POS_BOTTOM, NULL);
         } else {
                 gtk_scale_set_digits (GTK_SCALE (bar->priv->scale), 0);
-	}
+        }
 
         bar->priv->end_box = ebox = gtk_hbox_new (FALSE, 6);
         gtk_box_pack_start (GTK_BOX (box), ebox, FALSE, FALSE, 0);
@@ -230,6 +230,7 @@ update_level_from_map (GvcBalanceBar *bar,
 
 static void
 on_channel_map_volume_changed (GvcChannelMap  *map,
+                               gboolean        set,
                                GvcBalanceBar  *bar)
 {
         update_level_from_map (bar, map);
@@ -509,7 +510,7 @@ on_adjustment_value_changed (GtkAdjustment *adjustment,
                 break;
         }
 
-        gvc_channel_map_volume_changed (bar->priv->channel_map, &cv);
+        gvc_channel_map_volume_changed (bar->priv->channel_map, &cv, TRUE);
 }
 
 static void
diff --git a/gnome-volume-control/src/gvc-channel-map.c b/gnome-volume-control/src/gvc-channel-map.c
index 402804d..ea3e5af 100644
--- a/gnome-volume-control/src/gvc-channel-map.c
+++ b/gnome-volume-control/src/gvc-channel-map.c
@@ -209,15 +209,16 @@ gvc_channel_map_class_init (GvcChannelMapClass *klass)
                               G_SIGNAL_RUN_LAST,
                               G_STRUCT_OFFSET (GvcChannelMapClass, volume_changed),
                               NULL, NULL,
-                              g_cclosure_marshal_VOID__VOID,
-                              G_TYPE_NONE, 0);
+                              g_cclosure_marshal_VOID__BOOLEAN,
+                              G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
 
         g_type_class_add_private (klass, sizeof (GvcChannelMapPrivate));
 }
 
 void
 gvc_channel_map_volume_changed (GvcChannelMap     *map,
-                                const pa_cvolume  *cv)
+                                const pa_cvolume  *cv,
+                                gboolean           set)
 {
         g_return_if_fail (GVC_IS_CHANNEL_MAP (map));
         g_return_if_fail (cv != NULL);
@@ -232,7 +233,7 @@ gvc_channel_map_volume_changed (GvcChannelMap     *map,
                 map->priv->pa_volume_is_set = TRUE;
                 return;
         }
-        g_signal_emit (map, signals[VOLUME_CHANGED], 0);
+        g_signal_emit (map, signals[VOLUME_CHANGED], 0, set);
 }
 
 static void
diff --git a/gnome-volume-control/src/gvc-channel-map.h b/gnome-volume-control/src/gvc-channel-map.h
index b35c9cb..497ce69 100644
--- a/gnome-volume-control/src/gvc-channel-map.h
+++ b/gnome-volume-control/src/gvc-channel-map.h
@@ -44,7 +44,7 @@ typedef struct
 typedef struct
 {
         GObjectClass           parent_class;
-        void (*volume_changed) (GvcChannelMap *channel_map);
+        void (*volume_changed) (GvcChannelMap *channel_map, gboolean set);
 } GvcChannelMapClass;
 
 enum {
@@ -67,7 +67,8 @@ gboolean                gvc_channel_map_can_fade                (GvcChannelMap
 gboolean                gvc_channel_map_has_lfe                 (GvcChannelMap  *map);
 
 void                    gvc_channel_map_volume_changed          (GvcChannelMap    *map,
-                                                                 const pa_cvolume *cv);
+                                                                 const pa_cvolume *cv,
+                                                                 gboolean          set);
 const char *            gvc_channel_map_get_mapping             (GvcChannelMap  *map);
 
 /* private */
diff --git a/gnome-volume-control/src/gvc-mixer-control.c b/gnome-volume-control/src/gvc-mixer-control.c
index 0b5feee..eba8f55 100644
--- a/gnome-volume-control/src/gvc-mixer-control.c
+++ b/gnome-volume-control/src/gvc-mixer-control.c
@@ -691,7 +691,7 @@ update_sink (GvcMixerControl    *control,
 
         if (map == NULL)
                 map = gvc_mixer_stream_get_channel_map (stream);
-        gvc_channel_map_volume_changed (map, &info->volume);
+        gvc_channel_map_volume_changed (map, &info->volume, TRUE);
 }
 
 static void
diff --git a/gnome-volume-control/src/gvc-mixer-dialog.c b/gnome-volume-control/src/gvc-mixer-dialog.c
index eb3ac28..6699d24 100644
--- a/gnome-volume-control/src/gvc-mixer-dialog.c
+++ b/gnome-volume-control/src/gvc-mixer-dialog.c
@@ -652,7 +652,10 @@ on_adjustment_value_changed (GtkAdjustment  *adjustment,
         stream = g_object_get_data (G_OBJECT (adjustment), "gvc-mixer-dialog-stream"),
         volume = gtk_adjustment_get_value (adjustment);
         if (stream != NULL) {
-                gvc_mixer_stream_set_volume(stream, (pa_volume_t) volume );
+        	/* 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) volume);
+                gvc_mixer_stream_push_volume (stream);
         }
 }
 
@@ -881,6 +884,9 @@ add_stream (GvcMixerDialog *dialog,
 
         g_assert (stream != NULL);
 
+        if (gvc_mixer_stream_is_event_stream (stream) != FALSE)
+        	return;
+
         bar = NULL;
         is_default = FALSE;
         id = gvc_mixer_stream_get_application_id (stream);
@@ -904,7 +910,6 @@ add_stream (GvcMixerDialog *dialog,
                 g_debug ("Adding effects stream");
         } else if (! GVC_IS_MIXER_SOURCE (stream)
                    && !GVC_IS_MIXER_SINK (stream)
-                   && !gvc_mixer_stream_is_event_stream (stream)
                    && !gvc_mixer_stream_is_virtual (stream)
                    && g_strcmp0 (id, "org.gnome.VolumeControl") != 0
                    && g_strcmp0 (id, "org.PulseAudio.pavucontrol") != 0) {
diff --git a/gnome-volume-control/src/gvc-mixer-stream.c b/gnome-volume-control/src/gvc-mixer-stream.c
index 95b1739..2a9a7ce 100644
--- a/gnome-volume-control/src/gvc-mixer-stream.c
+++ b/gnome-volume-control/src/gvc-mixer-stream.c
@@ -153,7 +153,7 @@ gvc_mixer_stream_set_volume (GvcMixerStream *stream,
         pa_cvolume_scale(&cv, volume);
 
         if (!pa_cvolume_equal(gvc_channel_map_get_cvolume(stream->priv->channel_map), &cv)) {
-                gvc_channel_map_volume_changed(stream->priv->channel_map, &cv);
+                gvc_channel_map_volume_changed(stream->priv->channel_map, &cv, FALSE);
                 g_object_notify (G_OBJECT (stream), "volume");
         }
 
@@ -172,7 +172,7 @@ gvc_mixer_stream_set_decibel (GvcMixerStream *stream,
         pa_cvolume_scale(&cv, pa_sw_volume_from_dB(db));
 
         if (!pa_cvolume_equal(gvc_channel_map_get_cvolume(stream->priv->channel_map), &cv)) {
-                gvc_channel_map_volume_changed(stream->priv->channel_map, &cv);
+                gvc_channel_map_volume_changed(stream->priv->channel_map, &cv, FALSE);
                 g_object_notify (G_OBJECT (stream), "volume");
         }
 
@@ -323,9 +323,11 @@ gvc_mixer_stream_set_application_id (GvcMixerStream *stream,
 
 static void
 on_channel_map_volume_changed (GvcChannelMap  *channel_map,
+                               gboolean        set,
                                GvcMixerStream *stream)
 {
-        gvc_mixer_stream_push_volume (stream);
+        if (set == TRUE)
+                gvc_mixer_stream_push_volume (stream);
 
         g_object_notify (G_OBJECT (stream), "volume");
 }
diff --git a/gnome-volume-control/src/gvc-stream-status-icon.c b/gnome-volume-control/src/gvc-stream-status-icon.c
index e472438..e036d5f 100644
--- a/gnome-volume-control/src/gvc-stream-status-icon.c
+++ b/gnome-volume-control/src/gvc-stream-status-icon.c
@@ -73,6 +73,7 @@ on_adjustment_value_changed (GtkAdjustment *adjustment,
 
         gvc_mixer_stream_set_volume(icon->priv->mixer_stream,
                                     (pa_volume_t) volume);
+        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]