[notification-daemon] Use canberra instead of gstreamer for event sounds



commit bb685b8252df3963b5d88addcd039c895c63486c
Author: William Jon McCann <jmccann redhat com>
Date:   Fri Jan 8 21:31:58 2010 -0500

    Use canberra instead of gstreamer for event sounds

 configure.ac           |   31 +--------------------
 src/daemon/Makefile.am |    3 +-
 src/daemon/daemon.c    |   29 ++------------------
 src/daemon/sound.c     |   68 ++++++++----------------------------------------
 src/daemon/sound.h     |    7 ++---
 5 files changed, 20 insertions(+), 118 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5764393..f18cbb5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,11 +76,13 @@ AM_GLIB_GNU_GETTEXT
 REQ_GTK_VERSION=2.18.0
 REQ_GLIB_VERSION=$REQ_GTK_VERSION
 REQ_DBUS_VERSION=0.36
+REQ_LIBCANBERRA_GTK_VERSION=0.4
 pkg_modules="
 	gtk+-2.0 >= $REQ_GTK_VERSION, \
 	glib-2.0 >= $REQ_GLIB_VERSION, \
 	dbus-1 >= $REQ_DBUS_VERSION, \
 	dbus-glib-1 >= $REQ_DBUS_VERSION, \
+        libcanberra-gtk >= $REQ_LIBCANBERRA_GTK_VERSION, \
 	gconf-2.0, \
 	libwnck-1.0 \
 "
@@ -164,34 +166,6 @@ fi
 AC_SUBST(CFLAGS)
 
 dnl ################################################################
-dnl # Sound Support 
-dnl ################################################################
-
-AC_ARG_ENABLE(sound,
-  [[  --enable-sound=[auto,gstreamer,no]  Sound support (default=auto)]] )
-
-if test x$enable_sound != xno -a x$enable_sound != xgstreamer; then
-	enable_sound=auto
-fi
-
-if test x$enable_sound != xno; then
-	gstreampkg="gstreamer-0.10"
-
-	if test x$enable_sound = xauto; then
-		PKG_CHECK_MODULES(GSTREAMER, $gstreampkg,
-		                  [enable_sound=gstreamer], [enable_sound=no])
-	else
-		PKG_CHECK_MODULES(GSTREAMER, $gstreampkg, [enable_sound=gstreamer])
-	fi
-
-	if test x$enable_sound = xgstreamer; then
-		AC_DEFINE([HAVE_GSTREAMER], 1, [Defined if Gstreamer is detected])
-		AC_SUBST(GSTREAMER_CFLAGS)
-		AC_SUBST(GSTREAMER_LIBS)
-	fi
-fi
-
-dnl ################################################################
 dnl # Output the Makefiles
 dnl ################################################################
 AC_CONFIG_FILES([
@@ -215,7 +189,6 @@ echo
 echo prefix............... : $prefix
 echo dbus-1 system.d dir.. : $DBUS_SYS_DIR
 echo dbus-1 services dir.. : $DBUS_SERVICES_DIR
-echo sound support........ : $enable_sound
 echo
 echo "Now type make to compile"
 echo "Then su to root and type: make install"
diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am
index c4bf78f..73c0449 100644
--- a/src/daemon/Makefile.am
+++ b/src/daemon/Makefile.am
@@ -10,7 +10,7 @@ notification_daemon_SOURCES = \
 	sound.c \
 	sound.h
 
-notification_daemon_LDADD = $(NOTIFICATION_DAEMON_LIBS) $(GSTREAMER_LIBS)
+notification_daemon_LDADD = $(NOTIFICATION_DAEMON_LIBS)
 
 BUILT_SOURCES = notificationdaemon-dbus-glue.h
 
@@ -21,7 +21,6 @@ notificationdaemon-dbus-glue.h: notificationdaemon.xml
 INCLUDES = \
 	-I$(top_srcdir) \
 	$(NOTIFICATION_DAEMON_CFLAGS) \
-	$(GSTREAMER_CFLAGS) \
 	-DENGINES_DIR=\"$(libdir)/notification-daemon-1.0/engines\"
 
 EXTRA_DIST = notificationdaemon.xml
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index 1fe6248..0740e0f 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -1,4 +1,5 @@
-/* daemon.c - Implementation of the destop notification spec
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ * daemon.c - Implementation of the destop notification spec
  *
  * Copyright (C) 2006 Christian Hammond <chipx86 chipx86 com>
  * Copyright (C) 2005 John (J5) Palmieri <johnp redhat com>
@@ -1197,28 +1198,6 @@ notify_daemon_notify_handler(NotifyDaemon *daemon,
 				sound_file = NULL;
 			}
 		}
-
-		/*
-		 * TODO: If we don't have a sound_file yet, get the urgency hint, then
-		 *       get the corresponding system event sound
-		 *
-		 *       We will need to parse /etc/sound/events/gnome-2.soundlist
-		 *       and ~/.gnome2/sound/events/gnome-2.soundlist.
-		 */
-
-		/* If we don't have a sound file yet, use our gconf default */
-		if (sound_file == NULL)
-		{
-			sound_file = gconf_client_get_string(gconf_client,
-												 GCONF_KEY_DEFAULT_SOUND, NULL);
-			if (sound_file != NULL &&
-				(*sound_file == '\0' ||
-				 !g_file_test(sound_file, G_FILE_TEST_EXISTS)))
-			{
-				g_free(sound_file);
-				sound_file = NULL;
-			}
-		}
 	}
 
 	/* set up action buttons */
@@ -1359,7 +1338,7 @@ notify_daemon_notify_handler(NotifyDaemon *daemon,
 	{
 		theme_show_notification(nw);
 		if (sound_file != NULL)
-			sound_play(sound_file);
+			sound_play_file(GTK_WIDGET(nw), sound_file);
 	}
 
 	g_free(sound_file);
@@ -1446,8 +1425,6 @@ main(int argc, char **argv)
 
 	g_log_set_always_fatal(G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL);
 
-	sound_init();
-
 	gtk_init(&argc, &argv);
 	gconf_init(argc, argv, NULL);
 
diff --git a/src/daemon/sound.c b/src/daemon/sound.c
index 0e18a51..a524e98 100644
--- a/src/daemon/sound.c
+++ b/src/daemon/sound.c
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
  * sound.c - Sound support portion of the destop notification spec
  *
  * Copyright (C) 2007 Jim Ramsay <i am jimramsay com>
@@ -22,64 +23,17 @@
 
 #include "sound.h"
 
-#ifdef HAVE_GSTREAMER
-#include <gst/gst.h>
-
-static GstElement *player;
-
-static void
-sound_play_uri(const gchar* uri)
-{
-	if (player == NULL)
-		return;
-
-	/*
-	 * TODO: Fade out the current sound and then start the new sound?
-	 *       Right now we just cut off the existing sound, which is kind of
-	 *       abrupt
-	 */
-
-	/* Stop the pipeline */
-	gst_element_set_state(player, GST_STATE_NULL);
-
-	/* Set the input to a local file uri */
-	g_object_set(G_OBJECT(player), "uri", uri, NULL);
-
-	/* Start the pipeline again */
-	gst_element_set_state(player, GST_STATE_PLAYING);
-}
-#endif /* HAVE_GSTREAMER */
-
-void
-sound_init(void)
-{
-#ifdef HAVE_GSTREAMER
-	gst_init(NULL, NULL);
-
-	player = gst_element_factory_make("playbin", "Notification Player");
-
-	if (player != NULL)
-	{
-		/*
-		 * Instead of using the default audiosink, use the gconfaudiosink,
-		 * which will respect the defaults in gstreamer-properties
-		 */
-		g_object_set(G_OBJECT(player), "audio-sink",
-			gst_element_factory_make("gconfaudiosink", "GconfAudioSink"),
-			NULL);
-	}
-#endif /* HAVE_GSTREAMER */
-}
+#include <glib/gi18n.h>
+#include <canberra-gtk.h>
 
 void
-sound_play(const gchar* filename)
+sound_play_file(GtkWidget *widget,
+		const char *filename)
 {
-	/* We are guaranteed here that the file exists */
-#ifdef HAVE_GSTREAMER
-	/* gstreamer's playbin takes uris, so make a file:// uri */
-	gchar* uri = g_strdup_printf("file://%s", filename);
-	sound_play_uri(uri);
-	g_free(uri);
-#endif /* HAVE_GSTREAMER */
+	ca_gtk_play_for_widget (widget, 0,
+				CA_PROP_MEDIA_ROLE, "event",
+				CA_PROP_MEDIA_FILENAME, filename,
+				CA_PROP_EVENT_DESCRIPTION, _("Notification"),
+				NULL);
 }
 
diff --git a/src/daemon/sound.h b/src/daemon/sound.h
index 8426f0a..ca687b3 100644
--- a/src/daemon/sound.h
+++ b/src/daemon/sound.h
@@ -21,10 +21,9 @@
 #ifndef _SOUND_H
 #define _SOUND_H
 
-#include <glib.h>
+#include <gtk/gtk.h>
 
-void sound_init(void);
-
-void sound_play(const gchar *filename);
+void sound_play_file(GtkWidget *widget,
+                     const char *filename);
 
 #endif /* _SOUND_H */



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