mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 04:11:08 +00:00
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). ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@224856 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -142,25 +142,24 @@ static int speex_callback(struct ast_audiohook *audiohook, struct ast_channel *c
|
|||||||
struct ast_datastore *datastore = NULL;
|
struct ast_datastore *datastore = NULL;
|
||||||
struct speex_direction_info *sdi = NULL;
|
struct speex_direction_info *sdi = NULL;
|
||||||
struct speex_info *si = 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 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) {
|
if (audiohook->status == AST_AUDIOHOOK_STATUS_DONE || frame->frametype != AST_FRAME_VOICE) {
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_channel_lock(chan);
|
/* We are called with chan already locked */
|
||||||
if (!(datastore = ast_channel_datastore_find(chan, &speex_datastore, NULL))) {
|
if (!(datastore = ast_channel_datastore_find(chan, &speex_datastore, NULL))) {
|
||||||
ast_channel_unlock(chan);
|
return -1;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
ast_channel_unlock(chan);
|
|
||||||
|
|
||||||
si = datastore->data;
|
si = datastore->data;
|
||||||
|
|
||||||
sdi = (direction == AST_AUDIOHOOK_DIRECTION_READ) ? si->rx : si->tx;
|
sdi = (direction == AST_AUDIOHOOK_DIRECTION_READ) ? si->rx : si->tx;
|
||||||
|
|
||||||
if (!sdi) {
|
if (!sdi) {
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdi->samples != frame->samples) {
|
if (sdi->samples != frame->samples) {
|
||||||
@@ -182,6 +181,12 @@ static int speex_callback(struct ast_audiohook *audiohook, struct ast_channel *c
|
|||||||
}
|
}
|
||||||
|
|
||||||
speex_preprocess(sdi->state, frame->data.ptr, NULL);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -645,12 +645,17 @@ static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, st
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* Feed in frame to manipulation */
|
/* 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_audiohook_unlock(audiohook);
|
||||||
}
|
}
|
||||||
AST_LIST_TRAVERSE_SAFE_END;
|
AST_LIST_TRAVERSE_SAFE_END;
|
||||||
|
if (middle_frame) {
|
||||||
end_frame = middle_frame;
|
end_frame = middle_frame;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Now we figure out what to do with our end frame (whether to transcode or not) */
|
/* Now we figure out what to do with our end frame (whether to transcode or not) */
|
||||||
if (middle_frame == end_frame) {
|
if (middle_frame == end_frame) {
|
||||||
@@ -677,8 +682,10 @@ static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, st
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* No frame was modified, we can just drop our middle frame and pass the frame we got in out */
|
/* No frame was modified, we can just drop our middle frame and pass the frame we got in out */
|
||||||
|
if (middle_frame) {
|
||||||
ast_frfree(middle_frame);
|
ast_frfree(middle_frame);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return end_frame;
|
return end_frame;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user