summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2008-01-20 11:52:37 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2008-01-20 11:52:37 +0000
commit0a8fc6ab9a65ab14484d86aa274c952bcdd2508b (patch)
tree2a3a5b64cbd6595c1c4d63c27c4c3e931f6e04c0
parent21797cd3d683c34b0d59255fb9a0e9ea48c69c36 (diff)
Add zconfig build time option OPTIMIZE_CHANMUTE. Disabled by default.
When enabled, a zaptel channel will have an extra boolean flag: chanmute. If true, Zaptel needs not waste CPU cycles for copying data for this channel. If you do not enable the option, this commit should have no effect. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@3708 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rw-r--r--zaptel-base.c21
-rw-r--r--zaptel.h3
-rw-r--r--zconfig.h5
3 files changed, 29 insertions, 0 deletions
diff --git a/zaptel-base.c b/zaptel-base.c
index 867dca1..304e3e0 100644
--- a/zaptel-base.c
+++ b/zaptel-base.c
@@ -608,6 +608,11 @@ static int zaptel_proc_read(char *page, char **start, off_t off, int count, int
if ((chans[x]->flags & ZT_FLAG_OPEN)) {
len += sprintf(page + len, "(In use) ");
}
+#ifdef OPTIMIZE_CHANMUTE
+ if ((chans[x]->chanmute)) {
+ len += sprintf(page + len, "(no pcm) ");
+ }
+#endif
len += sprintf(page + len, "\n");
}
if (len <= off) { /* If everything printed so far is before beginning of request */
@@ -6860,6 +6865,10 @@ static void __zt_transmit_chunk(struct zt_chan *chan, unsigned char *buf)
{
unsigned char silly[ZT_CHUNKSIZE];
/* Called with chan->lock locked */
+#ifdef OPTIMIZE_CHANMUTE
+ if(likely(chan->chanmute))
+ return;
+#endif
if (!buf)
buf = silly;
__zt_getbuf_chunk(chan, buf);
@@ -6878,6 +6887,10 @@ static void __zt_transmit_chunk(struct zt_chan *chan, unsigned char *buf)
static inline void __zt_real_transmit(struct zt_chan *chan)
{
/* Called with chan->lock held */
+#ifdef OPTIMIZE_CHANMUTE
+ if(likely(chan->chanmute))
+ return;
+#endif
if (chan->confmode) {
/* Pull queued data off the conference */
__buf_pull(&chan->confout, chan->writechunk, chan, "zt_real_transmit");
@@ -6937,6 +6950,10 @@ static void __zt_receive_chunk(struct zt_chan *chan, unsigned char *buf)
/* Receive chunk of audio -- called with chan->lock held */
unsigned char waste[ZT_CHUNKSIZE];
+#ifdef OPTIMIZE_CHANMUTE
+ if(likely(chan->chanmute))
+ return;
+#endif
if (!buf) {
memset(waste, ZT_LIN2X(0, chan), sizeof(waste));
buf = waste;
@@ -6956,6 +6973,10 @@ static void __zt_receive_chunk(struct zt_chan *chan, unsigned char *buf)
static inline void __zt_real_receive(struct zt_chan *chan)
{
/* Called with chan->lock held */
+#ifdef OPTIMIZE_CHANMUTE
+ if(likely(chan->chanmute))
+ return;
+#endif
if (chan->confmode) {
/* Load into queue if we have space */
__buf_push(&chan->confin, chan->readchunk, "zt_real_receive");
diff --git a/zaptel.h b/zaptel.h
index 2cc6106..06f9e42 100644
--- a/zaptel.h
+++ b/zaptel.h
@@ -1451,6 +1451,9 @@ struct zt_chan {
int deflaw; /* 1 = mulaw, 2=alaw, 0=undefined */
short *xlaw;
+#ifdef OPTIMIZE_CHANMUTE
+ int chanmute; /*!< no need for PCM data */
+#endif
#ifdef CONFIG_CALC_XLAW
unsigned char (*lineartoxlaw)(short a);
#else
diff --git a/zconfig.h b/zconfig.h
index a5e18a7..35056e3 100644
--- a/zconfig.h
+++ b/zconfig.h
@@ -189,4 +189,9 @@
*/
#define ZAPTEL_SYNC_TICK
+/*
+ * Skip processing PCM if low-level driver won't use it anyway
+ */
+/* #define OPTIMIZE_CHANMUTE */
+
#endif