gnome-settings-daemon r563 - in branches/gnome-2-24: . plugins/media-keys/actions



Author: jensg
Date: Thu Oct 23 17:04:07 2008
New Revision: 563
URL: http://svn.gnome.org/viewvc/gnome-settings-daemon?rev=563&view=rev

Log:
2008-10-23  Jens Granseuer  <jensgr gmx net>

	Merged from trunk.

	* plugins/media-keys/actions/acme-volume-gstreamer.c:
	(acme_volume_gstreamer_finalize),
	(acme_volume_gstreamer_close_real), (acme_volume_gstreamer_open),
	(acme_volume_gstreamer_close), (acme_volume_gstreamer_init),
	(acme_volume_gstreamer_class_init):
	* plugins/media-keys/actions/acme-volume-gstreamer.h:
	clean up Volume initialization so that we don't get non-functional
	volume keys when the plugin starts up with an invalid configuration
	initially, even if the configuration is fixed afterwards (bug #552383)


Modified:
   branches/gnome-2-24/ChangeLog
   branches/gnome-2-24/plugins/media-keys/actions/acme-volume-gstreamer.c
   branches/gnome-2-24/plugins/media-keys/actions/acme-volume-gstreamer.h

Modified: branches/gnome-2-24/plugins/media-keys/actions/acme-volume-gstreamer.c
==============================================================================
--- branches/gnome-2-24/plugins/media-keys/actions/acme-volume-gstreamer.c	(original)
+++ branches/gnome-2-24/plugins/media-keys/actions/acme-volume-gstreamer.c	Thu Oct 23 17:04:07 2008
@@ -36,11 +36,13 @@
 
 #include <string.h>
 
-#define TIMEOUT	4000
+#define TIMEOUT	4
 
 #define DEFAULT_MIXER_DEVICE_KEY   "/desktop/gnome/sound/default_mixer_device"
 #define DEFAULT_MIXER_TRACKS_KEY   "/desktop/gnome/sound/default_mixer_tracks"
 
+#define ACME_VOLUME_GSTREAMER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), ACME_TYPE_VOLUME_GSTREAMER, AcmeVolumeGStreamerPrivate))
+
 struct AcmeVolumeGStreamerPrivate
 {
   	GstMixer      *mixer;
@@ -69,8 +71,6 @@
 
 	self = ACME_VOLUME_GSTREAMER (object);
 
-	g_return_if_fail (self->_priv != NULL);
-
 	if (self->_priv->timer_id != 0)
 	{
 		g_source_remove (self->_priv->timer_id);
@@ -79,12 +79,10 @@
 	acme_volume_gstreamer_close_real (self);
 
 	if (self->_priv->gconf_client != NULL) {
-		g_object_unref (G_OBJECT (self->_priv->gconf_client));
+		g_object_unref (self->_priv->gconf_client);
 		self->_priv->gconf_client = NULL;
 	}
 
-	g_free (self->_priv);
-
 	G_OBJECT_CLASS (acme_volume_gstreamer_parent_class)->finalize (object);
 }
 
@@ -236,17 +234,14 @@
 static gboolean
 acme_volume_gstreamer_close_real (AcmeVolumeGStreamer *self)
 {
-	if (self->_priv == NULL)
-		return FALSE;
-
 	if (self->_priv->mixer != NULL)
 	{
-		gst_element_set_state (GST_ELEMENT(self->_priv->mixer), GST_STATE_NULL);
+		gst_element_set_state (GST_ELEMENT (self->_priv->mixer), GST_STATE_NULL);
 		gst_object_unref (GST_OBJECT (self->_priv->mixer));
-		g_list_foreach (self->_priv->mixer_tracks, (GFunc)g_object_unref, NULL);
+		g_list_foreach (self->_priv->mixer_tracks, (GFunc) g_object_unref, NULL);
 		g_list_free (self->_priv->mixer_tracks);
-		self->_priv->mixer=NULL;
-		self->_priv->mixer_tracks=NULL;
+		self->_priv->mixer = NULL;
+		self->_priv->mixer_tracks = NULL;
 	}
 
 	self->_priv->timer_id = 0;
@@ -262,27 +257,27 @@
 static gboolean
 _acme_set_mixer(GstMixer *mixer, gpointer user_data)
 {
-   const GList *tracks;
+	const GList *tracks;
 
-   tracks = gst_mixer_list_tracks (mixer);
+	tracks = gst_mixer_list_tracks (mixer);
 
-   while (tracks != NULL) {
-      GstMixerTrack *track = GST_MIXER_TRACK (tracks->data);
+	while (tracks != NULL) {
+		GstMixerTrack *track = GST_MIXER_TRACK (tracks->data);
 
-      if (GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_MASTER)) {
-         AcmeVolumeGStreamer *self;
+		if (GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_MASTER)) {
+			AcmeVolumeGStreamer *self;
 
-         self = ACME_VOLUME_GSTREAMER (user_data);
+			self = ACME_VOLUME_GSTREAMER (user_data);
 
-         self->_priv->mixer = mixer;
-         self->_priv->mixer_tracks = g_list_append (self->_priv->mixer_tracks, g_object_ref (track));
-         return TRUE;
-      }
+			self->_priv->mixer = mixer;
+			self->_priv->mixer_tracks = g_list_append (self->_priv->mixer_tracks, g_object_ref (track));
+			return TRUE;
+		}
 
-      tracks = tracks->next;
-   }
+		tracks = tracks->next;
+	}
 
-   return FALSE;
+	return FALSE;
 }
 
 /* This is a modified version of code from gnome-media's gst-mixer */
@@ -293,9 +288,6 @@
 	gchar *mixer_device, **factory_and_device = NULL;
 	GList *mixer_list;
 
-	if (self->_priv == NULL)
-		return FALSE;
-
 	if (self->_priv->timer_id != 0)
 	{
 		g_source_remove (self->_priv->timer_id);
@@ -411,32 +403,17 @@
 static void
 acme_volume_gstreamer_close (AcmeVolumeGStreamer *self)
 {
-	self->_priv->timer_id = g_timeout_add (TIMEOUT,
+	self->_priv->timer_id = g_timeout_add_seconds (TIMEOUT,
 			(GSourceFunc) acme_volume_gstreamer_close_real, self);
 }
 
 static void
 acme_volume_gstreamer_init (AcmeVolumeGStreamer *self)
 {
-
-	self->_priv = g_new0 (AcmeVolumeGStreamerPrivate, 1);
-
+	self->_priv = ACME_VOLUME_GSTREAMER_GET_PRIVATE (self);
 	self->_priv->gconf_client = gconf_client_get_default ();
-
-	if (acme_volume_gstreamer_open (self) == FALSE)
-	{
-		g_free (self->_priv);
-		self->_priv = NULL;
-		return;
-	}
-
-	if (self->_priv->mixer != NULL) {
-		acme_volume_gstreamer_close_real (self);
-		return;
-	}
 }
 
-
 static void
 acme_volume_gstreamer_class_init (AcmeVolumeGStreamerClass *klass)
 {
@@ -450,4 +427,6 @@
 	volume_class->set_mute = acme_volume_gstreamer_set_mute;
 	volume_class->get_mute = acme_volume_gstreamer_get_mute;
 	volume_class->get_threshold = acme_volume_gstreamer_get_threshold;
+
+	g_type_class_add_private (klass, sizeof (AcmeVolumeGStreamerPrivate));
 }

Modified: branches/gnome-2-24/plugins/media-keys/actions/acme-volume-gstreamer.h
==============================================================================
--- branches/gnome-2-24/plugins/media-keys/actions/acme-volume-gstreamer.h	(original)
+++ branches/gnome-2-24/plugins/media-keys/actions/acme-volume-gstreamer.h	Thu Oct 23 17:04:07 2008
@@ -26,7 +26,7 @@
 #include <glib-object.h>
 #include "acme-volume.h"
 
-#define ACME_TYPE_VOLUME_GSTREAMER		(acme_volume_get_type ())
+#define ACME_TYPE_VOLUME_GSTREAMER		(acme_volume_gstreamer_get_type ())
 #define ACME_VOLUME_GSTREAMER(obj)		(G_TYPE_CHECK_INSTANCE_CAST ((obj), ACME_TYPE_VOLUME_GSTREAMER, AcmeVolumeGStreamer))
 #define ACME_VOLUME_GSTREAMER_CLASS(klass)	(G_TYPE_CHECK_CLASS_CAST ((klass), ACME_TYPE_VOLUME_GSTREAMER, AcmeVolumeGStreamerClass))
 #define ACME_IS_VOLUME_GSTREAMER(obj)	(G_TYPE_CHECK_INSTANCE_TYPE ((obj), ACME_TYPE_VOLUME_GSTREAMER))
@@ -46,4 +46,3 @@
 };
 
 GType acme_volume_gstreamer_get_type		(void);
-



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