[cheese] Use libcanberra instead of GStreamer for shutter



commit b7a59578b99016a79e613f8bb69f5b5e455258bb
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Nov 27 15:33:54 2009 +0000

    Use libcanberra instead of GStreamer for shutter
    
    https://bugzilla.gnome.org/show_bug.cgi?id=603152

 configure.ac             |    4 +-
 data/Makefile.am         |    2 +-
 data/sounds/Makefile.am  |   12 ---
 data/sounds/shutter0.ogg |  Bin 9420 -> 0 bytes
 data/sounds/shutter1.ogg |  Bin 30289 -> 0 bytes
 data/sounds/shutter2.ogg |  Bin 17024 -> 0 bytes
 data/sounds/shutter3.ogg |  Bin 26650 -> 0 bytes
 data/sounds/shutter4.ogg |  Bin 22302 -> 0 bytes
 src/Makefile.am          |    2 -
 src/cheese-window.c      |   38 ++--------
 src/gst-audio-play.c     |  200 ----------------------------------------------
 src/gst-audio-play.h     |   60 --------------
 12 files changed, 9 insertions(+), 309 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index c91af8f..c065569 100644
--- a/configure.ac
+++ b/configure.ac
@@ -89,7 +89,8 @@ PKG_CHECK_MODULES(CHEESE, \
   dbus-glib-1 >= $DBUS_GLIB_REQUIRED \
   hal >= $HAL_REQUIRED \
   pangocairo >= $PANGOCAIRO_REQUIRED \
-  librsvg-2.0 >= $LIBRSVG_REQUIRED)
+  librsvg-2.0 >= $LIBRSVG_REQUIRED
+  libcanberra-gtk)
 AC_SUBST(CHEESE_CFLAGS)
 
 CHEESE_LIBS="$CHEESE_LIBS -lgstinterfaces-0.10"
@@ -148,7 +149,6 @@ data/icons/32x32/actions/Makefile
 data/icons/48x48/actions/Makefile
 data/icons/scalable/actions/Makefile
 data/pixmaps/Makefile
-data/sounds/Makefile
 help/Makefile
 src/Makefile
 po/Makefile.in
diff --git a/data/Makefile.am b/data/Makefile.am
index 7002d84..fd51161 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = icons effects pixmaps sounds
+SUBDIRS = icons effects pixmaps
 
 @INTLTOOL_DESKTOP_RULE@
 desktopdir = $(datadir)/applications
diff --git a/src/Makefile.am b/src/Makefile.am
index 21cb8a9..233c71a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -36,8 +36,6 @@ cheese_SOURCES = \
 	eog-thumb-nav.h \
 	ephy-spinner.c \
 	ephy-spinner.h \
-	gst-audio-play.c \
-	gst-audio-play.h \
 	cheese-no-camera.c \
 	cheese-no-camera.h \
 	cheese-prefs-widget.h \
diff --git a/src/cheese-window.c b/src/cheese-window.c
index 88b0d24..29cc38e 100644
--- a/src/cheese-window.c
+++ b/src/cheese-window.c
@@ -38,6 +38,7 @@
 #include <gst/interfaces/xoverlay.h>
 #include <gtk/gtk.h>
 #include <libebook/e-book.h>
+#include <canberra-gtk.h>
 
 #ifdef HAVE_MMKEYS
   #include <X11/XF86keysym.h>
@@ -51,12 +52,10 @@
 #include "eog-thumb-nav.h"
 #include "cheese-window.h"
 #include "ephy-spinner.h"
-#include "gst-audio-play.h"
 #include "cheese-no-camera.h"
 #include "cheese-prefs-dialog.h"
 #include "cheese-flash.h"
 
-#define SHUTTER_SOUNDS             5
 #define FULLSCREEN_POPUP_HEIGHT    40
 #define FULLSCREEN_TIMEOUT         5 * 1000
 #define FULLSCREEN_EFFECTS_TIMEOUT 15
@@ -175,8 +174,6 @@ typedef struct
 
   GSource *fullscreen_timeout_source;
 
-  int audio_play_counter;
-
   gint repeat_count;
   gboolean is_bursting;
 
@@ -196,22 +193,6 @@ cheese_window_bring_to_front (gpointer data)
   gtk_window_present (GTK_WINDOW (cheese_window->window));
 }
 
-static char *
-audio_play_get_filename (CheeseWindow *cheese_window)
-{
-  char *filename;
-
-  if (cheese_window->audio_play_counter > 21)
-    filename = g_strdup_printf ("%s/sounds/shutter%i.ogg", PACKAGE_DATADIR,
-                                g_random_int_range (0, SHUTTER_SOUNDS));
-  else
-    filename = g_strdup_printf ("%s/sounds/shutter0.ogg", PACKAGE_DATADIR);
-
-  cheese_window->audio_play_counter++;
-
-  return filename;
-}
-
 /* standard event handler */
 static int
 cheese_window_delete_event_cb (GtkWidget *widget, GdkEvent event, gpointer data)
@@ -1267,9 +1248,6 @@ void
 cheese_window_countdown_picture_cb (gpointer data)
 {
   CheeseWindow *cheese_window = (CheeseWindow *) data;
-  GError       *error         = NULL;
-  GstAudioPlay *audio_play;
-  char         *shutter_filename;
   char         *photo_filename;
 
   if (cheese_window->webcam_mode == WEBCAM_MODE_BURST)
@@ -1284,14 +1262,11 @@ cheese_window_countdown_picture_cb (gpointer data)
   if (cheese_webcam_take_photo (cheese_window->webcam, photo_filename))
   {
     cheese_flash_fire (cheese_window->flash);
-    shutter_filename = audio_play_get_filename (cheese_window);
-    audio_play       = gst_audio_play_file (shutter_filename, &error);
-    if (!audio_play)
-    {
-      g_warning ("%s", error ? error->message : "Unknown error");
-      g_error_free (error);
-    }
-    g_free (shutter_filename);
+    ca_gtk_play_for_widget (cheese_window->screen, 0,
+                            CA_PROP_EVENT_ID, "camera-shutter",
+                            CA_PROP_MEDIA_ROLE, "event",
+                            CA_PROP_EVENT_DESCRIPTION, _("Shutter sound"),
+                            NULL);
   }
   g_free (photo_filename);
 }
@@ -2141,7 +2116,6 @@ cheese_window_init (char *hal_dev_udi, CheeseDbus *dbus_server, gboolean startup
   cheese_window->gconf               = cheese_gconf_new ();
   cheese_window->fileutil            = cheese_fileutil_new ();
   cheese_window->flash               = cheese_flash_new ();
-  cheese_window->audio_play_counter  = 0;
   cheese_window->isFullscreen        = FALSE;
   cheese_window->is_bursting         = FALSE;
 



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