gnome-media r4028 - in trunk/gnome-volume-control: . src
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-media r4028 - in trunk/gnome-volume-control: . src
- Date: Thu, 6 Nov 2008 00:45:52 +0000 (UTC)
Author: mccann
Date: Thu Nov 6 00:45:52 2008
New Revision: 4028
URL: http://svn.gnome.org/viewvc/gnome-media?rev=4028&view=rev
Log:
2008-11-05 William Jon McCann <jmccann redhat com>
* src/gvc-applet.c (gvc_applet_dispose), (on_control_ready):
* src/gvc-channel-bar.c (gvc_channel_bar_finalize):
* src/gvc-mixer-control.c (gvc_mixer_control_get_event_sink_input),
(gvc_mixer_control_get_default_sink),
(gvc_mixer_control_lookup_stream_id), (update_sink),
(update_sink_input), (update_event_role_stream),
(gvc_mixer_control_dispose), (gvc_mixer_control_init):
* src/gvc-mixer-control.h:
* src/gvc-mixer-dialog.c (on_control_stream_added),
(on_control_stream_removed), (gvc_mixer_dialog_constructor),
(gvc_mixer_dialog_dispose), (gvc_mixer_dialog_class_init):
* src/gvc-mixer-stream.c (gvc_mixer_stream_finalize):
Fix leaks. Use ids instead of indexes when possible.
Add method to lookup stream by id.
Modified:
trunk/gnome-volume-control/ChangeLog
trunk/gnome-volume-control/src/gvc-applet.c
trunk/gnome-volume-control/src/gvc-channel-bar.c
trunk/gnome-volume-control/src/gvc-mixer-control.c
trunk/gnome-volume-control/src/gvc-mixer-control.h
trunk/gnome-volume-control/src/gvc-mixer-dialog.c
trunk/gnome-volume-control/src/gvc-mixer-stream.c
Modified: trunk/gnome-volume-control/src/gvc-applet.c
==============================================================================
--- trunk/gnome-volume-control/src/gvc-applet.c (original)
+++ trunk/gnome-volume-control/src/gvc-applet.c Thu Nov 6 00:45:52 2008
@@ -92,6 +92,16 @@
applet->priv->dock = NULL;
}
+ if (applet->priv->control != NULL) {
+ g_object_unref (applet->priv->control);
+ applet->priv->control = NULL;
+ }
+
+ if (applet->priv->sink_stream != NULL) {
+ g_object_unref (applet->priv->sink_stream);
+ applet->priv->sink_stream = NULL;
+ }
+
G_OBJECT_CLASS (gvc_applet_parent_class)->dispose (object);
}
@@ -507,6 +517,8 @@
if (applet->priv->sink_stream != NULL) {
GtkAdjustment *adj;
+ g_object_ref (applet->priv->sink_stream);
+
adj = GTK_ADJUSTMENT (gvc_channel_bar_get_adjustment (GVC_CHANNEL_BAR (applet->priv->bar)));
gtk_adjustment_set_value (adj,
gvc_mixer_stream_get_volume (applet->priv->sink_stream));
Modified: trunk/gnome-volume-control/src/gvc-channel-bar.c
==============================================================================
--- trunk/gnome-volume-control/src/gvc-channel-bar.c (original)
+++ trunk/gnome-volume-control/src/gvc-channel-bar.c Thu Nov 6 00:45:52 2008
@@ -436,6 +436,10 @@
channel_bar = GVC_CHANNEL_BAR (object);
g_return_if_fail (channel_bar->priv != NULL);
+
+ g_free (channel_bar->priv->name);
+ g_free (channel_bar->priv->icon_name);
+
G_OBJECT_CLASS (gvc_channel_bar_parent_class)->finalize (object);
}
Modified: trunk/gnome-volume-control/src/gvc-mixer-control.c
==============================================================================
--- trunk/gnome-volume-control/src/gvc-mixer-control.c (original)
+++ trunk/gnome-volume-control/src/gvc-mixer-control.c Thu Nov 6 00:45:52 2008
@@ -46,13 +46,17 @@
pa_context *pa_context;
int n_outstanding;
+ gboolean default_sink_is_set;
+ guint default_sink_id;
char *default_sink_name;
- guint default_sink_index;
+ gboolean default_source_is_set;
+ guint default_source_id;
char *default_source_name;
- guint default_source_index;
- GvcMixerStream *event_sink_input;
+ gboolean event_sink_input_is_set;
+ guint event_sink_input_id;
+ GHashTable *all_streams;
GHashTable *sinks; /* fixed outputs */
GHashTable *sources; /* fixed inputs */
GHashTable *sink_inputs; /* routable output streams */
@@ -78,9 +82,14 @@
GvcMixerStream *
gvc_mixer_control_get_event_sink_input (GvcMixerControl *control)
{
+ GvcMixerStream *stream;
+
g_return_val_if_fail (GVC_IS_MIXER_CONTROL (control), NULL);
- return control->priv->event_sink_input;
+ stream = g_hash_table_lookup (control->priv->all_streams,
+ GUINT_TO_POINTER (control->priv->event_sink_input_id));
+
+ return stream;
}
GvcMixerStream *
@@ -90,8 +99,26 @@
g_return_val_if_fail (GVC_IS_MIXER_CONTROL (control), NULL);
- stream = g_hash_table_lookup (control->priv->sinks,
- GUINT_TO_POINTER (control->priv->default_sink_index));
+ if (control->priv->default_sink_is_set) {
+ stream = g_hash_table_lookup (control->priv->all_streams,
+ GUINT_TO_POINTER (control->priv->default_sink_id));
+ } else {
+ stream = NULL;
+ }
+
+ return stream;
+}
+
+GvcMixerStream *
+gvc_mixer_control_lookup_stream_id (GvcMixerControl *control,
+ guint id)
+{
+ GvcMixerStream *stream;
+
+ g_return_val_if_fail (GVC_IS_MIXER_CONTROL (control), NULL);
+
+ stream = g_hash_table_lookup (control->priv->all_streams,
+ GUINT_TO_POINTER (id));
return stream;
}
@@ -212,6 +239,10 @@
info->channel_map.channels);
g_hash_table_insert (control->priv->sinks,
GUINT_TO_POINTER (info->index),
+ g_object_ref (stream));
+
+ g_hash_table_insert (control->priv->all_streams,
+ GUINT_TO_POINTER (gvc_mixer_stream_get_id (stream)),
stream);
is_new = TRUE;
}
@@ -232,11 +263,17 @@
//w->type = info.flags & PA_SINK_HARDWARE ? SINK_HARDWARE : SINK_VIRTUAL;
if (is_new) {
- g_signal_emit (G_OBJECT (control), signals[STREAM_ADDED], 0, info->index);
+ g_signal_emit (G_OBJECT (control),
+ signals[STREAM_ADDED],
+ 0,
+ gvc_mixer_stream_get_id (stream));
}
if (is_default) {
- control->priv->default_sink_index = info->index;
+ control->priv->default_sink_id = gvc_mixer_stream_get_id (stream);
+ control->priv->default_sink_is_set = TRUE;
+
+ /* FIXME: property w/ changed event */
}
}
@@ -323,6 +360,10 @@
info->channel_map.channels);
g_hash_table_insert (control->priv->sink_inputs,
GUINT_TO_POINTER (info->index),
+ g_object_ref (stream));
+
+ g_hash_table_insert (control->priv->all_streams,
+ GUINT_TO_POINTER (gvc_mixer_stream_get_id (stream)),
stream);
is_new = TRUE;
}
@@ -337,7 +378,10 @@
gvc_mixer_stream_set_is_default (stream, is_default);
if (is_new) {
- g_signal_emit (G_OBJECT (control), signals[STREAM_ADDED], 0, info->index);
+ g_signal_emit (G_OBJECT (control),
+ signals[STREAM_ADDED],
+ 0,
+ gvc_mixer_stream_get_id (stream));
}
}
@@ -527,14 +571,20 @@
is_new = FALSE;
- if (control->priv->event_sink_input == NULL) {
+ if (!control->priv->event_sink_input_is_set) {
stream = gvc_mixer_sink_input_new (control->priv->pa_context,
0,
1);
- control->priv->event_sink_input = stream;
+ g_hash_table_insert (control->priv->all_streams,
+ GUINT_TO_POINTER (gvc_mixer_stream_get_id (stream)),
+ stream);
+ control->priv->event_sink_input_id = gvc_mixer_stream_get_id (stream);
+ control->priv->event_sink_input_is_set = TRUE;
+
is_new = TRUE;
} else {
- stream = control->priv->event_sink_input;
+ stream = g_hash_table_lookup (control->priv->all_streams,
+ GUINT_TO_POINTER (control->priv->event_sink_input_id));
}
avg_volume = pa_cvolume_avg (&info->volume);
@@ -544,6 +594,13 @@
gvc_mixer_stream_set_icon_name (stream, "multimedia-volume-control");
gvc_mixer_stream_set_volume (stream, (guint)avg_volume);
gvc_mixer_stream_set_is_muted (stream, info->mute);
+
+ if (is_new) {
+ g_signal_emit (G_OBJECT (control),
+ signals[STREAM_ADDED],
+ 0,
+ gvc_mixer_stream_get_id (stream));
+ }
}
static void
@@ -949,11 +1006,46 @@
control->priv->pa_context = NULL;
}
+ if (control->priv->default_source_name != NULL) {
+ g_free (control->priv->default_source_name);
+ control->priv->default_source_name = NULL;
+ }
+ if (control->priv->default_sink_name != NULL) {
+ g_free (control->priv->default_sink_name);
+ control->priv->default_sink_name = NULL;
+ }
+
if (control->priv->pa_mainloop != NULL) {
pa_glib_mainloop_free (control->priv->pa_mainloop);
control->priv->pa_mainloop = NULL;
}
+ if (control->priv->all_streams != NULL) {
+ g_hash_table_destroy (control->priv->all_streams);
+ control->priv->all_streams = NULL;
+ }
+
+ if (control->priv->sinks != NULL) {
+ g_hash_table_destroy (control->priv->sinks);
+ control->priv->sinks = NULL;
+ }
+ if (control->priv->sources != NULL) {
+ g_hash_table_destroy (control->priv->sources);
+ control->priv->sources = NULL;
+ }
+ if (control->priv->sink_inputs != NULL) {
+ g_hash_table_destroy (control->priv->sink_inputs);
+ control->priv->sink_inputs = NULL;
+ }
+ if (control->priv->source_outputs != NULL) {
+ g_hash_table_destroy (control->priv->source_outputs);
+ control->priv->source_outputs = NULL;
+ }
+ if (control->priv->clients != NULL) {
+ g_hash_table_destroy (control->priv->clients);
+ control->priv->clients = NULL;
+ }
+
G_OBJECT_CLASS (gvc_mixer_control_parent_class)->dispose (object);
}
@@ -1040,6 +1132,7 @@
control->priv->pa_api = pa_glib_mainloop_get_api (control->priv->pa_mainloop);
g_assert (control->priv->pa_api);
+ control->priv->all_streams = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify)g_object_unref);
control->priv->sinks = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify)g_object_unref);
control->priv->sources = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify)g_object_unref);
control->priv->sink_inputs = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify)g_object_unref);
Modified: trunk/gnome-volume-control/src/gvc-mixer-control.h
==============================================================================
--- trunk/gnome-volume-control/src/gvc-mixer-control.h (original)
+++ trunk/gnome-volume-control/src/gvc-mixer-control.h Thu Nov 6 00:45:52 2008
@@ -47,9 +47,9 @@
void (*ready) (GvcMixerControl *control);
void (*stream_added) (GvcMixerControl *control,
- guint index);
+ guint id);
void (*stream_removed) (GvcMixerControl *control,
- guint index);
+ guint id);
} GvcMixerControlClass;
GType gvc_mixer_control_get_type (void);
@@ -63,6 +63,9 @@
GSList * gvc_mixer_control_get_sinks (GvcMixerControl *control);
GSList * gvc_mixer_control_get_sink_inputs (GvcMixerControl *control);
+GvcMixerStream * gvc_mixer_control_lookup_stream_id (GvcMixerControl *control,
+ guint id);
+
GvcMixerStream * gvc_mixer_control_get_default_sink (GvcMixerControl *control);
GvcMixerStream * gvc_mixer_control_get_event_sink_input (GvcMixerControl *control);
Modified: trunk/gnome-volume-control/src/gvc-mixer-dialog.c
==============================================================================
--- trunk/gnome-volume-control/src/gvc-mixer-dialog.c (original)
+++ trunk/gnome-volume-control/src/gvc-mixer-dialog.c Thu Nov 6 00:45:52 2008
@@ -280,6 +280,22 @@
gtk_widget_show (bar);
}
+static void
+on_control_stream_added (GvcMixerControl *control,
+ guint id,
+ GvcMixerDialog *dialog)
+{
+ g_debug ("GvcMixerDialog: Stream %u added", id);
+}
+
+static void
+on_control_stream_removed (GvcMixerControl *control,
+ guint id,
+ GvcMixerDialog *dialog)
+{
+ g_debug ("GvcMixerDialog: Stream %u removed", id);
+}
+
static GObject *
gvc_mixer_dialog_constructor (GType type,
guint n_construct_properties,
@@ -322,6 +338,15 @@
gtk_widget_show_all (self->priv->streams_box);
+ g_signal_connect (self->priv->mixer_control,
+ "stream-added",
+ G_CALLBACK (on_control_stream_added),
+ self);
+ g_signal_connect (self->priv->mixer_control,
+ "stream-removed",
+ G_CALLBACK (on_control_stream_removed),
+ self);
+
streams = gvc_mixer_control_get_sinks (self->priv->mixer_control);
for (l = streams; l != NULL; l = l->next) {
stream = l->data;
@@ -343,11 +368,37 @@
}
static void
+gvc_mixer_dialog_dispose (GObject *object)
+{
+ GvcMixerDialog *dialog = GVC_MIXER_DIALOG (object);
+
+ g_signal_handlers_disconnect_by_func (dialog->priv->mixer_control,
+ on_control_stream_added,
+ dialog);
+ g_signal_handlers_disconnect_by_func (dialog->priv->mixer_control,
+ on_control_stream_removed,
+ dialog);
+
+ if (dialog->priv->mixer_control != NULL) {
+ g_object_unref (dialog->priv->mixer_control);
+ dialog->priv->mixer_control = NULL;
+ }
+
+ if (dialog->priv->bars != NULL) {
+ g_hash_table_destroy (dialog->priv->bars);
+ dialog->priv->bars = NULL;
+ }
+
+ G_OBJECT_CLASS (gvc_mixer_dialog_parent_class)->dispose (object);
+}
+
+static void
gvc_mixer_dialog_class_init (GvcMixerDialogClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->constructor = gvc_mixer_dialog_constructor;
+ object_class->dispose = gvc_mixer_dialog_dispose;
object_class->finalize = gvc_mixer_dialog_finalize;
object_class->set_property = gvc_mixer_dialog_set_property;
object_class->get_property = gvc_mixer_dialog_get_property;
Modified: trunk/gnome-volume-control/src/gvc-mixer-stream.c
==============================================================================
--- trunk/gnome-volume-control/src/gvc-mixer-stream.c (original)
+++ trunk/gnome-volume-control/src/gvc-mixer-stream.c Thu Nov 6 00:45:52 2008
@@ -446,5 +446,12 @@
mixer_stream = GVC_MIXER_STREAM (object);
g_return_if_fail (mixer_stream->priv != NULL);
+
+ g_free (mixer_stream->priv->name);
+ mixer_stream->priv->name = NULL;
+
+ g_free (mixer_stream->priv->icon_name);
+ mixer_stream->priv->icon_name = NULL;
+
G_OBJECT_CLASS (gvc_mixer_stream_parent_class)->finalize (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]