diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-10-20 22:11:03 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-10-20 22:11:03 +0000 |
commit | 992b0a00e5520978a8e2a204f06338477432edb9 (patch) | |
tree | 62ed0232f1e0de874d9a72428c79b80b8fdbdccd /funcs | |
parent | ff8583b84f751171a723b5176a81bb2f548ce663 (diff) |
Merged revisions 224856 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r224856 | tilghman | 2009-10-20 17:09:07 -0500 (Tue, 20 Oct 2009) | 12 lines
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: http://svn.digium.com/svn/asterisk/branches/1.6.1@224858 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-rw-r--r-- | funcs/func_speex.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/funcs/func_speex.c b/funcs/func_speex.c index 39deabd0c..2e19dc7e5 100644 --- a/funcs/func_speex.c +++ b/funcs/func_speex.c @@ -96,25 +96,24 @@ static int speex_callback(struct ast_audiohook *audiohook, struct ast_channel *c 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; + return -1; } - - ast_channel_lock(chan); + + /* We are called with chan already locked */ if (!(datastore = ast_channel_datastore_find(chan, &speex_datastore, NULL))) { - ast_channel_unlock(chan); - return 0; + return -1; } - ast_channel_unlock(chan); si = datastore->data; sdi = (direction == AST_AUDIOHOOK_DIRECTION_READ) ? si->rx : si->tx; if (!sdi) { - return 0; + return -1; } if (sdi->samples != frame->samples) { @@ -125,7 +124,7 @@ static int speex_callback(struct ast_audiohook *audiohook, struct ast_channel *c 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) { @@ -136,6 +135,12 @@ static int speex_callback(struct ast_audiohook *audiohook, struct ast_channel *c } 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; } |