]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
frame: Better handle interpolated frames.
authorJoshua Colp <jcolp@digium.com>
Wed, 26 Apr 2017 10:38:31 +0000 (10:38 +0000)
committerJoshua Colp <jcolp@digium.com>
Wed, 26 Apr 2017 16:34:59 +0000 (11:34 -0500)
Interpolated frames are frames which contain a number of
samples but have no actual data. Audiohooks did not
handle this case when translating an incoming frame into
signed linear. It assumed that a frame would always contain
media when it may not. If this occurs audiohooks will now
immediately return and not act on the frame.

As well for users of ast_trans_frameout the function has
been changed to be a bit more sane and ensure that the data
pointer on a frame is set to NULL if no data is actually
on the frame. This allows the various spots in Asterisk that
check for an interpolated frame based on the presence of a
data pointer to work as expected.

ASTERISK-26926

Change-Id: I7fa22f631fa28d540722ed789ce28e84c7f8662b

main/audiohook.c
main/translate.c

index 986f11f846f7114212c260f8a31a7b9b83e7bdd3..2cba2de6e2851e00b15d4bb7db400cf969b042bc 100644 (file)
@@ -945,6 +945,15 @@ static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, st
        if (!(middle_frame = audiohook_list_translate_to_slin(audiohook_list, direction, start_frame))) {
                return frame;
        }
+
+       /* If the translation resulted in an interpolated frame then immediately return as audiohooks
+        * rely on actual media being present to do things.
+        */
+       if (!middle_frame->data.ptr) {
+               ast_frfree(middle_frame);
+               return start_frame;
+       }
+
        samples = middle_frame->samples;
 
        /*
index 168a72a4bd59d835db99ec6e76e7289f3800df4b..f2aa5886b2d47f2bb14ca394f965e111e2eff784 100644 (file)
@@ -442,8 +442,14 @@ struct ast_frame *ast_trans_frameout(struct ast_trans_pvt *pvt,
        }
        if (datalen) {
                f->datalen = datalen;
+               f->data.ptr = pvt->outbuf.c;
        } else {
                f->datalen = pvt->datalen;
+               if (!f->datalen) {
+                       f->data.ptr = NULL;
+               } else {
+                       f->data.ptr = pvt->outbuf.c;
+               }
                pvt->datalen = 0;
        }