summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2003-05-28 19:45:07 +0000
committerMark Spencer <markster@digium.com>2003-05-28 19:45:07 +0000
commita03406e91f098665d9a192cc138430c12275a183 (patch)
tree8b96c1e3ca9d05f7614810a56b279be4557acdab /file.c
parent37d41292bb671f41a1d94cf6c2377bda5faf52f1 (diff)
Make file writing be able to handle a switch in codecs
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1060 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'file.c')
-rwxr-xr-xfile.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/file.c b/file.c
index 4ad7fa974..f7a604964 100755
--- a/file.c
+++ b/file.c
@@ -71,6 +71,7 @@ struct ast_filestream {
/* Transparently translate from another format -- just once */
struct ast_trans_pvt *trans;
struct ast_tranlator_pvt *tr;
+ int lastwriteformat;
};
static pthread_mutex_t formatlock = AST_MUTEX_INITIALIZER;
@@ -187,11 +188,16 @@ int ast_writestream(struct ast_filestream *fs, struct ast_frame *f)
} else {
/* XXX If they try to send us a type of frame that isn't the normal frame, and isn't
the one we've setup a translator for, we do the "wrong thing" XXX */
+ if (fs->trans && (f->subclass != fs->lastwriteformat)) {
+ ast_translator_free_path(fs->trans);
+ fs->trans = NULL;
+ }
if (!fs->trans)
fs->trans = ast_translator_build_path(fs->fmt->format, f->subclass);
if (!fs->trans)
ast_log(LOG_WARNING, "Unable to translate to format %s, source format %d\n", fs->fmt->name, f->subclass);
else {
+ fs->lastwriteformat = f->subclass;
res = 0;
/* Get the translated frame but don't consume the original in case they're using it on another stream */
trf = ast_translate(fs->trans, f, 0);