From ab2f7b36d75cbd447528e804888cd16053453ea1 Mon Sep 17 00:00:00 2001 From: sruffell Date: Tue, 19 Aug 2008 20:14:25 +0000 Subject: Couple of fixes for the transcoder: - In dahdi_transcode.c, Embed the identifiation number, assigned sequentially when the transcoders are registered, in the transcoder structure. This allows DAHDI_TC_GETINFO to work as expected even though the transcoders are rotated on the list in order to spread the load. - In wctc4xxp, fix bug where all transcoders are named tc400b0. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@4491 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- kernel/zaptel.h | 1 + kernel/zttranscode.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/zaptel.h b/kernel/zaptel.h index fd57755..98f514b 100644 --- a/kernel/zaptel.h +++ b/kernel/zaptel.h @@ -1744,6 +1744,7 @@ zt_tc_clear_data_waiting(struct zt_transcoder_channel *dtc) { struct zt_transcoder { struct list_head node; char name[80]; + int pos; int numchannels; unsigned int srcfmts; unsigned int dstfmts; diff --git a/kernel/zttranscode.c b/kernel/zttranscode.c index 23a5dc8..cc26492 100644 --- a/kernel/zttranscode.c +++ b/kernel/zttranscode.c @@ -60,9 +60,9 @@ struct zt_transcoder *zt_transcoder_alloc(int numchans) memset(tc, 0, size); strcpy(tc->name, ""); tc->numchannels = numchans; + INIT_LIST_HEAD(&tc->node); for (x=0;xnumchannels;x++) { init_waitqueue_head(&tc->channels[x].ready); - INIT_LIST_HEAD(&tc->node); tc->channels[x].parent = tc; } @@ -93,6 +93,8 @@ static int is_on_list(struct list_head *entry, struct list_head *head) /* Register a transcoder */ int zt_transcoder_register(struct zt_transcoder *tc) { + static int count = 0; + tc->pos = count++; spin_lock(&translock); BUG_ON(is_on_list(&tc->node, &trans)); list_add_tail(&tc->node, &trans); @@ -287,7 +289,6 @@ static long zt_tc_allocate(struct file *file, unsigned long data) static long zt_tc_getinfo(unsigned long data) { struct zt_transcoder_info info; - unsigned int x; struct zt_transcoder *cur; struct zt_transcoder *tc = NULL; @@ -295,10 +296,9 @@ static long zt_tc_getinfo(unsigned long data) return -EFAULT; } - x = 0; spin_lock(&translock); list_for_each_entry(cur, &trans, node) { - if (x++ == info.tcnum) { + if (cur->pos == info.tcnum) { tc = cur; break; } -- cgit v1.2.3