diff options
author | Richard Mudgett <rmudgett@digium.com> | 2014-10-03 19:39:49 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2014-10-03 19:39:49 +0000 |
commit | cff192429bd66651c048666970fd386c0c962ae6 (patch) | |
tree | 3bd1db6a53610bb452e68cd7bc78920d8dbc6178 /main | |
parent | 6a844be566478d6fed1ec93c0836fbf5d5d46ff3 (diff) |
audiohooks: Reevaluate the bridge technology when an audiohook is added or removed.
Adding a mixmonitor to a channel causes the bridge to change technologies
from native to simple_bridge so the call can be recorded. However, when
the mixmonitor is stopped the bridge does not switch back to the native
technology.
* Added unbridge requests to reevaluate the bridge when a channel
audiohook is removed.
* Moved the unbridge request into ast_audiohook_attach() ensure that the
bridge reevaluates whenever an audiohook is attached. This simplified the
mixmonitor and chan_spy start code as well.
* Added defensive code to stop_mixmonitor_full() in case additional
arguments are ever added to the StopMixMonitor application.
* Made ast_framehook_detach() not do an unbridge request if the framehook
does not exist.
* Made ast_framehook_list_fixup() do an unbridge request if there are any
framehooks. Also simplified the loop.
ASTERISK-24195 #close
Reported by: Jonathan Rose
Review: https://reviewboard.asterisk.org/r/4046/
........
Merged revisions 424506 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@424507 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r-- | main/audiohook.c | 20 | ||||
-rw-r--r-- | main/framehook.c | 14 |
2 files changed, 27 insertions, 7 deletions
diff --git a/main/audiohook.c b/main/audiohook.c index 33dad38f9..1c0f2c7ab 100644 --- a/main/audiohook.c +++ b/main/audiohook.c @@ -483,6 +483,10 @@ int ast_audiohook_attach(struct ast_channel *chan, struct ast_audiohook *audioho /* Change status over to running since it is now attached */ ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_RUNNING); + if (ast_channel_is_bridged(chan)) { + ast_channel_set_unbridged_nolock(chan, 1); + } + ast_channel_unlock(chan); return 0; @@ -713,6 +717,10 @@ int ast_audiohook_remove(struct ast_channel *chan, struct ast_audiohook *audioho audiohook_list_set_samplerate_compatibility(ast_channel_audiohooks(chan)); ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE); + if (ast_channel_is_bridged(chan)) { + ast_channel_set_unbridged_nolock(chan, 1); + } + ast_channel_unlock(chan); return 0; @@ -738,6 +746,9 @@ static struct ast_frame *dtmf_audiohook_write_list(struct ast_channel *chan, str ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE); ast_audiohook_unlock(audiohook); audiohook->manipulate_callback(audiohook, NULL, NULL, 0); + if (ast_channel_is_bridged(chan)) { + ast_channel_set_unbridged_nolock(chan, 1); + } continue; } if (ast_test_flag(audiohook, AST_AUDIOHOOK_WANTS_DTMF)) { @@ -863,6 +874,9 @@ static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, st removed = 1; ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE); ast_audiohook_unlock(audiohook); + if (ast_channel_is_bridged(chan)) { + ast_channel_set_unbridged_nolock(chan, 1); + } continue; } audiohook_set_internal_rate(audiohook, audiohook_list->list_internal_samp_rate, 1); @@ -884,6 +898,9 @@ static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, st removed = 1; ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_DONE); ast_audiohook_unlock(audiohook); + if (ast_channel_is_bridged(chan)) { + ast_channel_set_unbridged_nolock(chan, 1); + } continue; } audiohook_set_internal_rate(audiohook, audiohook_list->list_internal_samp_rate, 1); @@ -914,6 +931,9 @@ static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, st ast_audiohook_unlock(audiohook); /* We basically drop all of our links to the manipulate audiohook and prod it to do it's own destructive things */ audiohook->manipulate_callback(audiohook, chan, NULL, direction); + if (ast_channel_is_bridged(chan)) { + ast_channel_set_unbridged_nolock(chan, 1); + } continue; } audiohook_set_internal_rate(audiohook, audiohook_list->list_internal_samp_rate, 1); diff --git a/main/framehook.c b/main/framehook.c index 8df3a31a4..44bb86843 100644 --- a/main/framehook.c +++ b/main/framehook.c @@ -94,7 +94,7 @@ static struct ast_frame *framehook_list_push_event(struct ast_framehook_list *fr } skip_size = sizeof(int) * framehooks->count; - skip = alloca(skip_size); + skip = ast_alloca(skip_size); memset(skip, 0, skip_size); do { @@ -198,7 +198,7 @@ int ast_framehook_detach(struct ast_channel *chan, int id) } AST_LIST_TRAVERSE_SAFE_END; - if (ast_channel_is_bridged(chan)) { + if (!res && ast_channel_is_bridged(chan)) { ast_channel_set_unbridged_nolock(chan, 1); } @@ -246,9 +246,11 @@ void ast_framehook_list_fixup(struct ast_channel *old_chan, struct ast_channel * return; } - AST_LIST_TRAVERSE_SAFE_BEGIN(&ast_channel_framehooks(old_chan)->list, framehook, list) { - AST_LIST_REMOVE_CURRENT(list); - + if (!AST_LIST_EMPTY(&ast_channel_framehooks(old_chan)->list) + && ast_channel_is_bridged(old_chan)) { + ast_channel_set_unbridged_nolock(old_chan, 1); + } + while ((framehook = AST_LIST_REMOVE_HEAD(&ast_channel_framehooks(old_chan)->list, list))) { /* If inheritance is not allowed for this framehook, just destroy it. */ if (framehook->i.disable_inheritance) { framehook_detach(framehook, FRAMEHOOK_DETACH_DESTROY); @@ -257,7 +259,6 @@ void ast_framehook_list_fixup(struct ast_channel *old_chan, struct ast_channel * /* Otherwise move it to the other channel and perform any fixups set by the framehook interface */ moved_framehook_id = ast_framehook_attach(new_chan, &framehook->i); - if (moved_framehook_id < 0) { ast_log(LOG_WARNING, "Failed framehook copy during masquerade. Expect loss of features.\n"); framehook_detach(framehook, FRAMEHOOK_DETACH_DESTROY); @@ -270,7 +271,6 @@ void ast_framehook_list_fixup(struct ast_channel *old_chan, struct ast_channel * framehook_detach(framehook, FRAMEHOOK_DETACH_PRESERVE); } } - AST_LIST_TRAVERSE_SAFE_END; } int ast_framehook_list_is_empty(struct ast_framehook_list *framehooks) |