From 985a5fd7aac7a39cf9f9502f9e8e06ef216e1d35 Mon Sep 17 00:00:00 2001 From: Joshua Colp Date: Wed, 26 Apr 2017 10:38:31 +0000 Subject: frame: Better handle interpolated frames. 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/translate.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'main/translate.c') diff --git a/main/translate.c b/main/translate.c index 168a72a4b..f2aa5886b 100644 --- a/main/translate.c +++ b/main/translate.c @@ -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; } -- cgit v1.2.3