[asterisk-commits] russell: trunk r181465 - /trunk/main/channel.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 11 17:26:05 CDT 2009
Author: russell
Date: Wed Mar 11 17:25:57 2009
New Revision: 181465
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=181465
Log:
Make handling of the BRIDGE_PLAY_SOUND variable thread-safe.
Modified:
trunk/main/channel.c
Modified: trunk/main/channel.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/main/channel.c?view=diff&rev=181465&r1=181464&r2=181465
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Wed Mar 11 17:25:57 2009
@@ -4586,6 +4586,33 @@
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 @@
for (/* ever */;;) {
struct timeval now = { 0, };
int to;
- const char *bridge_play_sound = NULL;
to = -1;
@@ -4741,15 +4767,7 @@
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) &&
More information about the asterisk-commits
mailing list