[asterisk-commits] tilghman: trunk r224856 - in /trunk: ./ funcs/func_speex.c main/audiohook.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Oct 20 17:09:10 CDT 2009
Author: tilghman
Date: Tue Oct 20 17:09:07 2009
New Revision: 224856
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=224856
Log:
Merged revisions 224855 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r224855 | tilghman | 2009-10-20 17:07:11 -0500 (Tue, 20 Oct 2009) | 5 lines
Pay attention to the return value of the manipulate function.
While this looks like an optimization, it prevents a crash from occurring
when used with certain audiohook callbacks (diagnosed with SVN trunk,
backported to 1.4 to keep the source consistent across versions).
........
Modified:
trunk/ (props changed)
trunk/funcs/func_speex.c
trunk/main/audiohook.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Modified: trunk/funcs/func_speex.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_speex.c?view=diff&rev=224856&r1=224855&r2=224856
==============================================================================
--- trunk/funcs/func_speex.c (original)
+++ trunk/funcs/func_speex.c Tue Oct 20 17:09:07 2009
@@ -142,25 +142,24 @@
struct ast_datastore *datastore = NULL;
struct speex_direction_info *sdi = NULL;
struct speex_info *si = NULL;
+ char source[80];
/* If the audiohook is stopping it means the channel is shutting down.... but we let the datastore destroy take care of it */
if (audiohook->status == AST_AUDIOHOOK_STATUS_DONE || frame->frametype != AST_FRAME_VOICE) {
- return 0;
- }
-
- ast_channel_lock(chan);
+ return -1;
+ }
+
+ /* We are called with chan already locked */
if (!(datastore = ast_channel_datastore_find(chan, &speex_datastore, NULL))) {
- ast_channel_unlock(chan);
- return 0;
- }
- ast_channel_unlock(chan);
+ return -1;
+ }
si = datastore->data;
sdi = (direction == AST_AUDIOHOOK_DIRECTION_READ) ? si->rx : si->tx;
if (!sdi) {
- return 0;
+ return -1;
}
if (sdi->samples != frame->samples) {
@@ -171,7 +170,7 @@
if (!(sdi->state = speex_preprocess_state_init((sdi->samples = frame->samples), 8000))) {
return -1;
}
-
+
speex_preprocess_ctl(sdi->state, SPEEX_PREPROCESS_SET_AGC, &sdi->agc);
if (sdi->agc) {
@@ -182,6 +181,12 @@
}
speex_preprocess(sdi->state, frame->data.ptr, NULL);
+ snprintf(source, sizeof(source), "%s/speex", frame->src);
+ if (frame->mallocd & AST_MALLOCD_SRC) {
+ ast_free((char *) frame->src);
+ }
+ frame->src = ast_strdup(source);
+ frame->mallocd |= AST_MALLOCD_SRC;
return 0;
}
Modified: trunk/main/audiohook.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/audiohook.c?view=diff&rev=224856&r1=224855&r2=224856
==============================================================================
--- trunk/main/audiohook.c (original)
+++ trunk/main/audiohook.c Tue Oct 20 17:09:07 2009
@@ -574,7 +574,7 @@
struct ast_frame *start_frame = frame, *middle_frame = frame, *end_frame = frame;
struct ast_audiohook *audiohook = NULL;
int samples = frame->samples;
-
+
/* If the frame coming in is not signed linear we have to send it through the in_translate path */
if (frame->subclass != AST_FORMAT_SLINEAR) {
if (in_translate->format != frame->subclass) {
@@ -645,11 +645,16 @@
continue;
}
/* Feed in frame to manipulation */
- audiohook->manipulate_callback(audiohook, chan, middle_frame, direction);
+ if (audiohook->manipulate_callback(audiohook, chan, middle_frame, direction)) {
+ ast_frfree(middle_frame);
+ middle_frame = NULL;
+ }
ast_audiohook_unlock(audiohook);
}
AST_LIST_TRAVERSE_SAFE_END;
- end_frame = middle_frame;
+ if (middle_frame) {
+ end_frame = middle_frame;
+ }
}
/* Now we figure out what to do with our end frame (whether to transcode or not) */
@@ -677,7 +682,9 @@
}
} else {
/* No frame was modified, we can just drop our middle frame and pass the frame we got in out */
- ast_frfree(middle_frame);
+ if (middle_frame) {
+ ast_frfree(middle_frame);
+ }
}
return end_frame;
More information about the asterisk-commits
mailing list