[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/3] Factor out common audio module stuff into a macro
From: |
Boris Dušek |
Subject: |
[PATCH 2/3] Factor out common audio module stuff into a macro |
Date: |
Tue, 24 Jul 2012 22:08:32 +0200 |
From: Boris Dus?ek <address@hidden>
To: address@hidden
We use the same pattern when declaring an audio module in the end
of the respective implementation file. Factor out that patter into
a macro to ease maintainability and provide opportunities for
future portability improvements.
---
src/audio/alsa.c | 11 +++--------
src/audio/libao.c | 9 ++-------
src/audio/nas.c | 11 +++--------
src/audio/oss.c | 11 +++--------
src/audio/pulse.c | 9 ++-------
src/audio/spd_audio_plugin_p.h | 30 ++++++++++++++++++++++++++++++
6 files changed, 43 insertions(+), 38 deletions(-)
create mode 100644 src/audio/spd_audio_plugin_p.h
diff --git a/src/audio/alsa.c b/src/audio/alsa.c
index 4e20a54..b868429 100644
--- a/src/audio/alsa.c
+++ b/src/audio/alsa.c
@@ -2,7 +2,7 @@
/*
* alsa.c -- The Advanced Linux Sound System backend for Speech Dispatcher
*
- * Copyright (C) 2005,2006 Brailcom, o.p.s.
+ * Copyright (C) 2005,2006, 2012 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
@@ -39,6 +39,7 @@
#define SPD_AUDIO_PLUGIN_ENTRY spd_alsa_LTX_spd_audio_plugin_get
#include <spd_audio_plugin.h>
+#include "spd_audio_plugin_p.h"
typedef struct {
AudioID id;
@@ -872,12 +873,6 @@ static spd_audio_plugin_t alsa_functions = {
alsa_get_playcmd
};
-spd_audio_plugin_t *alsa_plugin_get(void)
-{
- return &alsa_functions;
-}
-
-spd_audio_plugin_t *SPD_AUDIO_PLUGIN_ENTRY(void)
- __attribute__ ((weak, alias("alsa_plugin_get")));
+SPD_AUDIO_PLUGIN(alsa)
#undef MSG
#undef ERR
diff --git a/src/audio/libao.c b/src/audio/libao.c
index e82be2b..3c473eb 100644
--- a/src/audio/libao.c
+++ b/src/audio/libao.c
@@ -33,6 +33,7 @@
#define SPD_AUDIO_PLUGIN_ENTRY spd_libao_LTX_spd_audio_plugin_get
#include <spd_audio_plugin.h>
+#include "spd_audio_plugin_p.h"
/* send a packet of XXX bytes to the sound device */
#define AO_SEND_BYTES 256
@@ -235,12 +236,6 @@ static spd_audio_plugin_t libao_functions = {
libao_get_playcmd
};
-spd_audio_plugin_t *libao_plugin_get(void)
-{
- return &libao_functions;
-}
-
-spd_audio_plugin_t *SPD_AUDIO_PLUGIN_ENTRY(void)
- __attribute__ ((weak, alias("libao_plugin_get")));
+SPD_AUDIO_PLUGIN(libao)
#undef MSG
#undef ERR
diff --git a/src/audio/nas.c b/src/audio/nas.c
index ca76127..ac2fa62 100644
--- a/src/audio/nas.c
+++ b/src/audio/nas.c
@@ -1,7 +1,7 @@
/*
* nas.c -- The Network Audio System backend for the spd_audio library.
*
- * Copyright (C) 2004,2006 Brailcom, o.p.s.
+ * Copyright (C) 2004,2006,2012 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
@@ -35,6 +35,7 @@
#define SPD_AUDIO_PLUGIN_ENTRY spd_nas_LTX_spd_audio_plugin_get
#include <spd_audio_plugin.h>
+#include "spd_audio_plugin_p.h"
typedef struct {
AudioID id;
@@ -254,10 +255,4 @@ static spd_audio_plugin_t nas_functions = {
nas_get_playcmd
};
-spd_audio_plugin_t *nas_plugin_get(void)
-{
- return &nas_functions;
-}
-
-spd_audio_plugin_t *SPD_AUDIO_PLUGIN_ENTRY(void)
- __attribute__ ((weak, alias("nas_plugin_get")));
+SPD_AUDIO_PLUGIN(nas)
diff --git a/src/audio/oss.c b/src/audio/oss.c
index b7232c3..12435b3 100644
--- a/src/audio/oss.c
+++ b/src/audio/oss.c
@@ -2,7 +2,7 @@
/*
* oss.c -- The Open Sound System backend for the spd_audio library.
*
- * Copyright (C) 2004,2006 Brailcom, o.p.s.
+ * Copyright (C) 2004,2006,2012 Brailcom, o.p.s.
*
* This is free software; you can redistribute it and/or modify it under the
* terms of the GNU Leser General Public License as published by the Free
@@ -43,6 +43,7 @@
#define SPD_AUDIO_PLUGIN_ENTRY spd_oss_LTX_spd_audio_plugin_get
#include <spd_audio_plugin.h>
+#include "spd_audio_plugin_p.h"
typedef struct {
AudioID id;
@@ -512,12 +513,6 @@ static spd_audio_plugin_t oss_functions = {
oss_get_playcmd
};
-spd_audio_plugin_t *oss_plugin_get(void)
-{
- return &oss_functions;
-}
-
-spd_audio_plugin_t *SPD_AUDIO_PLUGIN_ENTRY(void)
- __attribute__ ((weak, alias("oss_plugin_get")));
+SPD_AUDIO_PLUGIN(oss)
#undef MSG
#undef ERR
diff --git a/src/audio/pulse.c b/src/audio/pulse.c
index a4137e5..c6778cb 100644
--- a/src/audio/pulse.c
+++ b/src/audio/pulse.c
@@ -45,6 +45,7 @@
#define SPD_AUDIO_PLUGIN_ENTRY spd_pulse_LTX_spd_audio_plugin_get
#include <spd_audio_plugin.h>
+#include "spd_audio_plugin_p.h"
/* Switch this on to debug, see output log location in MSG() */
//#define DEBUG_PULSE
@@ -301,10 +302,4 @@ static spd_audio_plugin_t pulse_functions = {
pulse_get_playcmd
};
-spd_audio_plugin_t *pulse_plugin_get(void)
-{
- return &pulse_functions;
-}
-
-spd_audio_plugin_t *SPD_AUDIO_PLUGIN_ENTRY(void)
- __attribute__ ((weak, alias("pulse_plugin_get")));
+SPD_AUDIO_PLUGIN(pulse)
diff --git a/src/audio/spd_audio_plugin_p.h b/src/audio/spd_audio_plugin_p.h
new file mode 100644
index 0000000..9b79ca4
--- /dev/null
+++ b/src/audio/spd_audio_plugin_p.h
@@ -0,0 +1,30 @@
+/*
+ * spd_audio_plugin_p.h - Utility functions and macros for audio modules
+ *
+ * Copyright (C) 2012 Brailcom, o.p.s.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, 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 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.
+ *
+ */
+
+#ifndef SPD_AUDIO_PLUGIN_P_H_
+#define SPD_AUDIO_PLUGIN_P_H_
+
+#define SPD_AUDIO_PLUGIN(modname) \
+ spd_audio_plugin_t * modname##_plugin_get(void) { return
&modname##_functions; }\
+ spd_audio_plugin_t * SPD_AUDIO_PLUGIN_ENTRY (void) __attribute__
((weak, alias(#modname "_plugin_get")));
+
+#endif
--
1.7.7.5 (Apple Git-26)
[PATCH 1/3] Remove references to TEMP_FAILURE_RETRY, Trevor Saunders, 2012/07/25
[PATCH v2 0/3] Portability improvements, Boris Dušek, 2012/07/29