[asterisk-commits] mmichelson: branch mmichelson/more_transfer r387863 - /team/mmichelson/more_t...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue May 7 16:30:48 CDT 2013
Author: mmichelson
Date: Tue May 7 16:30:46 2013
New Revision: 387863
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=387863
Log:
Play tones for both previously bridged and unbridged channels.
Modified:
team/mmichelson/more_transfer/main/features.c
Modified: team/mmichelson/more_transfer/main/features.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/more_transfer/main/features.c?view=diff&rev=387863&r1=387862&r2=387863
==============================================================================
--- team/mmichelson/more_transfer/main/features.c (original)
+++ team/mmichelson/more_transfer/main/features.c Tue May 7 16:30:46 2013
@@ -7141,16 +7141,13 @@
struct ast_bridge_features *features, int play_tone)
{
RAII_VAR(struct ast_bridge *, chan_bridge, NULL, ao2_cleanup);
- struct ast_channel *bridge_chan;
+ struct ast_channel *bridge_chan = NULL;
ast_channel_lock(chan);
chan_bridge = ast_channel_get_bridge(chan);
ast_channel_unlock(chan);
if (chan_bridge) {
- /* XXX Is there a way to play the tone to chan before moving it? A
- * bridge action on the channel's bridge_channel perhaps?
- */
/* XXX ast_bridge_move() does not take an ast_bridge_features
* parameter. I could presumably get the channel's bridge_channel
* and substitute the features directly onto the bridge_channel.
@@ -7158,30 +7155,40 @@
* I can't know whether I need to free the old bridge features or
* if attempting to free the bridge features will cause a crash.
*/
- return ast_bridge_move(bridge, chan_bridge, chan, NULL, 1);
- }
-
- /* Slightly less easy case. We need to yank channel A from
- * where he currently is and impart him into our bridge.
- */
- bridge_chan = ast_channel_yank(chan);
- if (!bridge_chan) {
- ast_log(LOG_WARNING, "Could not gain control of channel %s\n", ast_channel_name(chan));
- return -1;
- }
- if (ast_channel_state(bridge_chan) != AST_STATE_UP) {
- ast_answer(bridge_chan);
- }
- if (play_tone && !ast_strlen_zero(xfersound) && !ast_streamfile(bridge_chan,
- xfersound, ast_channel_language(bridge_chan))) {
- if (ast_waitstream(bridge_chan, "") < 0) {
- ast_log(LOG_WARNING, "Failed to play a courtesy tone on chan %s\n",
- ast_channel_name(bridge_chan));
- }
- }
- if (ast_bridge_impart(bridge, bridge_chan, NULL, features, 1)) {
- ast_log(LOG_WARNING, "Could not add %s to the bridge\n", ast_channel_name(chan));
- return -1;
+ if (ast_bridge_move(bridge, chan_bridge, chan, NULL, 1)) {
+ return -1;
+ }
+ } else {
+ /* Slightly less easy case. We need to yank channel A from
+ * where he currently is and impart him into our bridge.
+ */
+ bridge_chan = ast_channel_yank(chan);
+ if (!bridge_chan) {
+ ast_log(LOG_WARNING, "Could not gain control of channel %s\n", ast_channel_name(chan));
+ return -1;
+ }
+ if (ast_channel_state(bridge_chan) != AST_STATE_UP) {
+ ast_answer(bridge_chan);
+ }
+ if (ast_bridge_impart(bridge, bridge_chan, NULL, features, 1)) {
+ ast_log(LOG_WARNING, "Could not add %s to the bridge\n", ast_channel_name(chan));
+ return -1;
+ }
+ }
+ if (play_tone && !ast_strlen_zero(xfersound)) {
+ struct ast_channel *play_chan = bridge_chan ?: chan;
+ RAII_VAR(struct ast_bridge_channel *, play_bridge_channel, NULL, ao2_cleanup);
+
+ ast_channel_lock(play_chan);
+ play_bridge_channel = ast_channel_get_bridge_channel(play_chan);
+ ast_channel_unlock(play_chan);
+
+ if (!play_bridge_channel) {
+ ast_log(LOG_WARNING, "Unable to play tone for channel %s. Unable to get bridge channel\n",
+ ast_channel_name(play_chan));
+ }
+
+ ast_bridge_channel_queue_playfile(play_bridge_channel, NULL, xfersound, NULL);
}
return 0;
}
More information about the asterisk-commits
mailing list