[gnome-games] libgames-support: Drop SDL-mixer sound support
- From: Christian Persch <chpe src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-games] libgames-support: Drop SDL-mixer sound support
- Date: Wed, 2 Dec 2009 20:38:23 +0000 (UTC)
commit 621c7e51492ffac910fbc7b70b5386c3c14f68d4
Author: Christian Persch <chpe gnome org>
Date: Wed Dec 2 21:29:05 2009 +0100
libgames-support: Drop SDL-mixer sound support
That leaves libcanberra-gtk as the one and only sound library. Finally!
aisleriot/window.c | 14 ++--
configure.in | 44 +--------
libgames-support/Makefile.am | 7 +--
libgames-support/games-runtime.c | 2 +-
libgames-support/games-sound.c | 90 +------------------
m4/sdl.m4 | 182 --------------------------------------
m4/sound.m4 | 30 ------
7 files changed, 17 insertions(+), 352 deletions(-)
---
diff --git a/aisleriot/window.c b/aisleriot/window.c
index 8be0102..59e9032 100644
--- a/aisleriot/window.c
+++ b/aisleriot/window.c
@@ -1903,7 +1903,7 @@ game_exception_cb (AisleriotGame *game,
gtk_widget_show (dialog);
}
-#if defined(HAVE_CLUTTER) || (defined(HAVE_CANBERRA_GTK) && GTK_CHECK_VERSION (2, 14, 0))
+#if defined(HAVE_CLUTTER) || (defined(ENABLE_SOUND) && GTK_CHECK_VERSION (2, 14, 0))
static void
settings_changed_cb (GtkSettings *settings,
@@ -1929,14 +1929,14 @@ settings_changed_cb (GtkSettings *settings,
}
#endif /* HAVE_CLUTTER */
-#if defined(HAVE_CANBERRA_GTK) && GTK_CHECK_VERSION (2, 14, 0)
+#if defined(ENABLE_SOUND) && GTK_CHECK_VERSION (2, 14, 0)
if (name == NULL || strcmp (name, "gtk-enable-event-sounds") == 0) {
g_object_get (settings, "gtk-enable-event-sounds", &enabled, NULL);
action = gtk_action_group_get_action (priv->action_group, "Sound");
gtk_action_set_visible (action, enabled);
}
-#endif /* HAVE_CANBERRA_GTK && GTK >= 2.14 */
+#endif /* ENABLE_SOUND && GTK >= 2.14 */
}
static void
@@ -1968,13 +1968,13 @@ screen_changed_cb (GtkWidget *widget,
g_signal_connect (settings, "notify::gtk-enable-animations",
G_CALLBACK (settings_changed_cb), window);
#endif
-#if defined (HAVE_CANBERRA_GTK) && GTK_CHECK_VERSION (2, 14, 0)
+#if defined (ENABLE_SOUND) && GTK_CHECK_VERSION (2, 14, 0)
g_signal_connect (settings, "notify::gtk-enable-event-sounds",
G_CALLBACK (settings_changed_cb), window);
#endif
}
-#endif /* HAVE_CLUTTER || HAVE_CANBERRA_GTK */
+#endif /* HAVE_CLUTTER || ENABLE_SOUND && GTK+ >= 2.14.0 */
/*
* aisleriot_window_set_freecell_mode:
@@ -2637,12 +2637,12 @@ aisleriot_window_init (AisleriotWindow *window)
#endif /* HAVE_CLUTTER */
-#if defined(HAVE_CLUTTER) || (defined(HAVE_CANBERRA_GTK) && GTK_CHECK_VERSION (2, 14, 0))
+#if defined(HAVE_CLUTTER) || (defined(ENABLE_SOUND) && GTK_CHECK_VERSION (2, 14, 0))
/* Set the action visibility and listen for animation and sound mode changes */
screen_changed_cb (GTK_WIDGET (window), NULL, window);
g_signal_connect (window, "screen-changed",
G_CALLBACK (screen_changed_cb), window);
-#endif /* HAVE_CLUTTER || HAVE_CANBERRA_GTK */
+#endif /* HAVE_CLUTTER || ENABLE_SOUND && GTK+ >= 2.14.0 */
/* Now set up the widgets */
main_vbox = gtk_vbox_new (FALSE, 0);
diff --git a/configure.in b/configure.in
index 27f4eb0..90dd7e6 100644
--- a/configure.in
+++ b/configure.in
@@ -353,7 +353,7 @@ AM_CONDITIONAL([PLATFORM_WIN32_NATIVE],[test "$os_win32" = "yes"])
if test "$want_sound" = "yes"; then
AC_MSG_CHECKING([whether to enable sound support])
AC_ARG_ENABLE([sound],
- [AS_HELP_STRING([--enable-sound],[Enable sound with GStreamer or SDL_Mixer.])],
+ [AS_HELP_STRING([--enable-sound],[Enable sound using libcanberra])],
[],[case "$with_platform" in
gnome|gtk-only) enable_sound=yes ;;
hildon) case "$with_platform_variant" in
@@ -366,18 +366,6 @@ else
enable_sound=no
fi
-# Check which sound library to use
-
-if test "$enable_sound" = "yes"; then
- AC_MSG_CHECKING([for which sound library to use])
- AC_ARG_WITH([sound],
- [AS_HELP_STRING([--with-sound=libcanberra|sdl_mixer (default: libcanberra)])],
- [],[with_sound=libcanberra])
- AC_MSG_RESULT([$with_sound])
-else
- with_sound=no
-fi
-
# Clutter
# We're using need_guile as a quick way to check whether building aisleriot
@@ -664,39 +652,15 @@ AM_CONDITIONAL([HAVE_PYTHON],[test "$enable_python" = "yes"])
AM_CONDITIONAL([WITH_GTHREAD],[test "$need_gthread" = "yes"])
-# Sound support: Libcanberra, GStreamer or SDL_mixer
+# libcanberra
if test "$enable_sound" = "yes"; then
- AC_DEFINE([ENABLE_SOUND],[1],[Define if sound support is enabled])
-fi
-
-have_libcanberra=no
-if test "$enable_sound" = "yes" -a "$with_sound" = "libcanberra"; then
PKG_CHECK_MODULES([CANBERRA_GTK],[libcanberra-gtk >= $LIBCANBERRA_GTK_REQUIRED],[],
- [AC_MSG_ERROR([Sound support using libcanberra was requested, but libcanberra-gtk not found.])])
+ [AC_MSG_ERROR([Sound support was requested, but libcanberra-gtk not found.])])
- AC_DEFINE([HAVE_CANBERRA_GTK],[1],[Define if libcanberra-gtk support is enabled])
- have_libcanberra=yes
-fi
-
-if test "$enable_sound" = "yes" -a "$with_sound" = "sdl_mixer"; then
- # Check for SDL_Mixer sound support, sets SDL_MIXER_CFLAGS, SDL_MIXER_LIBS, AUDIO_SDL
- GAMES_CHECK_SOUND()
-
- if test "$SDL_mixer" = "no"; then
- AC_MSG_ERROR([Sound support using SDL-Mixer was requested, but SDL-Mixer not found.])
- fi
-fi
-
-if test "x$SDL_mixer" = "xyes"; then
- AC_SUBST(SDL_MIXER_CFLAGS)
- AC_SUBST(SDL_MIXER_LIBS)
-
- AC_DEFINE([HAVE_SDL_MIXER],[1],[Define if SDL_Mixer is available])
+ AC_DEFINE([ENABLE_SOUND],[1],[Define if sound support is enabled])
fi
-AM_CONDITIONAL([HAVE_CANBERRA_GTK],[test "$have_libcanberra" = "yes"])
-AM_CONDITIONAL([HAVE_SDL_MIXER],[test "x$SDL_mixer" = "xyes"])
AM_CONDITIONAL([ENABLE_SOUND],[test "$enable_sound" = "yes"])
# SMClient
diff --git a/libgames-support/Makefile.am b/libgames-support/Makefile.am
index 506074a..0d3e987 100644
--- a/libgames-support/Makefile.am
+++ b/libgames-support/Makefile.am
@@ -137,16 +137,11 @@ libgames_support_la_CFLAGS += $(RSVG_CFLAGS)
libgames_support_la_LIBADD += $(RSVG_LIBS)
endif
-if HAVE_CANBERRA_GTK
+if ENABLE_SOUND
libgames_support_la_CFLAGS += $(CANBERRA_GTK_CFLAGS)
libgames_support_la_LIBADD += $(CANBERRA_GTK_LIBS)
endif
-if HAVE_SDL_MIXER
-libgames_support_la_CFLAGS += $(SDL_MIXER_CFLAGS)
-libgames_support_la_LIBADD += $(SDL_MIXER_LIBS)
-endif
-
if HAVE_HILDON
libgames_support_la_CFLAGS += $(HILDON_CFLAGS)
libgames_support_la_LIBADD += $(HILDON_LIBS)
diff --git a/libgames-support/games-runtime.c b/libgames-support/games-runtime.c
index 1a23239..8218f86 100644
--- a/libgames-support/games-runtime.c
+++ b/libgames-support/games-runtime.c
@@ -346,7 +346,7 @@ games_runtime_init (const char *name)
}
#endif /* G_OS_WIN32 */
-#if defined(HAVE_GNOME) || defined(HAVE_RSVG_GNOMEVFS) || defined(HAVE_CANBERRA_GTK)
+#if defined(HAVE_GNOME) || defined(HAVE_RSVG_GNOMEVFS) || defined(ENABLE_SOUND)
/* If we're going to use gconf, gnome-vfs, or canberra, we need to
* init threads; and this has to be done before calling any other glib functions.
*/
diff --git a/libgames-support/games-sound.c b/libgames-support/games-sound.c
index 2b32915..bf064aa 100644
--- a/libgames-support/games-sound.c
+++ b/libgames-support/games-sound.c
@@ -25,11 +25,8 @@
#include <glib.h>
#include <glib/gi18n.h>
-#if defined(HAVE_CANBERRA_GTK)
+#ifdef ENABLE_SOUND
#include <canberra-gtk.h>
-#elif defined(HAVE_SDL_MIXER)
-#include "SDL.h"
-#include "SDL_mixer.h"
#endif
#include "games-debug.h"
@@ -39,42 +36,14 @@
#ifdef ENABLE_SOUND
-static gboolean sound_enabled = FALSE;
-
-#ifdef HAVE_SDL_MIXER
-
-static gboolean sound_init = FALSE;
-
-static void
-games_sound_sdl_play (const gchar *filename)
-{
- Mix_Chunk *wave = NULL;
- gchar *name, *path;
-
- name = g_strdup_printf ("%s.ogg", filename);
- path = games_runtime_get_file (GAMES_RUNTIME_SOUND_DIRECTORY, name);
- g_free (name);
-
- wave = Mix_LoadWAV (path);
- if (wave == NULL) {
- _games_debug_print (GAMES_DEBUG_SOUND,
- "Error playing sound %s: %s\n", path, Mix_GetError ());
- }
-
- Mix_PlayChannel (-1, wave, 0);
- g_free (path);
-}
-
-#endif /* HAVE_SDL_MIXER */
-
-#ifdef HAVE_CANBERRA_GTK
-
#ifdef CA_CHECK_VERSION
#if CA_CHECK_VERSION (0, 13)
#define HAVE_CANBERRA_GTK_MULTIHEAD_SAFE
#endif
#endif
+static gboolean sound_enabled = FALSE;
+
typedef enum {
GAMES_SOUND_PLAIN,
GAMES_SOUND_FOR_EVENT,
@@ -151,38 +120,6 @@ games_sound_canberra_play (const char *sound_name,
g_free (path);
}
-#endif /* HAVE_CANBERRA_GTK */
-
-#ifdef HAVE_SDL_MIXER
-
-/* Initializes the games-sound support */
-static void
-games_sound_init (void)
-{
- const int audio_rate = MIX_DEFAULT_FREQUENCY;
- const int audio_format = MIX_DEFAULT_FORMAT;
- const int audio_channels = 2;
-
-/* Sounds don't sound good on Windows unless the buffer size is 4k,
- * but this seems to cause strange behaviour on other systems,
- * such as a delay before playing the sound. */
-#ifdef G_OS_WIN32
- const size_t buf_size = 4096;
-#else
- const size_t buf_size = 1024;
-#endif
-
- SDL_Init (SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE);
-
- if (Mix_OpenAudio (audio_rate, audio_format, audio_channels, buf_size) < 0) {
- _games_debug_print (GAMES_DEBUG_SOUND,
- "Error calling Mix_OpenAudio\n");
- return;
- }
-}
-
-#endif /* HAVE_SDL_MIXER */
-
#endif /* ENABLE_SOUND */
/**
@@ -198,7 +135,6 @@ void
games_sound_init (GdkScreen *screen)
{
#ifdef ENABLE_SOUND
-#ifdef HAVE_CANBERRA_GTK
ca_context *context;
if (screen == NULL)
@@ -226,7 +162,6 @@ games_sound_init (GdkScreen *screen)
NULL);
g_object_set_data (G_OBJECT (screen), "games-sound-initialised", GINT_TO_POINTER (TRUE));
-#endif /* HAVE_CANBERRA_GTK */
#endif /* ENABLE_SOUND */
}
@@ -264,17 +199,8 @@ void
games_sound_play_for_screen (const gchar * sound_name,
GdkScreen *screen)
{
-#if defined(HAVE_CANBERRA_GTK)
+#if defined(ENABLE_SOUND)
games_sound_canberra_play (sound_name, GAMES_SOUND_PLAIN, screen);
-
-#elif defined(HAVE_SDL_MIXER)
-
- if (!sound_enabled)
- return;
- if (!sound_init)
- games_sound_init ();
-
- games_sound_sdl_play (sound_name);
#endif
}
@@ -291,11 +217,7 @@ games_sound_play_for_event (const gchar *sound_name,
GdkEvent *event)
{
#ifdef ENABLE_SOUND
-#ifdef HAVE_CANBERRA_GTK
games_sound_canberra_play (sound_name, GAMES_SOUND_FOR_EVENT, event);
-#else
- games_sound_play (sound_name);
-#endif /* HAVE_CANBERRA_GTK */
#endif /* ENABLE_SOUND */
}
@@ -314,11 +236,7 @@ games_sound_play_for_widget (const gchar *sound_name,
GtkWidget *widget)
{
#ifdef ENABLE_SOUND
-#ifdef HAVE_CANBERRA_GTK
games_sound_canberra_play (sound_name, GAMES_SOUND_FOR_WIDGET, widget);
-#else
- games_sound_play (sound_name);
-#endif /* HAVE_CANBERRA_GTK */
#endif /* ENABLE_SOUND */
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]