gok r2690 - in trunk: . gok



Author: gerdk
Date: Thu Apr  2 17:04:35 2009
New Revision: 2690
URL: http://svn.gnome.org/viewvc/gok?rev=2690&view=rev

Log:
2009-04-02  Gerd Kohlberger  <gerdk svn gnome org>

	Migrate to libcanberra. Bug #572913
	
	* gok/gok-sound.c:
	* gok/gok-sound.c:
		migrate to libcanberra
	* gok/test-gok-sound:
		remove unused and now broken test case
	* gok/main.c:
		gok_sound_shutdown() is no longer needed
	* configure.in:
		bump gtk+ dependency to 2.12;
		new dependency: libcanberra and libcanberra-gtk >= 0.3
	* Makefile.am:
		install sound files into the freedesktop sound-theme
	* gok/Makefile.am:
		remove test case	
	* gok-with-references.schemas.m4:
	* gok-with-references.schemas.in:
		switch to $sounddir
	* goksound1.wav:
	* goksound2.wav:
		use new sounds



Removed:
   trunk/gok/test-gok-sound.c
Modified:
   trunk/ChangeLog
   trunk/Makefile.am
   trunk/configure.in
   trunk/gok-with-references.schemas.in
   trunk/gok-with-references.schemas.m4
   trunk/gok/Makefile.am
   trunk/gok/gok-sound.c
   trunk/gok/gok-sound.h
   trunk/gok/main.c
   trunk/goksound1.wav
   trunk/goksound2.wav

Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am	(original)
+++ trunk/Makefile.am	Thu Apr  2 17:04:35 2009
@@ -45,6 +45,11 @@
 icondir = $(datadir)/icons/hicolor/48x48/apps
 icon_DATA = gok.png
 
+sounddir = $(datadir)/sounds/freedesktop/stereo
+sound_DATA =		\
+	goksound1.wav	\
+	goksound2.wav
+
 gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
 
 install-data-hook: update-icon-cache
@@ -78,8 +83,6 @@
 	manage.kbd                     \
 	dictionary.txt                 \
 	gok.rc                         \
-	goksound1.wav                  \
-	goksound2.wav		\
 	latched.png		\
 	locked.png		\
 	empty.png		\

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Thu Apr  2 17:04:35 2009
@@ -169,11 +169,12 @@
 	libloginhelper-1.0 >= 1.5.2 \
 	libbonobo-2.0 >= 2.5.1  \
 	atk >= 1.3.0            \
-	gtk+-2.0 >= 2.3.1       \
+	gtk+-2.0 >= 2.12.0	\
 	gail                    \
 	libwnck-1.0             \
 	gnome-speech-1.0        \
 	esound			\
+	libcanberra-gtk >= 0.3	\
 	libglade-2.0)
 AC_SUBST(GOK_LIBS)
 AC_SUBST(GOK_CFLAGS)

Modified: trunk/gok-with-references.schemas.in
==============================================================================
--- trunk/gok-with-references.schemas.in	(original)
+++ trunk/gok-with-references.schemas.in	Thu Apr  2 17:04:35 2009
@@ -1454,7 +1454,7 @@
       <applyto>/apps/gok/feedbacks/goksound1/soundname</applyto>
       <owner>gok</owner>
       <type>string</type>
-      <default>$pkgdatadir/goksound1.wav</default>
+      <default>$sounddir/goksound1.wav</default>
       <locale name="C">
         <short>The name of the sound that this feedback will play</short>
         <long></long>
@@ -1531,7 +1531,7 @@
       <applyto>/apps/gok/feedbacks/goksound2/soundname</applyto>
       <owner>gok</owner>
       <type>string</type>
-      <default>$pkgdatadir/goksound2.wav</default>
+      <default>$sounddir/goksound2.wav</default>
       <locale name="C">
         <short>The name of the sound that this feedback will play</short>
         <long></long>

Modified: trunk/gok-with-references.schemas.m4
==============================================================================
--- trunk/gok-with-references.schemas.m4	(original)
+++ trunk/gok-with-references.schemas.m4	Thu Apr  2 17:04:35 2009
@@ -224,9 +224,9 @@
     mkfeedback(`key_flashing', `Key flashing', `true', `4', `false', `none',
                `false', `true')
     mkfeedback(`goksound1', `Sound one', `false', `0', `true',
-               `$pkgdatadir/goksound1.wav', `false', `true')
+               `$sounddir/goksound1.wav', `false', `true')
     mkfeedback(`goksound2', `Sound two', `false', `0', `true',
-               `$pkgdatadir/goksound2.wav', `false', `true')
+               `$sounddir/goksound2.wav', `false', `true')
     mkfeedback(`gokspeech', `Speech', `false', `0', `false',
                `none', `true', `true')
   </schemalist>

Modified: trunk/gok/Makefile.am
==============================================================================
--- trunk/gok/Makefile.am	(original)
+++ trunk/gok/Makefile.am	Thu Apr  2 17:04:35 2009
@@ -1,6 +1,6 @@
 bin_PROGRAMS = gok create-branching-keyboard
 
-noinst_PROGRAMS = test-gok-action test-gok-feedback test-gok-sound test-gok-bounds test-gok-wordcomplete keyboard-geometry 
+noinst_PROGRAMS = test-gok-action test-gok-feedback test-gok-bounds test-gok-wordcomplete keyboard-geometry 
 
 serverdir = $(libdir)/bonobo/servers
 server_in_files = GNOME_Gok.server.in.in
@@ -123,11 +123,6 @@
 	gok-sound.c gok-sound.h				\
 	gok-speech.c gok-speech.h
 
-test_gok_sound_SOURCES = \
-	test-gok-sound.c                                 \
-	gok-sound.c gok-sound.h                          \
-	gok-log.c gok-log.h gok-log-priv.h
-
 test_gok_bounds_SOURCES = \
 	test-gok-bounds.c                                \
 	gok-bounds.c gok-bounds.h

Modified: trunk/gok/gok-sound.c
==============================================================================
--- trunk/gok/gok-sound.c	(original)
+++ trunk/gok/gok-sound.c	Thu Apr  2 17:04:35 2009
@@ -1,126 +1,97 @@
 /*
-* gok-sound.c
-*
-* Copyright 2002 Sun Microsystems, Inc.,
-* Copyright 2002 University Of Toronto
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Library General Public
-* License as published by the Free Software Foundation; either
-* version 2 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-* Library General Public License for more details.
-*
-* You should have received a copy of the GNU Library General Public
-* License along with this library; if not, write to the
-* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-* Boston, MA 02111-1307, USA.
-*/
+ * gok-sound.c
+ *
+ * Copyright 2002-2009 Sun Microsystems, Inc.,
+ * Copyright 2002-2009 University Of Toronto
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
-#include <gnome.h>
-#include <libgnome/gnome-sound.h>
-#include <esd.h>
+#include <glib/gi18n.h>
+#include <canberra-gtk.h>
+
 #include "gok-sound.h"
 #include "gok-log.h"
 
-static void free_entry (gpointer soundfile, gpointer sample_id,
-                        gpointer user_data);
-
-static gint gnome_sound_connection;
-static GHashTable *stored_sounds;
+#define SOUND_ID 0
 
 /**
  * gok_sound_initialize:
  *
  * Initialises gok-sound.
- */
-void gok_sound_initialize ()
+ **/
+void
+gok_sound_initialize (void)
 {
-    gok_log_enter ();
-    gnome_sound_init ("localhost");
-    gnome_sound_connection = gnome_sound_connection_get ();
-    stored_sounds = g_hash_table_new (g_str_hash, g_str_equal);
-    gok_log_leave ();
-}
+    ca_proplist *prop;
 
-/**
- * gok_sound_shutdown:
- *
- * Shuts down gok-sound and frees any loaded sounds.
- */
-void gok_sound_shutdown ()
-{
     gok_log_enter ();
-    g_hash_table_foreach (stored_sounds, free_entry, NULL);
-    g_hash_table_destroy (stored_sounds);
-    fsync (gnome_sound_connection);
-    gnome_sound_shutdown ();
-    gok_log_leave ();
-}
 
-void free_entry (gpointer soundfile, gpointer sample_id, gpointer user_data)
-{
-    esd_sample_free (gnome_sound_connection, *((gint *)sample_id) );
-    gok_log ("Freed sample_id %d", *((gint *)sample_id) );
-    g_free (soundfile);
-    g_free (sample_id);
+    /* attach some common properties */
+    ca_proplist_create (&prop);
+    ca_proplist_sets (prop, CA_PROP_APPLICATION_NAME, _("GOK"));
+    ca_proplist_sets (prop, CA_PROP_APPLICATION_VERSION, VERSION);
+    ca_proplist_sets (prop, CA_PROP_APPLICATION_ICON_NAME, "gok");
+    ca_proplist_sets (prop, CA_PROP_EVENT_DESCRIPTION, _("Key Feedback"));
+
+    ca_proplist_sets (prop, CA_PROP_CANBERRA_CACHE_CONTROL, "permanent");
+
+    ca_context_change_props_full (ca_gtk_context_get (), prop);
+    ca_proplist_destroy (prop);
+
+    gok_log ("Sound initialized.");
+
+    gok_log_leave ();
 }
 
 /**
  * gok_sound_play:
  * @soundfile: The sound file to play.
  *
- * Plays the sound file @soundfile. The @soundfile is stored in a cache
- * the first time that it is played and from then on the sound is played
- * from the cache.
- */
-void gok_sound_play (gchar *soundfile)
+ * Plays @soundfile.
+ *
+ * Returns: 0 on success, negative value otherwise.
+ **/
+gint
+gok_sound_play (const gchar *soundfile)
 {
-    gchar *copy_of_soundfile;
-    gint *sample_id;
+    gint res;
+
+    g_return_val_if_fail (soundfile != NULL, -1);
 
     gok_log_enter ();
 
-    /* Have we already loaded soundfile? */
-    if ( (sample_id = g_hash_table_lookup (stored_sounds, soundfile))
-         == NULL)
-    {
-        copy_of_soundfile = g_strdup (soundfile);
-        sample_id = g_malloc (sizeof (gint));
-
-        gok_log ("Loading soundfile %s", copy_of_soundfile);
-        *sample_id = gnome_sound_sample_load (copy_of_soundfile,
-                                              copy_of_soundfile);
-        gok_log ("*sample_id = %d", *sample_id);
-
-        if (*sample_id < 0)
-        {
-            gok_log_x ("Error loading soundfile %s", copy_of_soundfile);
-            g_free (copy_of_soundfile);
-            g_free (sample_id);
-            gok_log_leave ();
-            return;
-        }
-        else
-        {
-            g_hash_table_insert (stored_sounds, copy_of_soundfile, 
-                                 sample_id);
-        }
-    }
+    res = ca_context_play (ca_gtk_context_get (),
+			   SOUND_ID,
+			   CA_PROP_MEDIA_FILENAME, soundfile,
+			   NULL);
+
+    if (res == CA_ERROR_DISABLED)
+	gok_log ("System sounds are disabled.");
+    else if (res == CA_SUCCESS)
+	gok_log ("Playing soundfile %s.", soundfile);
     else
-    {
-        gok_log ("Playing soundfile %s from stored_sounds with sample_id %d",
-                 soundfile, *sample_id);
-    }
-    
-    esd_sample_play (gnome_sound_connection, *sample_id);
+	gok_log ("Failed to play soundfile %s. Code %i: %s.",
+		 soundfile, res, ca_strerror (res));
 
     gok_log_leave ();
+
+    return res;
 }

Modified: trunk/gok/gok-sound.h
==============================================================================
--- trunk/gok/gok-sound.h	(original)
+++ trunk/gok/gok-sound.h	Thu Apr  2 17:04:35 2009
@@ -1,25 +1,33 @@
 /*
-* gok-sound.h
-*
-* Copyright 2002 Sun Microsystems, Inc.,
-* Copyright 2001 University Of Toronto
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Library General Public
-* License as published by the Free Software Foundation; either
-* version 2 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-* Library General Public License for more details.
-*
-* You should have received a copy of the GNU Library General Public
-* License along with this library; if not, write to the
-* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-* Boston, MA 02111-1307, USA.
-*/
+ * gok-sound.h
+ *
+ * Copyright 2002-2009 Sun Microsystems, Inc.,
+ * Copyright 2001-2009 University Of Toronto
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
 
-void gok_sound_initialize ();
-void gok_sound_shutdown ();
-void gok_sound_play (gchar *soundfile);
+#ifndef __GOK_SOUND_H__
+#define __GOK_SOUND_H__
+
+G_BEGIN_DECLS
+
+void gok_sound_initialize (void);
+gint gok_sound_play       (const gchar *soundfile);
+
+G_END_DECLS
+
+#endif /* __GOK_SOUND_H__ */

Modified: trunk/gok/main.c
==============================================================================
--- trunk/gok/main.c	(original)
+++ trunk/gok/main.c	Thu Apr  2 17:04:35 2009
@@ -2808,7 +2808,6 @@
 	gok_data_close();
 
 	closeSwitchApi();
-	gok_sound_shutdown();
 	gok_modifier_close();
 	gok_action_close();
 	gok_feedback_close();

Modified: trunk/goksound1.wav
==============================================================================
Binary files. No diff available.

Modified: trunk/goksound2.wav
==============================================================================
Binary files. No diff available.



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