[zaptel-commits] kpfleming: branch mogorman/zaptel-1.2-transcoder
r2031 - /team/mogorman/zapte...
zaptel-commits at lists.digium.com
zaptel-commits at lists.digium.com
Tue Jan 30 17:47:29 MST 2007
Author: kpfleming
Date: Tue Jan 30 18:47:28 2007
New Revision: 2031
URL: http://svn.digium.com/view/zaptel?view=rev&rev=2031
Log:
more code cleanup... no functional changes
Modified:
team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c
Modified: team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c?view=diff&rev=2031&r1=2030&r2=2031
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c (original)
+++ team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c Tue Jan 30 18:47:28 2007
@@ -673,20 +673,27 @@
do {
chars = (u8 *)(zth->srcdata + zth->srcoffset);
- if ((zth->srcfmt == ZT_FORMAT_ULAW) || (zth->srcfmt == ZT_FORMAT_ALAW)) {
- if (zth->dstfmt == ZT_FORMAT_G729A) {
- inbytes = G729_SAMPLES;
- timestamp_inc = G729_SAMPLES;
- } else if (zth->dstfmt == ZT_FORMAT_G723_1) {
- inbytes = G723_SAMPLES;
- timestamp_inc = G723_SAMPLES;
+ switch (zth->srcfmt) {
+ case ZT_FORMAT_ULAW:
+ case ZT_FORMAT_ALAW:
+ switch (zth->dstfmt) {
+ case ZT_FORMAT_G729A:
+ inbytes = G729_SAMPLES;
+ timestamp_inc = G729_SAMPLES;
+ break;
+ case ZT_FORMAT_G723_1:
+ inbytes = G723_SAMPLES;
+ timestamp_inc = G723_SAMPLES;
+ break;
}
- } else if (zth->srcfmt == ZT_FORMAT_G729A) {
+ case ZT_FORMAT_G729A:
inbytes = G729_BYTES;
timestamp_inc = G729_SAMPLES;
- } else if (zth->srcfmt == ZT_FORMAT_G723_1) {
+ break;
+ case ZT_FORMAT_G723_1:
inbytes = G723_BYTES;
timestamp_inc = G723_SAMPLES;
+ break;
}
zth->srclen -= inbytes;
@@ -827,33 +834,26 @@
rcodec = DTE_FORMAT_UNDEF;
}
- if ((rcodec == 0x00) || (rcodec == 0x08)) { /* ulaw or alaw (decoders) */
+ switch (rcodec) {
+ case 0x00: /* ulaw */
+ case 0x08: /* alaw */
ztc = &(wc->udecode->channels[ztc_ndx]);
- zth = ztc->tch;
- st = ztc->pvt;
-
- if (zth == NULL) {
- debug_printk(1, "Tried to put data into a freed zth header\n");
- rcodec = DTE_FORMAT_UNDEF;
- } else {
- chars = (u8 *)(zth->dstdata + zth->dstoffset + zth->dstlen);
- st->packets_received++;
- }
+ break;
+ case 0x04: /* g.723.1 */
+ case 0x12: /* g.729 */
+ ztc = &(wc->uencode->channels[ztc_ndx]);
+ break;
}
+
+ zth = ztc->tch;
+ st = ztc->pvt;
- if ((rcodec == 0x04) || (rcodec == 0x12)) { /* g.723 or g.729 (encoders) */
- ztc = &(wc->uencode->channels[ztc_ndx]);
- zth = ztc->tch;
- st = ztc->pvt;
-
- if (zth == NULL) {
- debug_printk(1, "Tried to put data into a freed zth header\n");
- rcodec = DTE_FORMAT_UNDEF;
- } else {
- chars = (u8 *)(zth->dstdata + zth->dstoffset + zth->dstlen);
- st->packets_received++;
- }
-
+ if (!zth) {
+ debug_printk(1, "Tried to put data into a freed zth header\n");
+ rcodec = DTE_FORMAT_UNDEF;
+ } else {
+ chars = (u8 *)(zth->dstdata + zth->dstoffset + zth->dstlen);
+ st->packets_received++;
}
if (st->dte_seqno_rcv == 0) {
@@ -865,71 +865,49 @@
st->last_dte_seqno = rtp_rseq;
}
- if (rcodec == 0x00) { /* ulaw */
+ switch (rcodec) {
+ case 0x00: /* ulaw */
+ case 0x08: /* alaw */
if (zt_tc_sanitycheck(zth, rlen) &&
((zth->srcfmt == ZT_FORMAT_G729A && rlen == G729_SAMPLES) ||
(zth->srcfmt == ZT_FORMAT_G723_1 && rlen == G723_SAMPLES))) {
- for (i = 0; i < rlen; i++)
- chars[i] = readchunk[i+54];
-
+ memcpy(chars, (void *) readchunk + 54, rlen);
zth->dstlen += rlen;
zth->dstsamples = zth->dstlen;
-
} else {
ztc->errorstatus = -EOVERFLOW;
}
zt_transcoder_alert(ztc);
- } else if (rcodec == 0x08) { /* alaw */
- if (zt_tc_sanitycheck(zth, rlen) &&
- ((zth->srcfmt == ZT_FORMAT_G729A && rlen == G729_SAMPLES) ||
- (zth->srcfmt == ZT_FORMAT_G723_1 && rlen == G723_SAMPLES))) {
- for (i = 0; i < rlen; i++)
- chars[i] = readchunk[i+54];
-
- zth->dstlen += rlen;
- zth->dstsamples = zth->dstlen;
-
- } else {
- ztc->errorstatus = -EOVERFLOW;
- }
- zt_transcoder_alert(ztc);
- } else if (rcodec == 0x04) { /* g.723.1 */
+ break;
+ case 0x04: /* g.723.1 */
if (zt_tc_sanitycheck(zth, rlen) && (rlen == G723_BYTES)) {
- for (i = 0; i < rlen; i++)
- chars[i] = readchunk[i+54];
-
+ memcpy(chars, (void *) readchunk + 54, rlen);
zth->dstlen += rlen;
zth->dstsamples = zth->dstlen * 12;
} else {
ztc->errorstatus = -EOVERFLOW;
}
-
- if (!(zth->dstsamples % G723_SAMPLES)) {
+ if ((zth->dstsamples % G723_SAMPLES) == 0)
zt_transcoder_alert(ztc);
- }
- } else if (rcodec == 0x12) { /* g.729a */
+ break;
+ case 0x12: /* g.729 */
if (zt_tc_sanitycheck(zth, rlen) && (rlen == G729_BYTES)) {
- for (i = 0; i < rlen; i++)
- chars[i] = readchunk[i+54];
-
+ memcpy(chars, (void *) readchunk + 54, rlen);
zth->dstlen += rlen;
zth->dstsamples = zth->dstlen * 8;
} else {
ztc->errorstatus = -EOVERFLOW;
}
- if (!(zth->dstsamples % G729_SAMPLES)) {
+ if ((zth->dstsamples % G729_SAMPLES) == 0)
zt_transcoder_alert(ztc);
- }
}
}
}
static int check_descriptor(struct wcdte *wc)
{
- int o2;
-
- o2 = (ERING_SIZE * 4) + (wc->rdbl * 4);
+ int o2 = (ERING_SIZE * 4) + (wc->rdbl * 4);
if (!(le32_to_cpu(wc->descripchunk[o2]) & 0x80000000)) {
wc->rxints++;
@@ -1068,11 +1046,7 @@
static inline void enable_interrupts(struct wcdte *wc)
{
- /* Enable interrupts */
- if (!debug)
- setintmask(wc, 0x00010041);
- else
- setintmask(wc, 0x0001A1EB);
+ setintmask(wc, !debug ? 0x00010041 : 0x0001A1EB);
}
static void start_dma(struct wcdte *wc)
@@ -1092,7 +1066,6 @@
static void disable_interrupts(struct wcdte *wc)
{
- /* Disable interrupts */
setintmask(wc, 0x00000000);
setctl(wc, 0x0084, 0x00000000);
}
@@ -1113,10 +1086,9 @@
{
int ret;
- if (use_mask)
- ret = wait_event_interruptible_timeout(wc->regq, (wc->rcvflags == mask), wc->timeout);
- else
- ret = wait_event_interruptible_timeout(wc->regq, (wc->last_rcommand == wc->last_command_sent), wc->timeout);
+ ret = wait_event_interruptible_timeout(wc->regq,
+ use_mask ? (wc->rcvflags == mask) : (wc->last_rcommand == wc->last_command_sent),
+ wc->timeout);
wc->rcvflags = 0;
wc->last_rcommand = 0;
wc->last_command_sent = 0;
@@ -1223,17 +1195,13 @@
setctl(wc, 0x00A0, 0x04080000);
/* Wait for Ethernet link */
- delay_count = 0;
- do {
- delay_count++;
- if (delay_count >= 100) {
- module_printk("Failed to link to DTE processor!\n");
- return 1;
- }
-
- reg = getctl(wc, 0x00fc);
- mdelay(100);
- } while ((reg & 0xE0000000) != 0xE0000000);
+ for (delay_count = 0, reg = getctl(wc, 0x00fc);
+ ((reg & 0xE0000000) != 0xE0000000) && delay_count < 100; mdelay(100), delay_count++);
+
+ if (delay_count == 100) {
+ module_printk("Failed to link to DTE processor!\n");
+ return 1;
+ }
/* Turn off booted LED */
setctl(wc, 0x00A0, 0x04084000);
@@ -1491,9 +1459,6 @@
return -ENOMEM;
}
- memset(encoders, 0, sizeof(*encoders) * wc->numchannels);
- memset(decoders, 0, sizeof(*decoders) * wc->numchannels);
-
strcpy(wc->udecode->name, wc->variety);
strcpy(wc->uencode->name, wc->variety);
@@ -1504,7 +1469,6 @@
for (x = 0;x < wc->numchannels; x++) {
dte_init_state(&encoders[x], 1, x, wc);
- encoders[x].encoder = 1;
dte_init_state(&decoders[x], 0, x, wc);
wc->uencode->channels[x].pvt = &encoders[x];
wc->udecode->channels[x].pvt = &decoders[x];
@@ -1623,7 +1587,7 @@
debug_printk(1, "wc->ztsnd_rtx = %d\n", wc->ztsnd_rtx);
debug_printk(1, "wc->ztsnd_0010_rtx = %d\n", wc->ztsnd_0010_rtx);
- for(i = 0; i < wc->numchannels; i++) {
+ for (i = 0; i < wc->numchannels; i++) {
ztc_en = &(wc->uencode->channels[i]);
st_en = ztc_en->pvt;
More information about the zaptel-commits
mailing list