diff options
author | Russell Bryant <russell@russellbryant.com> | 2009-03-11 22:25:57 +0000 |
---|---|---|
committer | Russell Bryant <russell@russellbryant.com> | 2009-03-11 22:25:57 +0000 |
commit | c61a3f2878d08e334aaa1b39b05078b9703a2a14 (patch) | |
tree | 38d550be9555f7f899be580925ef932c187233f3 /main | |
parent | d555f6b98bb9d554a1699dc3b2e1b9715b32905c (diff) |
Make handling of the BRIDGE_PLAY_SOUND variable thread-safe.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@181465 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r-- | main/channel.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/main/channel.c b/main/channel.c index 0958baa23..5a0994ea7 100644 --- a/main/channel.c +++ b/main/channel.c @@ -4586,6 +4586,33 @@ static void update_bridge_vars(struct ast_channel *c0, struct ast_channel *c1) ast_channel_unlock(c1); } +static void bridge_play_sounds(struct ast_channel *c0, struct ast_channel *c1) +{ + const char *s, *sound; + + /* See if we need to play an audio file to any side of the bridge */ + + ast_channel_lock(c0); + if ((s = pbx_builtin_getvar_helper(c0, "BRIDGE_PLAY_SOUND"))) { + sound = ast_strdupa(s); + ast_channel_unlock(c0); + bridge_playfile(c0, c1, sound, 0); + pbx_builtin_setvar_helper(c0, "BRIDGE_PLAY_SOUND", NULL); + } else { + ast_channel_unlock(c0); + } + + ast_channel_lock(c1); + if ((s = pbx_builtin_getvar_helper(c1, "BRIDGE_PLAY_SOUND"))) { + sound = ast_strdupa(s); + ast_channel_unlock(c1); + bridge_playfile(c1, c0, sound, 0); + pbx_builtin_setvar_helper(c1, "BRIDGE_PLAY_SOUND", NULL); + } else { + ast_channel_unlock(c1); + } +} + /*! \brief Bridge two channels together */ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_channel *c1, struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc) @@ -4663,7 +4690,6 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha for (/* ever */;;) { struct timeval now = { 0, }; int to; - const char *bridge_play_sound = NULL; to = -1; @@ -4741,15 +4767,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha update_bridge_vars(c0, c1); - /* See if we need to play an audio file to any side of the bridge */ - if ((bridge_play_sound = pbx_builtin_getvar_helper(c0, "BRIDGE_PLAY_SOUND"))) { - bridge_playfile(c0, c1, bridge_play_sound, 0); - pbx_builtin_setvar_helper(c0, "BRIDGE_PLAY_SOUND", NULL); - } - if ((bridge_play_sound = pbx_builtin_getvar_helper(c1, "BRIDGE_PLAY_SOUND"))) { - bridge_playfile(c1, c0, bridge_play_sound, 0); - pbx_builtin_setvar_helper(c1, "BRIDGE_PLAY_SOUND", NULL); - } + bridge_play_sounds(c0, c1); if (c0->tech->bridge && (c0->tech->bridge == c1->tech->bridge) && |