[Xfce4-commits] [apps/xfce4-volumed-pulse] 06/62: New release : 0.1.4 (see changelog

noreply at xfce.org noreply at xfce.org
Thu Sep 8 10:32:28 CEST 2016


This is an automated email from the git hooks/post-receive script.

ochosi pushed a commit to branch master
in repository apps/xfce4-volumed-pulse.

commit dcd449bb429adaf0284ad344b1a1175bbdb97b62
Author: Steve Dodier <sidnioulz at gmail.com>
Date:   Fri Sep 4 19:17:41 2009 +0200

    New release : 0.1.4 (see changelog
---
 ChangeLog            |  8 ++++++++
 configure.ac         |  4 ++--
 src/main.c           |  6 +-----
 src/xvd_data_types.h |  1 -
 src/xvd_mixer.c      | 46 +++++++++++++++++++++++++++-------------------
 src/xvd_xfconf.c     | 27 +++++++++++++++------------
 6 files changed, 53 insertions(+), 39 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 501e7d4..e6e9509 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-09-04  Steve Dodier <sidnioulz at gmail.com>
+
+	* Volume initialisation now includes mute check
+	* Fixed a bug in volume calculation due to float truncating
+	* Replaced g_utf8_collate by g_strcmp0. Less accurate but at least doesn't corrupt strings
+	* Removed obsolete code
+	* Fixed an error preventing from building without libnotify
+
 2009-09-03  Steve Dodier <sidnioulz at gmail.com>
 
 	* Reworking the whole xfconf / mixer code to make it more solid
diff --git a/configure.ac b/configure.ac
index 50eae09..b8dbb78 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([xfce4-volumed], [0.1.3], [http://bugs.launchpad.net/xfce4-volumed])
+AC_INIT([xfce4-volumed], [0.1.4], [http://bugs.launchpad.net/xfce4-volumed])
 AM_INIT_AUTOMAKE([AC_PACKAGE_TARNAME()], [AC_PACKAGE_VERSION()])
 
 AC_CONFIG_SRCDIR([src/main.c])
@@ -49,9 +49,9 @@ if test "$with_libnotify" = "yes" || test "$HAVE_LIBNOTIFY" = "1"; then
    HAVE_LIBNOTIFY=1
    AC_SUBST(LIBNOTIFY_CFLAGS)
    AC_SUBST(LIBNOTIFY_LIBS)
+   AC_DEFINE(HAVE_LIBNOTIFY, 1, [LIBNOTIFY support])
 fi
 AC_SUBST(HAVE_LIBNOTIFY)
-AC_DEFINE(HAVE_LIBNOTIFY, $HAVE_LIBNOTIFY, [LIBNOTIFY support])
 AM_CONDITIONAL(HAVE_LIBNOTIFY, [test "$HAVE_LIBNOTIFY" = "1"])
 
 if test "x$enable_debug" = "xyes"; then
diff --git a/src/main.c b/src/main.c
index 5b47911..65c90de 100644
--- a/src/main.c
+++ b/src/main.c
@@ -18,7 +18,7 @@
  */
 
 #ifdef HAVE_CONFIG_H
-#include <config.h>
+#include "config.h"
 #endif
 
 #include "xvd_keys.h"
@@ -156,10 +156,6 @@ main(gint argc, gchar **argv)
 	xvd_notify_init (Inst, XVD_APPNAME);
 	#endif
 	
-/*	while (Inst->xvd_init_error) {*/
-/*		sleep (1);*/
-/*	}*/ //superseded ? XXX
-	
 	Inst->loop = g_main_loop_new (NULL, FALSE);
 	g_main_loop_run (Inst->loop);
 	
diff --git a/src/xvd_data_types.h b/src/xvd_data_types.h
index 3ec8c4c..a60e9f3 100644
--- a/src/xvd_data_types.h
+++ b/src/xvd_data_types.h
@@ -77,7 +77,6 @@ typedef struct {
 
 	/* Other Xvd vars */
 	GMainLoop			*loop;
-	gboolean			xvd_init_error;
 	gboolean			notifyosd;
 } XvdInstance;
 
diff --git a/src/xvd_mixer.c b/src/xvd_mixer.c
index 787f337..8d23b8d 100644
--- a/src/xvd_mixer.c
+++ b/src/xvd_mixer.c
@@ -101,7 +101,7 @@ _xvd_mixer_bus_message (GstBus *bus, GstMessage *message,
 	{
 		gst_mixer_message_parse_mute_toggled (message, &msg_track, &Inst->muted);
 		g_object_get (msg_track, "label", &label, NULL);
-		if (g_utf8_collate (Inst->track_label, label) != 0)
+		if (g_strcmp0 (Inst->track_label, label) != 0)
 			return;
 #ifdef HAVE_LIBNOTIFY
 		if (Inst->muted)
@@ -117,7 +117,7 @@ _xvd_mixer_bus_message (GstBus *bus, GstMessage *message,
 	{
 		gst_mixer_message_parse_volume_changed (message, &msg_track, &volumes, &num_channels);
 		g_object_get (msg_track, "label", &label, NULL);
-		if (g_utf8_collate (Inst->track_label, label) != 0)
+		if (g_strcmp0 (Inst->track_label, label) != 0)
 			return;
 		xvd_calculate_avg_volume (Inst, volumes, num_channels);
 #ifdef HAVE_LIBNOTIFY
@@ -158,6 +158,7 @@ xvd_mixer_init_volume(XvdInstance *Inst)
 		gst_mixer_get_volume (GST_MIXER (Inst->card), Inst->track, volumes);
 		xvd_calculate_avg_volume (Inst, volumes, Inst->track->num_channels);
 		g_free (volumes);
+		Inst->muted = (GST_MIXER_TRACK_HAS_FLAG (Inst->track, GST_MIXER_TRACK_MUTE));
 	}
 }
 
@@ -178,13 +179,14 @@ xvd_get_card_from_mixer(XvdInstance *Inst,
 	for (iter = g_list_first (Inst->mixers); iter != NULL; iter = g_list_next (iter)) {
 		tmp_card_name = g_object_get_data (G_OBJECT (iter->data), "xfce-mixer-internal-name");
 		
-		if ((wanted_card != NULL) && (G_UNLIKELY (g_utf8_collate (wanted_card, tmp_card_name) == 0))) {
+		if ((wanted_card != NULL) && (G_UNLIKELY (g_strcmp0 (wanted_card, tmp_card_name) == 0))) {
 		  Inst->card = iter->data;
+		  Inst->card_name = g_strdup (wanted_card);
 		  break;
 		}
 
 		// If the fallback card label is set, we save the fallback card in case the wanted one isn't found
-		if ((preferred_fallback != NULL) && (G_UNLIKELY (g_utf8_collate (preferred_fallback, tmp_card_name) == 0))) {
+		if ((preferred_fallback != NULL) && (G_UNLIKELY (g_strcmp0 (preferred_fallback, tmp_card_name) == 0))) {
 		  fallback_card = iter->data;
 		}
 		
@@ -199,7 +201,7 @@ xvd_get_card_from_mixer(XvdInstance *Inst,
 	
 	// We now check if the card was set or if we should use fallback / first instead
 	if (NULL != Inst->card) {
-		g_debug ("The card %s was found on the card and set as the current card.\n", wanted_card);
+		g_debug ("The card %s was found and set as the current card.\n", wanted_card);
 	}
 	else if (NULL != fallback_card) {
 		g_debug ("The wanted card could not be found, using the fallback one instead.\n");
@@ -219,14 +221,12 @@ xvd_get_card_from_mixer(XvdInstance *Inst,
 	}
 	else {
 		g_debug ("Error: there is no sound card on this machine.\n");
-		Inst->xvd_init_error = TRUE;
 		return;
 	}
 	
 	g_free (first_name);
 
 	#ifdef HAVE_LIBNOTIFY
-	gst_object_unref (Inst->bus);
 	gst_element_set_bus (Inst->card, Inst->bus);
 	#endif
 }
@@ -250,7 +250,7 @@ xvd_get_track_from_mixer(XvdInstance *Inst,
 			g_object_get (GST_MIXER_TRACK (iter->data), "label", &tmp_label, NULL);
 			
 			// If the wanted track is requested and found
-			if ((wanted_track != NULL) && (g_utf8_collate (tmp_label, wanted_track) == 0)) {
+			if ((wanted_track != NULL) && (g_strcmp0 (tmp_label, wanted_track) == 0)) {
 				Inst->track_label = g_strdup (tmp_label);
 				Inst->track = iter->data;
 				g_free (tmp_label);
@@ -258,7 +258,7 @@ xvd_get_track_from_mixer(XvdInstance *Inst,
 			}
 			
 			// If the fallback track label is set, we save the fallback track in case the wanted one isn't found
-			if ((preferred_fallback != NULL) && (g_utf8_collate (tmp_label, preferred_fallback) == 0)) {
+			if ((preferred_fallback != NULL) && (g_strcmp0 (tmp_label, preferred_fallback) == 0)) {
 				fallback_track = iter->data;
 			}
 			
@@ -279,7 +279,6 @@ xvd_get_track_from_mixer(XvdInstance *Inst,
 	}
 	else {
 		g_debug ("Error: there is no sound card to search tracks from.\n");
-		Inst->xvd_init_error = TRUE;
 		return;
 	}
 	
@@ -303,17 +302,11 @@ xvd_get_track_from_mixer(XvdInstance *Inst,
 	}
 	else {
 		g_debug ("Error: the current sound card doesn't have any track.\n");
-		Inst->xvd_init_error = TRUE;
 		return;
 	}
 	
 	g_free (first_label);
 	g_free (master_label);
-	
-	if (Inst->xvd_init_error) {
-		Inst->xvd_init_error = FALSE;
-		g_debug ("The daemon apparently recovered from a card/track initialisation error.\n");
-	}
 }
 
 static void 
@@ -340,9 +333,12 @@ xvd_clean_cards(XvdInstance *Inst)
 void
 xvd_clean_mixer_bus(XvdInstance *Inst)
 {
+	int i, refc = GST_OBJECT_REFCOUNT(Inst->bus);
 	gst_bus_remove_signal_watch (Inst->bus);
 	g_signal_handler_disconnect (Inst->bus, Inst->bus_id);
-	gst_object_unref (Inst->bus);
+	
+	for (i=0; i < refc; i++)
+		gst_object_unref (Inst->bus);
 }
 #endif
 
@@ -371,6 +367,19 @@ xvd_calculate_avg_volume(XvdInstance *Inst,
 	}
 }
 
+static gint
+_nearest_int (gdouble val)
+{
+	gdouble diff = (val - (gint) val);
+
+	if ((-0.5 < diff) && (diff < 0.5))
+		return (gint) val;
+	else if (diff > 0)
+		return (gint) val + 1;
+	else
+		return (gint) val - 1;
+}
+
 gboolean 
 xvd_mixer_change_volume(XvdInstance *Inst, 
 						gint step)
@@ -382,7 +391,7 @@ xvd_mixer_change_volume(XvdInstance *Inst,
 		gst_mixer_get_volume (GST_MIXER (Inst->card), Inst->track, volumes);
 		
 		for (i=0; i<Inst->track->num_channels; i++) {
-			volumes[i] += (gint)( ((gdouble)step / 100) * (Inst->track->max_volume - Inst->track->min_volume));
+			volumes[i] += _nearest_int ((gdouble)(step * (Inst->track->max_volume - Inst->track->min_volume)) / 100.0);
 			
 			if (volumes[i] > Inst->track->max_volume)
 				volumes[i] = Inst->track->max_volume;
@@ -390,7 +399,6 @@ xvd_mixer_change_volume(XvdInstance *Inst,
 			if (volumes[i] < Inst->track->min_volume)
 				volumes[i] = Inst->track->min_volume;
 		}
-		
 		xvd_calculate_avg_volume (Inst, volumes, Inst->track->num_channels);
 		
 		gst_mixer_set_volume (GST_MIXER (Inst->card), Inst->track, volumes);
diff --git a/src/xvd_xfconf.c b/src/xvd_xfconf.c
index 52d0757..a875437 100644
--- a/src/xvd_xfconf.c
+++ b/src/xvd_xfconf.c
@@ -36,19 +36,18 @@ _xvd_xfconf_reinit_card(XvdInstance *Inst)
 	}
 	
 	// If the card set in xfconf is the same as the currently used one, we do nothing
-	if ((Inst->card_name != NULL) && (g_utf8_collate (Inst->xfconf_card_name, Inst->card_name) == 0)) {
+	if ((Inst->card_name != NULL) && (g_strcmp0 (Inst->xfconf_card_name, Inst->card_name) == 0)) {
 		return;
 	}
 	
-	// We now clean the current track and try to replace it with the one set in xfconf
+	// We now try to replace it with the one set in xfconf
 	previous_card = g_strdup (Inst->card_name);
-	xvd_clean_card_name (Inst);
 	xvd_get_card_from_mixer (Inst, Inst->xfconf_card_name, previous_card);
 	
 	// At this stage the track grabbed is wrong, but we expect the user to also update the track key
 	
 	// We check if the card has been correctly set
-	if ((Inst->card_name == NULL) || (g_utf8_collate (Inst->xfconf_card_name, Inst->card_name) != 0)) {
+	if ((Inst->card_name == NULL) || (g_strcmp0 (Inst->xfconf_card_name, Inst->card_name) != 0)) {
 		g_debug ("The card chosen in xfconf could not be set, another one was set instead\nChosen: %s\nSet: %s\n",
 														Inst->xfconf_card_name,
 														Inst->card_name);
@@ -58,6 +57,9 @@ _xvd_xfconf_reinit_card(XvdInstance *Inst)
 		g_free (Inst->xfconf_card_name);
 		Inst->xfconf_card_name = g_strdup (Inst->card_name);
 	}
+	else {
+		g_debug ("The card change succeeded with the new xfconf card %s.\n", Inst->xfconf_card_name);
+	}
 	
 	g_free (previous_card);
 	
@@ -65,7 +67,7 @@ _xvd_xfconf_reinit_card(XvdInstance *Inst)
 	// So we check if the track belongs to our new card.
 	if (Inst->previously_set_track_label) {
 		xvd_get_track_from_mixer (Inst, Inst->previously_set_track_label, Inst->track_label);
-		if (g_utf8_collate (Inst->previously_set_track_label, Inst->track_label) == 0) {
+		if (g_strcmp0 (Inst->previously_set_track_label, Inst->track_label) == 0) {
 			xvd_xfconf_set_track (Inst, Inst->previously_set_track_label);
 			g_free (Inst->previously_set_track_label);
 			g_debug ("The previously set xfconf track was a track from the newly set sound card.\n");
@@ -75,8 +77,10 @@ _xvd_xfconf_reinit_card(XvdInstance *Inst)
 	else {
 		xvd_get_track_from_mixer (Inst, Inst->track_label, NULL);
 	}
+	
+	xvd_mixer_init_volume (Inst);
 
-	g_debug ("Xfconf reinit: the card is now %s, the track (probably wrong) is %s and the volume is %d\n", Inst->card_name, Inst->track_label, Inst->current_vol);
+	g_debug ("Xfconf reinit: the card is now %s, the track is %s and the volume is %d\n", Inst->card_name, Inst->track_label, Inst->current_vol);
 }
 
 static void
@@ -95,17 +99,16 @@ _xvd_xfconf_reinit_track(XvdInstance *Inst)
 	}
 	
 	// If the track set in xfconf is the same as the currently used one, we do nothing
-	if ((Inst->track_label != NULL) && (g_utf8_collate (Inst->xfconf_track_label, Inst->track_label) == 0)) {
+	if ((Inst->track_label != NULL) && (g_strcmp0 (Inst->xfconf_track_label, Inst->track_label) == 0)) {
 		return;
 	}
 	
-	// We now clean the current track and try to replace it with the one set in xfconf
+	// We now try to replace it with the one set in xfconf
 	previous_track = g_strdup (Inst->track_label);
-	xvd_clean_track (Inst);
 	xvd_get_track_from_mixer (Inst, Inst->xfconf_track_label, previous_track);
 
 	// We check if the track has been correctly set
-	if ((Inst->track_label == NULL) || (g_utf8_collate (Inst->xfconf_track_label, Inst->track_label) != 0)) {
+	if ((Inst->track_label == NULL) || (g_strcmp0 (Inst->xfconf_track_label, Inst->track_label) != 0)) {
 		// If not, we save the valid track in xfconf instead of the user chosen
 		Inst->previously_set_track_label = g_strdup (Inst->xfconf_track_label);
 		g_debug ("The track chosen in xfconf (%s) doesn't exist in the current card. It'll be tried again after a sound card change.\nNow using %s.\n",
@@ -197,7 +200,7 @@ xvd_xfconf_get_card(XvdInstance *Inst)
 void 
 xvd_xfconf_set_card(XvdInstance *Inst, gchar *value)
 {
-	g_debug ("%s %s\n", "Setting the xfconf card name to", Inst->xfconf_card_name);
+	g_debug ("%s %s\n", "Setting the xfconf card name to", value);
 	xfconf_channel_set_string (Inst->chan, XFCONF_MIXER_ACTIVECARD, value);
 }
 
@@ -223,7 +226,7 @@ xvd_xfconf_get_track(XvdInstance *Inst)
 void 
 xvd_xfconf_set_track(XvdInstance *Inst, gchar *value)
 {
-	g_debug("%s %s\n", "Setting the xfconf card name to", Inst->xfconf_card_name);
+	g_debug("%s %s\n", "Setting the xfconf card name to", value);
 	xfconf_channel_set_string (Inst->chan, XFCONF_MIXER_ACTIVETRACK, value);
 }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list