[asterisk-commits] frame: Better handle interpolated frames. (asterisk[13])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Apr 27 17:35:48 CDT 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5538 )

Change subject: frame: Better handle interpolated frames.
......................................................................


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
---
M main/audiohook.c
M main/translate.c
2 files changed, 15 insertions(+), 0 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Mark Michelson: Looks good to me, approved
  George Joseph: Looks good to me, but someone else must approve
  Jenkins2: Approved for Submit



diff --git a/main/audiohook.c b/main/audiohook.c
index 0a2f6c2..869cb75 100644
--- a/main/audiohook.c
+++ b/main/audiohook.c
@@ -942,6 +942,15 @@
 	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;
 
 	/*
diff --git a/main/translate.c b/main/translate.c
index 73e03a8..e1a7d9f 100644
--- a/main/translate.c
+++ b/main/translate.c
@@ -444,8 +444,14 @@
 	}
 	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;
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/5538
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7fa22f631fa28d540722ed789ce28e84c7f8662b
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-commits mailing list