build-sys: Make speex library optional

make speex library dependency optional, this affects the resampler
and the echo canceller module

this patch supersedes an earlier patch proposal and addresses the following
comments:
* fix order of pa_echo_canceller_method_t enum and ec_table (Frederic)
* the default resampler is speex if available as before, otherwise ffmpeg (Arun)
* does not touch the Adrian EC implementation (see separate patch) (Arun)
This commit is contained in:
Peter Meerwald 2011-12-11 16:07:41 +01:00 committed by Arun Raghavan
parent 87e6f489a9
commit 5f2286e6f7
5 changed files with 97 additions and 11 deletions

View file

@ -31,8 +31,11 @@
#include <pulsecore/core.h>
#include <pulsecore/macro.h>
#ifdef HAVE_SPEEX
#include <speex/speex_echo.h>
#include <speex/speex_preprocess.h>
#endif
#include "adrian.h"
/* Common data structures */
@ -43,10 +46,12 @@ typedef struct pa_echo_canceller_params pa_echo_canceller_params;
struct pa_echo_canceller_params {
union {
#ifdef HAVE_SPEEX
struct {
SpeexEchoState *state;
SpeexPreprocessState *pp_state;
} speex;
#endif
struct {
uint32_t blocksize;
AEC *aec;
@ -121,6 +126,7 @@ struct pa_echo_canceller {
void pa_echo_canceller_get_capture_volume(pa_echo_canceller *ec, pa_cvolume *v);
void pa_echo_canceller_set_capture_volume(pa_echo_canceller *ec, pa_cvolume *v);
#ifdef HAVE_SPEEX
/* Speex canceller functions */
pa_bool_t pa_speex_ec_init(pa_core *c, pa_echo_canceller *ec,
pa_sample_spec *source_ss, pa_channel_map *source_map,
@ -128,6 +134,7 @@ pa_bool_t pa_speex_ec_init(pa_core *c, pa_echo_canceller *ec,
uint32_t *blocksize, const char *args);
void pa_speex_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *play, uint8_t *out);
void pa_speex_ec_done(pa_echo_canceller *ec);
#endif
/* Adrian Andre's echo canceller */
pa_bool_t pa_adrian_ec_init(pa_core *c, pa_echo_canceller *ec,

View file

@ -82,7 +82,9 @@ PA_MODULE_USAGE(
/* NOTE: Make sure the enum and ec_table are maintained in the correct order */
typedef enum {
PA_ECHO_CANCELLER_INVALID = -1,
PA_ECHO_CANCELLER_SPEEX = 0,
#ifdef HAVE_SPEEX
PA_ECHO_CANCELLER_SPEEX,
#endif
PA_ECHO_CANCELLER_ADRIAN,
#ifdef HAVE_WEBRTC
PA_ECHO_CANCELLER_WEBRTC,
@ -96,12 +98,14 @@ typedef enum {
#endif
static const pa_echo_canceller ec_table[] = {
#ifdef HAVE_SPEEX
{
/* Speex */
.init = pa_speex_ec_init,
.run = pa_speex_ec_run,
.done = pa_speex_ec_done,
},
#endif
{
/* Adrian Andre's NLMS implementation */
.init = pa_adrian_ec_init,
@ -1541,16 +1545,17 @@ void pa_echo_canceller_set_capture_volume(pa_echo_canceller *ec, pa_cvolume *v)
}
static pa_echo_canceller_method_t get_ec_method_from_string(const char *method) {
#ifdef HAVE_SPEEX
if (pa_streq(method, "speex"))
return PA_ECHO_CANCELLER_SPEEX;
else if (pa_streq(method, "adrian"))
#endif
if (pa_streq(method, "adrian"))
return PA_ECHO_CANCELLER_ADRIAN;
#ifdef HAVE_WEBRTC
else if (pa_streq(method, "webrtc"))
if (pa_streq(method, "webrtc"))
return PA_ECHO_CANCELLER_WEBRTC;
#endif
else
return PA_ECHO_CANCELLER_INVALID;
return PA_ECHO_CANCELLER_INVALID;
}
/* Common initialisation bits between module-echo-cancel and the standalone test program */