### INITIALIZATION ############################################################
-AC_PREREQ([2.62]) # Oldest version of Autoconf that works with introspection
+AC_PREREQ([2.64]) # Newest feature: m4_map_args_w
# Initialize Autoconf
# Args: (human-readable package name, package version, bug report address,
# tarballname)
### SOUND LIBRARY TO USE ######################################################
-AC_ARG_WITH([gstreamer],
- [AS_HELP_STRING([--without-gstreamer], [Disable GStreamer sound])],
+AC_ARG_WITH([sound],
+ [AS_HELP_STRING([--with-sound=@<:@no/auto/gstreamer0.10/gstreamer1.0@:>@],
+ [Choose library with which to implement Glk sound])],
[],
- [with_gstreamer=yes])
+ [with_sound=auto])
+
+have_gstreamer0_10=no
+have_gstreamer1_0=no
+AS_IF([test "x$with_sound" != "xno"], [
+ PKG_CHECK_EXISTS([gstreamer-1.0], [have_gstreamer1_0=yes])
+ PKG_CHECK_EXISTS([gstreamer-0.10], [have_gstreamer0_10=yes])])
SOUND_MODULE=
-AS_IF([$TEST "x$with_gstreamer" != xno],
- [AC_DEFINE([GSTREAMER_SOUND], [1], [Define to enable sound support with GStreamer])
- SOUND_MODULE="gstreamer-0.10 >= 0.10.12"])
+# Autodetect sound library
+AS_IF([test "x$with_sound" = "xauto"], [
+ AC_MSG_CHECKING([which sound library to use])
+ AS_IF([test "x$have_gstreamer1_0" = "xyes"], [with_sound=gstreamer1.0], [
+ AS_IF([test "x$have_gstreamer0_10" = "xyes"],
+ [with_sound=gstreamer0.10],
+ [with_sound=no])])
+ AC_MSG_RESULT([$with_sound])])
+# Sound library to use in the end
+AS_CASE([$with_sound],
+ [gstreamer0.10], [
+ AC_DEFINE([GSTREAMER_0_10_SOUND], [1],
+ [Define to enable sound support with GStreamer 0.10])
+ SOUND_MODULE="gstreamer-0.10 >= 0.10.12"],
+ [gstreamer1.0], [
+ AC_DEFINE([GSTREAMER_1_0_SOUND], [1],
+ [Define to enable sound support with GStreamer 1.0])
+ SOUND_MODULE="gstreamer-1.0"],
+ [])
+AS_IF([test "x$with_sound" != "xno"],
+ [AC_DEFINE([HAVE_SOUND], [1], [Define if any sound support is enabled])])
### WHETHER TO GENERATE A .VAPI FILE ##########################################
# Requires vapigen
])
# GStreamer plugins needed to run library
-AS_IF([$TEST "x$with_gstreamer" != xno], [
- m4_defun([AX_GST_REQUIRE_ELEMENT],
- [AM_GST_ELEMENT_CHECK([$1],
- [],
- [AC_MSG_ERROR([GStreamer element $1 not found. You need to install gstreamer-plugins-m4_default([$2], [base]).])]
- )]
- )
- AX_GST_REQUIRE_ELEMENT([giostreamsrc])
- AX_GST_REQUIRE_ELEMENT([typefind])
- AX_GST_REQUIRE_ELEMENT([audioconvert])
- AX_GST_REQUIRE_ELEMENT([volume])
- AX_GST_REQUIRE_ELEMENT([oggdemux])
- AX_GST_REQUIRE_ELEMENT([vorbisdec])
- AX_GST_REQUIRE_ELEMENT([autoaudiosink], [good])
- AX_GST_REQUIRE_ELEMENT([aiffparse], [bad])
- AX_GST_REQUIRE_ELEMENT([modplug], [bad])
-])
+AS_CASE([$with_sound],
+ [gstreamer0.10], [
+ have_all_elements=yes
+ m4_ifdef([AM_GST_ELEMENT_CHECK], [
+ m4_map_args_w([
+ giostreamsrc
+ typefind
+ audioconvert
+ volume
+ oggdemux
+ vorbisdec
+ autoaudiosink
+ aiffparse
+ modplug],
+ [AM_GST_ELEMENT_CHECK(], [, [], [have_all_elements=no])])
+ AS_IF([test "x$have_all_elements" = "xno"],
+ [AC_MSG_ERROR([One or more required GStreamer elements were not found.
+You will have to install your system's "base", "good", and "bad" plugins
+pacakges. Try looking for names such as: gstreamer-plugins-base,
+gstreamer-plugins-good, gstreamer-plugins-bad-free,
+gstreamer-plugins-bad-free-extras, gstreamer0.10-plugins-base,
+gstreamer0.10-plugins-good, gstreamer0.10-plugins-bad])])],
+ [AC_MSG_ERROR([AM_GST_ELEMENT_CHECK not found. Install the development package
+for GStreamer 0.10 and rerun autogen.sh.])])
+ ],
+ [gstreamer1.0], [dnl aiffparse is currently broken in Fedora 19
+ have_all_elements=yes
+ m4_ifdef([GST_ELEMENT_CHECK], [
+ m4_map_args_w([
+ giostreamsrc
+ typefind
+ audioconvert
+ volume
+ oggdemux
+ vorbisdec
+ autoaudiosink
+ modplug],
+ [GST_ELEMENT_CHECK(], [, [1.0], [], [have_all_elements=no])])
+ AS_IF([test "x$have_all_elements" = "xno"],
+ [AC_MSG_ERROR([One or more required GStreamer elements were not found.
+You will have to install your system's "base", "good", and "bad" plugins
+packages. Try looking for names such as: gstreamer1-plugins-base,
+gstreamer1-plugins-good, gstreamer1-plugins-bad-free,
+gstreamer1-plugins-bad-free-extras, gstreamer1.0-plugins-base,
+gstreamer1.0-plugins-good, gstreamer1.0-plugins-bad])])],
+ [AC_MSG_ERROR([GST_ELEMENT_CHECK not found. Install the development package
+for GStreamer 1.0 and rerun autogen.sh.])])
+ ],
+ [])
# Plugin flags; include '-module' in each Makefile.am, because AC_SUBSTed
# variables are black boxes to Automake, so it has to know about it being a
case gestalt_ResourceStream:
return 1;
- /* Capabilities supported if compiled with GStreamer */
+ /* Capabilities supported if compiled with sound support */
case gestalt_Sound:
case gestalt_SoundVolume:
case gestalt_SoundNotify:
case gestalt_SoundMusic:
case gestalt_Sound2:
-#ifdef GSTREAMER_SOUND
+#ifdef HAVE_SOUND
return 1;
#else
return 0;
#include <config.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
-#ifdef GSTREAMER_SOUND
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
#include <gst/gst.h>
#endif
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
-#ifdef GSTREAMER_SOUND
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
/* Make sure GStreamer has been initialized if it hasn't been already;
in particular, if you want your program to parse GStreamer command line
options then you should do it yourself, before gtk_init(). */
-
- /* SUCKY DEBIAN: gst_is_initialized() supported from 0.10.30 onward */
- /*if( !gst_is_initialized() )*/
+
+ if( !gst_is_initialized() )
gst_init(NULL, NULL);
#endif
}
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <libchimara/glk.h>
-#ifdef GSTREAMER_SOUND
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
#include <gst/gst.h>
-#endif
+#endif /* GSTREAMER_0_10_SOUND || GSTREAMER_1_0_SOUND */
#include "magic.h"
#include "schannel.h"
#include "chimara-glk-private.h"
#define VOLUME_TIMER_RESOLUTION 1.0 /* In milliseconds */
+#ifdef GSTREAMER_0_10_SOUND
+#define OGG_MIMETYPE "application/ogg"
+#endif
+#ifdef GSTREAMER_1_0_SOUND
+#define OGG_MIMETYPE "audio/ogg"
+#endif
+
extern GPrivate glk_data_key;
-#ifdef GSTREAMER_SOUND
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
/* Stop any currently playing sound on this channel, and remove any
format-specific GStreamer elements from the channel. */
static void
on_type_found(GstElement *typefind, guint probability, GstCaps *caps, schanid_t s)
{
gchar *type = gst_caps_to_string(caps);
- if(strcmp(type, "application/ogg") == 0) {
+ if(strcmp(type, OGG_MIMETYPE) == 0) {
s->demux = gst_element_factory_make("oggdemux", NULL);
s->decode = gst_element_factory_make("vorbisdec", NULL);
if(!s->demux || !s->decode) {
finally:
g_free(type);
}
-#endif /* GSTREAMER_SOUND */
+#endif /* GSTREAMER_0_10_SOUND || GSTREAMER_1_0_SOUND */
/**
* glk_schannel_create:
schanid_t
glk_schannel_create_ext(glui32 rock, glui32 volume)
{
-#ifdef GSTREAMER_SOUND
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key);
schanid_t s = g_new0(struct glk_schannel_struct, 1);
return NULL;
#else
return NULL;
-#endif /* GSTREAMER_SOUND */
+#endif /* GSTREAMER_0_10_SOUND || GSTREAMER_1_0_SOUND */
}
/**
{
VALID_SCHANNEL(chan, return);
-#ifdef GSTREAMER_SOUND
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key);
if(!gst_element_set_state(chan->pipeline, GST_STATE_NULL))
chan->magic = MAGIC_FREE;
g_free(chan);
-#endif
+#endif /* GSTREAMER_0_10_SOUND || GSTREAMER_1_0_SOUND */
}
/**
{
VALID_SCHANNEL_OR_NULL(chan, return NULL);
-#ifdef GSTREAMER_SOUND
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key);
GList *retnode;
return retval;
#else
return NULL;
-#endif /* GSTREAMER_SOUND */
+#endif /* GSTREAMER_0_10_SOUND || GSTREAMER_1_0_SOUND */
}
/**
glk_schannel_play_ext(schanid_t chan, glui32 snd, glui32 repeats, glui32 notify)
{
VALID_SCHANNEL(chan, return 0);
-#ifdef GSTREAMER_SOUND
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key);
GInputStream *stream;
return 1;
#else
return 0;
-#endif
+#endif /* GSTREAMER_0_10_SOUND || GSTREAMER_1_0_SOUND */
}
/**
for(count = 0; count < chancount; count++)
VALID_SCHANNEL(chanarray[count], return 0);
-#ifdef GSTREAMER_SOUND
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key);
GInputStream *stream;
return successes;
#else
return 0;
-#endif
+#endif /* GSTREAMER_0_10_SOUND || GSTREAMER_1_0_SOUND */
}
/**
glk_schannel_stop(schanid_t chan)
{
VALID_SCHANNEL(chan, return);
-#ifdef GSTREAMER_SOUND
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
clean_up_after_playing_sound(chan);
#endif
}
/* Mark the channel as paused even if there is no sound playing yet */
chan->paused = TRUE;
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
GstState state;
if(gst_element_get_state(chan->pipeline, &state, NULL, GST_CLOCK_TIME_NONE) != GST_STATE_CHANGE_SUCCESS) {
WARNING(_("Could not get GstElement state"));
WARNING_S(_("Could not set GstElement state to"), "PAUSED");
return;
}
+#endif /* GSTREAMER_0_10_SOUND || GSTREAMER_1_0_SOUND */
}
/**
/* Mark the channel as not paused in any case */
chan->paused = FALSE;
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
GstState state;
if(gst_element_get_state(chan->pipeline, &state, NULL, GST_CLOCK_TIME_NONE) != GST_STATE_CHANGE_SUCCESS) {
WARNING(_("Could not get GstElement state"));
WARNING_S(_("Could not set GstElement state to"), "PLAYING");
return;
}
+#endif /* GSTREAMER_0_10_SOUND || GSTREAMER_1_0_SOUND */
}
/**
return CLAMP(((double)volume_glk / 0x10000), 0.0, 10.0);
}
-#ifdef GSTREAMER_SOUND
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
static gboolean
volume_change_timeout(schanid_t chan)
{
return TRUE;
}
-#endif /* GSTREAMER_SOUND */
+#endif /* GSTREAMER_0_10_SOUND || GSTREAMER_1_0_SOUND */
/**
* glk_schannel_set_volume_ext:
VALID_SCHANNEL(chan, return);
/* Silently ignore out-of-range volume values */
-#ifdef GSTREAMER_SOUND
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
/* Interrupt a previous volume change */
if(chan->volume_timer_id > 0)
g_source_remove(chan->volume_timer_id);
/* Set up a timer for the volume */
chan->volume_timer_id = g_timeout_add(VOLUME_TIMER_RESOLUTION, (GSourceFunc)volume_change_timeout, chan);
-#endif
+#endif /* GSTREAMER_0_10_SOUND || GSTREAMER_1_0_SOUND */
}
/**
void
glk_sound_load_hint(glui32 snd, glui32 flag)
{
-#ifdef GSTREAMER_SOUND
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key);
giblorb_result_t resource;
giblorb_err_t result;
return;
}
}
-#endif /* GSTREAMER_SOUND */
+#endif /* GSTREAMER_0_10_SOUND || GSTREAMER_1_0_SOUND */
}
#include "glk.h"
#include "gi_dispa.h"
#include "chimara-glk.h"
-#ifdef GSTREAMER_SOUND
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
#include <gst/gst.h>
#endif
guint volume_timer_id;
glui32 volume_notify;
-#ifdef GSTREAMER_SOUND
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
/* Each sound channel is represented as a GStreamer pipeline. */
GstElement *pipeline, *source, *typefind, *demux, *decode, *convert, *filter, *sink;
#endif