[pulseaudio-discuss] [PATCH] echo-cancel: Extend null implementation to arbitary sample specs
Stefan Huber
s.huber at bct-electronic.com
Wed Dec 5 01:11:39 PST 2012
Peter submitted four mails on Dez 4 2012, 14:55 that address asymmetric
blocksizes and sample specs for the play and record stream in the echo
canceler module. This is a follow-up patch on top of [PATCH 4/4]
echo-cancel: Fix null implementation to setup one channel
Best,
Stefan
-- >8 --
The new null implementation works with arbitrary sample specs for source
and sink. In particular, it handles a different number of channels for
source and sink.
Signed-off-by: Stefan Huber <s.huber at bct-electronic.com>
---
src/modules/echo-cancel/echo-cancel.h | 3 +++
src/modules/echo-cancel/null.c | 19 ++++++++++---------
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/modules/echo-cancel/echo-cancel.h b/src/modules/echo-cancel/echo-cancel.h
index 6e81681..7b60996 100644
--- a/src/modules/echo-cancel/echo-cancel.h
+++ b/src/modules/echo-cancel/echo-cancel.h
@@ -46,6 +46,9 @@ typedef struct pa_echo_canceller_params pa_echo_canceller_params;
struct pa_echo_canceller_params {
union {
+ struct {
+ pa_sample_spec source_ss;
+ } null;
#ifdef HAVE_SPEEX
struct {
SpeexEchoState *state;
diff --git a/src/modules/echo-cancel/null.c b/src/modules/echo-cancel/null.c
index 6333848..6692f91 100644
--- a/src/modules/echo-cancel/null.c
+++ b/src/modules/echo-cancel/null.c
@@ -29,22 +29,23 @@ pa_bool_t pa_null_ec_init(pa_core *c, pa_echo_canceller *ec,
pa_sample_spec *source_ss, pa_channel_map *source_map,
pa_sample_spec *sink_ss, pa_channel_map *sink_map,
uint32_t *nframes, const char *args) {
- *nframes = 256;
-
- source_ss->format = PA_SAMPLE_S16NE;
- source_ss->channels = 1;
+ char strss_source[PA_SAMPLE_SPEC_SNPRINT_MAX];
+ char strss_sink[PA_SAMPLE_SPEC_SNPRINT_MAX];
- *sink_ss = *source_ss;
- *sink_map = *source_map;
+ *nframes = 256;
+ ec->params.priv.null.source_ss = *source_ss;
- pa_log_debug("null AEC: nframes %u, channels %d, rate %d", *nframes, source_ss->channels, source_ss->rate);
+ pa_log_debug("null AEC: nframes=%u, sample spec source=%s, sample spec sink=%s", *nframes,
+ pa_sample_spec_snprint(strss_source, sizeof(strss_source), source_ss),
+ pa_sample_spec_snprint(strss_sink, sizeof(strss_sink), sink_ss));
return TRUE;
}
void pa_null_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *play, uint8_t *out) {
- // blocksize is nframes * frame-size
- memcpy(out, rec, 256 * 2 );
+ /* The null implementation simply copies the recorded buffer to the output
+ buffer and ignores the play buffer. */
+ memcpy(out, rec, 256 * pa_frame_size(&ec->params.priv.null.source_ss) );
}
void pa_null_ec_done(pa_echo_canceller *ec) {
--
1.7.9.5
More information about the pulseaudio-discuss
mailing list