]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Update ast_readvideo_callback to match ast_readaudio_callback.
authorMark Michelson <mmichelson@digium.com>
Wed, 15 Apr 2009 20:04:20 +0000 (20:04 +0000)
committerMark Michelson <mmichelson@digium.com>
Wed, 15 Apr 2009 20:04:20 +0000 (20:04 +0000)
This fixes potential refcount errors that may occur on ast_filestreams.

AST-208

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@188582 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/file.c

index 8e83880141f57460c8d64a680fd27cf74656a309..8614a6def5b61d751471c66dd14a768686cb6149 100644 (file)
@@ -798,12 +798,21 @@ static enum fsread_res ast_readvideo_callback(struct ast_filestream *s)
 
        while (!whennext) {
                struct ast_frame *fr = s->fmt->read(s, &whennext);
-               if (!fr || ast_write(s->owner, fr)) { /* no stream or error, as above */
-                       if (fr)
+               if (fr) {
+                       ast_set_flag(fr, AST_FRFLAG_FROM_FILESTREAM);
+                       ao2_ref(s, +1);
+               }
+               if (!fr /* stream complete */ || ast_write(s->owner, fr) /* error writing */) {
+                       if (fr) {
                                ast_log(LOG_WARNING, "Failed to write frame\n");
+                               ast_frfree(fr);
+                       }
                        s->owner->vstreamid = -1;
                        return FSREAD_FAILURE;
                }
+               if (fr) {
+                       ast_frfree(fr);
+               }
        }
 
        if (whennext != s->lasttimeout) {