[zaptel-commits] kpfleming: branch mogorman/zaptel-1.2-transcoder
r2050 - in /team/mogorman/za...
zaptel-commits at lists.digium.com
zaptel-commits at lists.digium.com
Wed Jan 31 09:45:17 MST 2007
Author: kpfleming
Date: Wed Jan 31 10:45:17 2007
New Revision: 2050
URL: http://svn.digium.com/view/zaptel?view=rev&rev=2050
Log:
use bitfields instead of flag definitions
attempt to automatically release references when fds to channels are closed
Modified:
team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c
team/mogorman/zaptel-1.2-transcoder/zaptel.h
team/mogorman/zaptel-1.2-transcoder/zttranscode.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=2050&r1=2049&r2=2050
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c (original)
+++ team/mogorman/zaptel-1.2-transcoder/wctc4xxp/base.c Wed Jan 31 10:45:17 2007
@@ -642,7 +642,7 @@
compl_ztc = &(wc->uencode->channels[st->timeslot_in_num >> 1]);
/* If the channel complement (other half of the encoder/decoder pair) is not being used... */
- if ((compl_ztc->flags & ZT_TC_FLAG_BUSY) == 0) {
+ if (!compl_ztc->busy) {
if (st->encoder)
destroy_channel(wc, st->chan_in_num, st->chan_out_num);
else
Modified: team/mogorman/zaptel-1.2-transcoder/zaptel.h
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-1.2-transcoder/zaptel.h?view=diff&rev=2050&r1=2049&r2=2050
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/zaptel.h (original)
+++ team/mogorman/zaptel-1.2-transcoder/zaptel.h Wed Jan 31 10:45:17 2007
@@ -746,7 +746,7 @@
__u32 magic; /* Magic value -- ZT_TRANSCODE_MAGIC, read by user */
__u32 config; /* Read/write by user */
- __u32 status; /* Read/write by user */
+ __u32 busy:1; /* Read/write by user */
__u8 userhdr[ZT_TRANSCODE_HDRLEN - (sizeof(__u32) * 14)]; /* Storage for user parameters */
__u8 srcdata[ZT_TRANSCODE_BUFSIZ / 2]; /* Storage of source data */
__u8 dstdata[ZT_TRANSCODE_BUFSIZ / 2]; /* Storage of destination data */
@@ -1408,16 +1408,16 @@
wait_queue_head_t ready;
int errorstatus;
int offset;
- unsigned int chan_built;
+ unsigned int chan_built:1;
+ unsigned int have_reference:1;
+ unsigned int busy:1;
+ unsigned int transient:1;
unsigned int built_fmts;
unsigned int flags;
unsigned int srcfmt;
unsigned int dstfmt;
struct zt_transcode_header *tch;
};
-
-#define ZT_TC_FLAG_BUSY (1 << 0)
-#define ZT_TC_FLAG_TRANSIENT (1 << 1)
struct zt_transcoder {
struct list_head list;
Modified: team/mogorman/zaptel-1.2-transcoder/zttranscode.c
URL: http://svn.digium.com/view/zaptel/team/mogorman/zaptel-1.2-transcoder/zttranscode.c?view=diff&rev=2050&r1=2049&r2=2050
==============================================================================
--- team/mogorman/zaptel-1.2-transcoder/zttranscode.c (original)
+++ team/mogorman/zaptel-1.2-transcoder/zttranscode.c Wed Jan 31 10:45:17 2007
@@ -157,7 +157,7 @@
if (debug)
printk("ZT Transcoder Alert!\n");
if (ztc->tch)
- ztc->tch->status &= ~ZT_TC_FLAG_BUSY;
+ ztc->tch->busy = 0;
wake_up_interruptible(&ztc->ready);
return 0;
@@ -179,7 +179,8 @@
memset(ztc, 0, sizeof(*ztc));
memset(zth, 0, sizeof(*zth));
- ztc->flags = ZT_TC_FLAG_TRANSIENT | ZT_TC_FLAG_BUSY;
+ ztc->transient = 1;
+ ztc->busy = 1;
ztc->tch = zth;
if (debug)
printk("Allocated Transcoder Channel, header is at %p!\n", zth);
@@ -201,7 +202,7 @@
if (!ztc)
return;
- ztc->flags &= ~(ZT_TC_FLAG_BUSY);
+ ztc->busy = 0;
if (ztc->tch) {
for (page = virt_to_page(zth);
@@ -212,9 +213,13 @@
}
ztc->tch = NULL;
- /* Actually reset the transcoder channel */
- if (ztc->flags & ZT_TC_FLAG_TRANSIENT)
+
+ if (ztc->have_reference)
+ module_put(ztc->parent->owner);
+
+ if (ztc->transient);
kfree(ztc);
+
if (debug)
printk("Released Transcoder!\n");
}
@@ -247,16 +252,19 @@
match = 1;
for (x = 0; x < tc->numchannels; x++) {
- if (tc->channels[x].flags & ZT_TC_FLAG_BUSY)
+ if (tc->channels[x].busy)
continue;
- if ((tc->channels[x].chan_built) && ((zth->srcfmt | zth->dstfmt) != tc->channels[x].built_fmts))
+
+ if (tc->channels[x].chan_built &&
+ ((zth->srcfmt | zth->dstfmt) != tc->channels[x].built_fmts))
continue;
if (!try_module_get(tc->owner))
continue;
newztc = &tc->channels[x];
- newztc->flags = ZT_TC_FLAG_BUSY;
+ newztc->busy = 1;
+ newztc->have_reference = 1;
break;
}
}
@@ -270,7 +278,7 @@
(*ztc) = newztc;
(*ztc)->tch = origztc->tch;
origztc->tch = NULL;
- (*ztc)->flags |= (origztc->flags & ~(ZT_TC_FLAG_TRANSIENT));
+ (*ztc)->transient = 0;
ztc_release(origztc);
}
@@ -286,7 +294,7 @@
int ret;
for (;;) {
- if (!(ztc->tch->status & ZT_TC_FLAG_BUSY))
+ if (!(ztc->tch->busy))
return 0;
if ((ret = schluffen(&ztc->ready)))
return ret;
@@ -346,13 +354,14 @@
break;
case ZT_TCOP_RELEASE:
ret = ztc->parent->operation(ztc, ZT_TCOP_RELEASE);
- module_put(ztc->parent->owner);
+ if (ztc->have_reference)
+ module_put(ztc->parent->owner);
break;
case ZT_TCOP_TRANSCODE:
if (!ztc->parent->operation)
return -EINVAL;
- ztc->tch->status |= ZT_TC_FLAG_BUSY;
+ ztc->tch->busy = 1;
if (!(ret = ztc->parent->operation(ztc, ZT_TCOP_TRANSCODE))) {
/* Wait for busy to go away if we are in blocking mode */
if (!(file->f_flags & O_NONBLOCK)) {
@@ -360,7 +369,7 @@
ret = ztc->errorstatus;
}
} else
- ztc->tch->status &= ~ZT_TC_FLAG_BUSY;
+ ztc->tch->busy = 0;
break;
default:
ret = -ENOSYS;
@@ -422,7 +431,7 @@
poll_wait(file, &ztc->ready, wait_table);
- return ztc->tch->status & ZT_TC_FLAG_BUSY ? 0 : POLLPRI;
+ return ztc->tch->busy ? 0 : POLLPRI;
}
struct file_operations __zt_transcode_fops = {
More information about the zaptel-commits
mailing list