summaryrefslogtreecommitdiff
path: root/ext/speexdsp
diff options
context:
space:
mode:
Diffstat (limited to 'ext/speexdsp')
-rw-r--r--ext/speexdsp/speexdsp.c55
-rw-r--r--ext/speexdsp/speexdsp.h1
2 files changed, 45 insertions, 11 deletions
diff --git a/ext/speexdsp/speexdsp.c b/ext/speexdsp/speexdsp.c
index 84e4438..5ae413c 100644
--- a/ext/speexdsp/speexdsp.c
+++ b/ext/speexdsp/speexdsp.c
@@ -273,6 +273,8 @@ gst_speex_dsp_init (GstSpeexDSP * self, GstSpeexDSPClass *klass)
GST_DEBUG_FUNCPTR (gst_speex_dsp_rec_event));
gst_element_add_pad (GST_ELEMENT (self), self->rec_sinkpad);
+ self->channels = 1;
+
self->frame_size_ms = 20;
self->filter_length_ms = 500;
@@ -496,7 +498,10 @@ gst_speex_dsp_getcaps (GstPad * pad)
if (self->echostate != NULL)
{
GST_OBJECT_LOCK (self);
- gst_caps_set_simple (result, "rate", G_TYPE_INT, self->rate, NULL);
+ gst_caps_set_simple (result,
+ "rate", G_TYPE_INT, self->rate,
+ "channels", G_TYPE_INT, self->channels,
+ NULL);
GST_OBJECT_UNLOCK (self);
goto out;
}
@@ -545,6 +550,7 @@ gst_speex_dsp_setcaps (GstPad * pad, GstCaps * caps)
GstSpeexDSP *self;
GstStructure *structure;
gint rate;
+ gint channels = 1;
gboolean ret = TRUE;
self = GST_SPEEX_DSP (gst_pad_get_parent (pad));
@@ -560,6 +566,8 @@ gst_speex_dsp_setcaps (GstPad * pad, GstCaps * caps)
return FALSE;
}
+ gst_structure_get_int (structure, "channels", &channels);
+
GST_OBJECT_LOCK (self);
if (self->echostate) {
@@ -568,6 +576,11 @@ gst_speex_dsp_setcaps (GstPad * pad, GstCaps * caps)
rate, self->rate);
ret = FALSE;
}
+ if (self->channels != channels) {
+ GST_WARNING_OBJECT (self, "Wrong channel count, got %d, expected %d",
+ channels, self->channels);
+ ret = FALSE;
+ }
goto done;
}
@@ -591,26 +604,38 @@ gst_speex_dsp_setcaps (GstPad * pad, GstCaps * caps)
self->rate = rate;
if (self->probe) {
+ guint probe_channels = 1;
+
GST_OBJECT_LOCK (self->probe);
self->probe->channels_locked = TRUE;
+ probe_channels = self->probe->channels;
GST_OBJECT_UNLOCK (self->probe);
- }
- self->echostate = speex_echo_state_init (
- rate * self->frame_size_ms / 1000,
- rate * self->filter_length_ms / 1000);
+ if (self->channels == 1 && probe_channels == 1)
+ self->echostate = speex_echo_state_init (
+ rate * self->frame_size_ms / 1000,
+ rate * self->filter_length_ms / 1000);
+ else
+ speex_echo_state_init_mc (
+ rate * self->frame_size_ms / 1000,
+ rate * self->filter_length_ms / 1000,
+ self->channels,
+ probe_channels);
+ }
self->preprocstate = speex_preprocess_state_init (
rate * self->frame_size_ms / 1000,
rate);
- speex_echo_ctl (self->echostate,
- SPEEX_ECHO_SET_SAMPLING_RATE,
- &rate);
+ if (self->echostate) {
+ speex_echo_ctl (self->echostate,
+ SPEEX_ECHO_SET_SAMPLING_RATE,
+ &rate);
- speex_preprocess_ctl (self->preprocstate,
- SPEEX_PREPROCESS_SET_ECHO_STATE,
- self->echostate);
+ speex_preprocess_ctl (self->preprocstate,
+ SPEEX_PREPROCESS_SET_ECHO_STATE,
+ self->echostate);
+ }
speex_preprocess_ctl (self->preprocstate,
SPEEX_PREPROCESS_SET_AGC,
@@ -759,6 +784,14 @@ gst_speex_dsp_rec_chain (GstPad *pad, GstBuffer *buffer)
rec_rt = gst_segment_to_running_time (&self->rec_segment, GST_FORMAT_TIME,
self->rec_time) - play_latency;
+ if (!self->echostate)
+ {
+ outbuffer = gst_buffer_make_writable (recbuffer);
+ gst_buffer_set_caps (outbuffer, GST_PAD_CAPS (self->rec_sinkpad));
+
+ goto no_echo;
+ }
+
if (probe)
{
GST_OBJECT_LOCK (probe);
diff --git a/ext/speexdsp/speexdsp.h b/ext/speexdsp/speexdsp.h
index 0e013e8..40223b1 100644
--- a/ext/speexdsp/speexdsp.h
+++ b/ext/speexdsp/speexdsp.h
@@ -66,6 +66,7 @@ struct _GstSpeexDSP {
guint filter_length_ms; /* filter length in ms */
/* Protected by the object lock */
gint rate;
+ gint channels;
/* Protected by the stream lock */
GstSegment rec_segment;