[zaptel-commits] qwell: branch qwell/echocan-debug r2418 - /team/qwell/echocan-debug/

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Fri Apr 13 10:52:56 MST 2007


Author: qwell
Date: Fri Apr 13 12:52:55 2007
New Revision: 2418

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2418
Log:
Add an echo canceller that completely hoses audio.  Yes, on purpose.

It may sound like a cruel joke at first, but there are some circumstances
 where you want to be 100% sure that your echo canceller is functional.
 Unless you have bad audio to begin with, it's sometimes difficult to tell
 whether it's working or not.  If this "echo can" is in use - you'll know...

Added:
    team/qwell/echocan-debug/jpah.h   (with props)
Modified:
    team/qwell/echocan-debug/zaptel-base.c
    team/qwell/echocan-debug/zconfig.h

Added: team/qwell/echocan-debug/jpah.h
URL: http://svn.digium.com/view/zaptel/team/qwell/echocan-debug/jpah.h?view=auto&rev=2418
==============================================================================
--- team/qwell/echocan-debug/jpah.h (added)
+++ team/qwell/echocan-debug/jpah.h Fri Apr 13 12:52:55 2007
@@ -1,0 +1,103 @@
+/*
+ * ECHO_CAN_JP1
+ *
+ * by Jason Parker
+ *
+ * Based upon mg2ec.h
+ * 
+ * Copyright (C) 2007, Digium, Inc.
+ *
+ * This program is free software and may be used and
+ * distributed according to the terms of the GNU
+ * General Public License, incorporated herein by
+ * reference.
+ *
+ */
+
+#ifndef _JP_ECHO_H
+#define _JP_ECHO_H
+
+#ifdef __KERNEL__
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#define MALLOC(a) kmalloc((a), GFP_KERNEL)
+#define FREE(a) kfree(a)
+#else
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdint.h>
+#include <string.h>
+#define MALLOC(a) malloc(a)
+#define FREE(a) free(a)
+#endif
+
+/* Echo canceller definition */
+struct echo_can_state {
+	/* an arbitrary ID for this echo can - this really should be settable from the calling channel... */
+	int id;
+
+	/* absolute time - aka. sample number index - essentially the number of samples since this can was init'ed */
+	int i_d;
+};
+
+static void echo_can_init(void)
+{
+	printk("Zaptel Audio Hoser: JP1\n");
+}
+
+static void echo_can_identify(char *buf, size_t len)
+{
+	strncpy(buf, "JP1", len);
+}
+
+static void echo_can_shutdown(void)
+{
+}
+
+static inline void init_cc(struct echo_can_state *ec)
+{
+	void *ptr = ec;
+	unsigned long tmp;
+	/* Double-word align past end of state */
+	ptr += sizeof(struct echo_can_state);
+	tmp = (unsigned long)ptr;
+	tmp += 3;
+	tmp &= ~3L;
+	ptr = (void *)tmp;
+}
+
+static inline void echo_can_free(struct echo_can_state *ec)
+{
+	FREE(ec);
+}
+
+static inline short echo_can_update(struct echo_can_state *ec, short iref, short isig) 
+{
+	static int blah = 0;
+
+	if (blah < 2) {
+		blah++;
+		return 0;
+	} else {
+		blah = (blah + 1) % 3;
+		return isig;
+	}
+}
+
+static inline struct echo_can_state *echo_can_create(int len, int adaption_mode)
+{
+	struct echo_can_state *ec;
+	ec = (struct echo_can_state *)MALLOC(sizeof(struct echo_can_state) + 4); /* align */
+	if (ec) {
+		memset(ec, 0, sizeof(struct echo_can_state) + 4); /* align */
+		init_cc(ec);
+	}
+	return ec;
+}
+
+static inline int echo_can_traintap(struct echo_can_state *ec, int pos, short val)
+{
+	return 0;
+}
+
+#endif

Propchange: team/qwell/echocan-debug/jpah.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/qwell/echocan-debug/jpah.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/qwell/echocan-debug/jpah.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: team/qwell/echocan-debug/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/team/qwell/echocan-debug/zaptel-base.c?view=diff&rev=2418&r1=2417&r2=2418
==============================================================================
--- team/qwell/echocan-debug/zaptel-base.c (original)
+++ team/qwell/echocan-debug/zaptel-base.c Fri Apr 13 12:52:55 2007
@@ -424,6 +424,8 @@
 #include "kb1ec.h"
 #elif defined(ECHO_CAN_MG2)
 #include "mg2ec.h"
+#elif defined(ECHO_CAN_JP1)
+#include "jpah.h"
 #else
 #include "mec3.h"
 #endif

Modified: team/qwell/echocan-debug/zconfig.h
URL: http://svn.digium.com/view/zaptel/team/qwell/echocan-debug/zconfig.h?view=diff&rev=2418&r1=2417&r2=2418
==============================================================================
--- team/qwell/echocan-debug/zconfig.h (original)
+++ team/qwell/echocan-debug/zconfig.h Fri Apr 13 12:52:55 2007
@@ -64,6 +64,13 @@
 /* #define ECHO_CAN_KB1 */
 /* This is the new latest and greatest */
 #define ECHO_CAN_MG2
+
+/*
+ * This is only technically an "echo canceller"...
+ * It purposely drops 2 out of 3 samples and sounds horrible.
+ * You really only want this for testing "echo cancelled" audio.
+ */
+/* #define ECHO_CAN_JP1 */
 
 /*
  * Uncomment for aggressive residual echo suppression under 



More information about the zaptel-commits mailing list