speechd-discuss
[Top][All Lists]
Advanced

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

[PATCH] determine availability of audio plugins by using config.h


From: William Hubbs
Subject: [PATCH] determine availability of audio plugins by using config.h
Date: Sat, 4 Dec 2010 19:23:49 -0600

This reworks the way static_plugins.c determines which audio plugins are
available. Now it uses config.h instead of being generated as part of
the configure process.
---
 configure.ac                          |   34 ++++---------
 src/modules/audio/.gitignore          |    1 -
 src/modules/audio/static_plugins.c    |   91 +++++++++++++++++++++++++++++++++
 src/modules/audio/static_plugins.c.in |   54 -------------------
 4 files changed, 101 insertions(+), 79 deletions(-)
 delete mode 100644 src/modules/audio/.gitignore
 create mode 100644 src/modules/audio/static_plugins.c
 delete mode 100644 src/modules/audio/static_plugins.c.in

diff --git a/configure.ac b/configure.ac
index 58a233c..96bcc52 100644
--- a/configure.ac
+++ b/configure.ac
@@ -199,10 +199,6 @@ AS_IF([test $with_pico != "no"],
                        [AC_MSG_FAILURE([SVOX pico is not available])])])])
 AM_CONDITIONAL([pico_support], [test $with_pico = "yes"])
 
-# checks for audio subsystems
-# clear static audio plugins list
-STATIC_AUDIO_PLUGINS_LIST=""
-
 # check for alsa support
 AC_ARG_WITH([alsa],
        [AS_HELP_STRING([--with-alsa], [include ALSA support])],
@@ -210,8 +206,8 @@ AC_ARG_WITH([alsa],
        [with_alsa=check])
 AS_IF([test $with_alsa != "no"],
        [PKG_CHECK_MODULES([ALSA], [alsa],
-               [with_alsa=yes;
-               STATIC_AUDIO_PLUGINS_LIST="$STATIC_AUDIO_PLUGINS_LIST alsa"],
+               [with_alsa=yes
+               AC_DEFINE([HAVE_ALSA], [1], [define if you have ALSA])],
                [AS_IF([test $with_alsa = "yes"],
                        [AC_MSG_FAILURE([ALSA is not available])])])])
 AM_CONDITIONAL([alsa_support], [test $with_alsa = "yes"])
@@ -225,8 +221,8 @@ AC_ARG_WITH([libao],
        [with_libao=check])
 AS_IF([test $with_libao != "no"],
        [PKG_CHECK_MODULES([LIBAO], [ao],
-               [with_libao=yes;
-               STATIC_AUDIO_PLUGINS_LIST="$STATIC_AUDIO_PLUGINS_LIST libao"],
+               [with_libao=yes
+               AC_DEFINE([HAVE_LIBAO], [1], [define if you have libao])],
                [AS_IF([test $with_libao = yes],
                        [AC_MSG_FAILURE([libao is not available])])])])
 AM_CONDITIONAL([libao_support], [test $with_libao = "yes"])
@@ -240,8 +236,8 @@ AC_ARG_WITH([nas],
        [with_nas=check])
 AS_IF([test $with_nas != "no"],
        [AC_CHECK_LIB([audio], [AuOpenServer],
-               [with_nas=yes;
-               STATIC_AUDIO_PLUGINS_LIST="$STATIC_AUDIO_PLUGINS_LIST nas";
+               [with_nas=yes
+               AC_DEFINE([HAVE_NAS], [1], [define if you have NAS])
                NAS_LIBS="-L/usr/X11R6/lib -lXau -laudio"],
                [AS_IF([test $with_nas = "yes"],
                        [AC_MSG_FAILURE([nas is not available])])],
@@ -256,8 +252,8 @@ AC_ARG_WITH([oss],
        [with_oss=check])
 AS_IF([test $with_oss != "no"],
        [AC_CHECK_HEADER([sys/soundcard.h],
-               [with_oss=yes;
-               STATIC_AUDIO_PLUGINS_LIST="$STATIC_AUDIO_PLUGINS_LIST oss"],
+               [with_oss=yes
+               AC_DEFINE([HAVE_OSS], [1], [define if you have OSS])],
                [AS_IF([test $with_oss = "yes"],
                        [AC_MSG_FAILURE([oss is not available])])])])
 AM_CONDITIONAL([oss_support], [test $with_oss = "yes"])
@@ -269,23 +265,14 @@ AC_ARG_WITH([pulse],
        [with_pulse=check])
 AS_IF([test $with_pulse != "no"],
        [PKG_CHECK_MODULES([PULSE], [libpulse-simple],
-               [with_pulse=yes;
-               STATIC_AUDIO_PLUGINS_LIST="$STATIC_AUDIO_PLUGINS_LIST pulse"],
+               [with_pulse=yes
+               AC_DEFINE([HAVE_PULSE], [1], [define if you have pulseaudio])],
                [AS_IF([test $with_pulse = "yes"],
                        [AC_MSG_FAILURE([pulseaudio is not available])])])])
 AM_CONDITIONAL([pulse_support], [test $with_pulse = "yes"])
 AC_SUBST([PULSE_CFLAGS])
 AC_SUBST([PULSE_LIBS])
 
-for name in $STATIC_AUDIO_PLUGINS_LIST; do
-       STATIC_AUDIO_PLUGINS_GET="$STATIC_AUDIO_PLUGINS_GET${name}_plugin_get,";
-       STATIC_AUDIO_PLUGINS_EXTERN="${STATIC_AUDIO_PLUGINS_EXTERN} extern 
spd_audio_plugin_t const * ${name}_plugin_get (void); "
-done
-
-# used in src/audio/static_plugins.c.in
-AC_SUBST([STATIC_AUDIO_PLUGINS_EXTERN])
-AC_SUBST([STATIC_AUDIO_PLUGINS_GET])
-
 # current, age and revision values for shared libraries.
 LIB_SDAUDIO_CURRENT=2 # Current main version (increment on every API change -- 
incompatible AND extensions)
 LIB_SDAUDIO_REVISION=4 # Current minor version (increment on every 
implementation change)
@@ -359,7 +346,6 @@ AC_CONFIG_FILES([Makefile
                  src/common/Makefile
                  src/modules/Makefile
                  src/modules/audio/Makefile
-                 src/modules/audio/static_plugins.c
                  src/server/Makefile
                  src/tests/Makefile])
 AC_OUTPUT
diff --git a/src/modules/audio/.gitignore b/src/modules/audio/.gitignore
deleted file mode 100644
index f75f98e..0000000
--- a/src/modules/audio/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-static_plugins.c
diff --git a/src/modules/audio/static_plugins.c 
b/src/modules/audio/static_plugins.c
new file mode 100644
index 0000000..01337d8
--- /dev/null
+++ b/src/modules/audio/static_plugins.c
@@ -0,0 +1,91 @@
+/*
+ * static_plugins.c -- spd audio library static plugins
+ *
+ * Copyright (C) 2010 Brailcom, o.p.s.
+ *
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1, or (at your option) any later
+ * version.
+ *
+ * This software 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this package; see the file COPYING.  If not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+
+#include "spd_audio_plugin.h"
+
+#ifdef HAVE_ALSA
+spd_audio_plugin_t const *alsa_plugin_get(void);
+#endif
+
+#ifdef HAVE_LIBAO
+spd_audio_plugin_t const *libao_plugin_get(void);
+#endif
+
+#ifdef HAVE_NAS
+spd_audio_plugin_t const *nas_plugin_get(void);
+#endif
+
+#ifdef HAVE_OSS
+spd_audio_plugin_t const *oss_plugin_get(void);
+#endif
+
+#ifdef HAVE_PULSE
+spd_audio_plugin_t const *pulse_plugin_get(void);
+                                       #endif
+
+static spd_audio_plugin_t const * (* spd_audio_static_plugins[]) (void) =
+{
+#ifdef HAVE_ALSA
+       alsa_plugin_get,
+#endif
+
+#ifdef HAVE_LIBAO
+       libao_plugin_get,
+#endif
+
+#ifdef HAVE_NAS
+       nas_plugin_get,
+#endif
+
+#ifdef HAVE_OSS
+       oss_plugin_get,
+#endif
+
+#ifdef HAVE_PULSE
+       pulse_plugin_get,
+                                       #endif
+
+       NULL
+};
+
+spd_audio_plugin_t const * spd_audio_static_plugin_get (char * name)
+{
+    int i;
+    spd_audio_plugin_t const * plugin;
+
+    for (i=0; spd_audio_static_plugins[i]; i++)
+    {
+        plugin = spd_audio_static_plugins[i]();
+        if (plugin != NULL && strcmp(plugin->name, name)== 0)
+        {
+            return plugin;
+        }
+    }
+
+    return (spd_audio_plugin_t *)NULL;
+}
diff --git a/src/modules/audio/static_plugins.c.in 
b/src/modules/audio/static_plugins.c.in
deleted file mode 100644
index 055f4d1..0000000
--- a/src/modules/audio/static_plugins.c.in
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * static_plugins.c -- spd audio library static plugins
- *
- * Copyright (C) 2010 Andrei Kholodnyi
- *
- * This is free software; you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1, or (at your option) any later
- * version.
- *
- * This software 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this package; see the file COPYING.  If not, write to the Free
- * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string.h>
-
-#include "spd_audio_plugin.h"
-
- at STATIC_AUDIO_PLUGINS_EXTERN@
-
-static spd_audio_plugin_t const * (* spd_audio_static_plugins[]) (void) =
-{
-       @STATIC_AUDIO_PLUGINS_GET@
-       0
-};
-
-spd_audio_plugin_t const * spd_audio_static_plugin_get (char * name)
-{
-    int i;
-    spd_audio_plugin_t const * plugin;
-
-    for (i=0; spd_audio_static_plugins[i]; i++)
-    {
-        plugin = spd_audio_static_plugins[i]();
-        if (plugin != NULL && 0 == strcmp(plugin->name, name))
-        {
-            return plugin;
-        }
-    }
-
-    return (spd_audio_plugin_t *)NULL;
-}
-- 
1.7.2.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]