diff options
author | Shaun Ruffell <sruffell@digium.com> | 2008-12-04 20:55:25 +0000 |
---|---|---|
committer | Shaun Ruffell <sruffell@digium.com> | 2008-12-04 20:55:25 +0000 |
commit | 3dbbba4a65492552c23214121b684e7dfc51d837 (patch) | |
tree | b235d309e4f7b7ca0a277e88c49cf5d26d863b98 /drivers/dahdi | |
parent | 5e27b5794ed01ce63c0084d4ac089f84c2e42a63 (diff) |
Do not use an already built channel if the source and destination formats do
not match the formats we want. This fixes a regression introduced by the new
transcoder interface where a translation path from one complex codec to
another can result in garbled audio.
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@5433 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi')
-rw-r--r-- | drivers/dahdi/dahdi_transcode.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/drivers/dahdi/dahdi_transcode.c b/drivers/dahdi/dahdi_transcode.c index 940ab3d..a831d54 100644 --- a/drivers/dahdi/dahdi_transcode.c +++ b/drivers/dahdi/dahdi_transcode.c @@ -179,8 +179,8 @@ static int dahdi_tc_release(struct inode *inode, struct file *file) /* Find a free channel on the transcoder and mark it busy. */ static inline struct dahdi_transcoder_channel * -get_free_channel(struct dahdi_transcoder *tc) - +get_free_channel(struct dahdi_transcoder *tc, + const struct dahdi_transcoder_formats *fmts) { struct dahdi_transcoder_channel *chan; int i; @@ -190,8 +190,18 @@ get_free_channel(struct dahdi_transcoder *tc) for (i = 0; i < tc->numchannels; i++) { chan = &tc->channels[i]; if (!dahdi_tc_is_busy(chan)) { - dahdi_tc_set_busy(chan); - return chan; + if (!dahdi_tc_is_built(chan)) { + dahdi_tc_set_busy(chan); + return chan; + } else { + /* If the channel is already built, we must + * make sure that it can support the formats + * that we're interested in. */ + if ((fmts->srcfmt|fmts->dstfmt) == chan->built_fmts) { + dahdi_tc_set_busy(chan); + return chan; + } + } } } return NULL; @@ -216,7 +226,7 @@ __find_free_channel(struct list_head *list, const struct dahdi_transcoder_format /* We found a transcoder that can handle our formats. * Now look for an available channel. */ match = 1; - if ((chan = get_free_channel(tc))) { + if ((chan = get_free_channel(tc, fmts))) { /* transcoder tc has a free channel. In order * to spread the load among available * transcoders (when there are more than one |