summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mg2ec.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/mg2ec.h b/mg2ec.h
index fca3c21..a1d691e 100644
--- a/mg2ec.h
+++ b/mg2ec.h
@@ -158,8 +158,8 @@ struct echo_can_state {
int avg_Lu_i_toolow;
int avg_Lu_i_ok;
#endif
- short lastsig[256];
- int lastpos;
+ short lastsig;
+ int lastcount;
int backup;
#ifdef DC_NORMALIZE
int dc_estimate;
@@ -327,18 +327,18 @@ static inline short echo_can_update(struct echo_can_state *ec, short iref, short
ec->N_d);
rs >>= 15;
- ec->lastsig[ec->lastpos++] = isig;
- if (ec->lastpos >= 256)
- ec->lastpos = 0;
-
- for (k=0; k < 256; k++) {
- if (isig != ec->lastsig[k])
- break;
+ if (ec->lastsig == isig) {
+ ec->lastcount++;
+ } else {
+ ec->lastcount = 0;
+ ec->lastsig = isig;
}
if (isig == 0) {
u = 0;
- } else if (k == 256) {
+ } else if (ec->lastcount > 255) {
+ /* We have seen the same input-signal more than 255 times,
+ * we should pass it through uncancelled, as we are likely on hold */
u = isig;
} else {
if (rs < -32768) {