[asterisk-commits] dvossel: branch dvossel/hd_confbridge r311733 - /team/dvossel/hd_confbridge/a...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Mar 28 09:59:33 CDT 2011
Author: dvossel
Date: Mon Mar 28 09:59:29 2011
New Revision: 311733
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=311733
Log:
Code refactoring
Modified:
team/dvossel/hd_confbridge/apps/app_confbridge.c
Modified: team/dvossel/hd_confbridge/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/app_confbridge.c?view=diff&rev=311733&r1=311732&r2=311733
==============================================================================
--- team/dvossel/hd_confbridge/apps/app_confbridge.c (original)
+++ team/dvossel/hd_confbridge/apps/app_confbridge.c Mon Mar 28 09:59:29 2011
@@ -940,38 +940,52 @@
ao2_ref(conference_bridge, -1);
}
+/*!
+ * \internal
+ * \brief allocates playback chan on a channel
+ * \note expects conference to be locked before calling this function
+ */
+static int alloc_playback_chan(struct conference_bridge *conference_bridge)
+{
+ int cause;
+ struct ast_format_cap *cap;
+ struct ast_format tmpfmt;
+
+ if (conference_bridge->playback_chan) {
+ return 0;
+ }
+ if (!(cap = ast_format_cap_alloc_nolock())) {
+ return -1;
+ }
+ ast_format_cap_add(cap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
+ if (!(conference_bridge->playback_chan = ast_request("Bridge", cap, NULL, "", &cause))) {
+ cap = ast_format_cap_destroy(cap);
+ return -1;
+ }
+ cap = ast_format_cap_destroy(cap);
+
+ conference_bridge->playback_chan->bridge = conference_bridge->bridge;
+
+ if (ast_call(conference_bridge->playback_chan, "", 0)) {
+ ast_hangup(conference_bridge->playback_chan);
+ conference_bridge->playback_chan = NULL;
+ return -1;
+ }
+
+ ast_debug(1, "Created a playback channel to conference bridge '%s'\n", conference_bridge->name);
+ return 0;
+}
+
static int play_sound_helper(struct conference_bridge *conference_bridge, const char *filename, int say_number)
{
struct ast_channel *underlying_channel;
ast_mutex_lock(&conference_bridge->playback_lock);
-
if (!(conference_bridge->playback_chan)) {
- int cause;
- struct ast_format_cap *cap = ast_format_cap_alloc_nolock();
- struct ast_format tmpfmt;
- if (!cap) {
- return -1;
- }
- ast_format_cap_add(cap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
- if (!(conference_bridge->playback_chan = ast_request("Bridge", cap, NULL, "", &cause))) {
- ast_mutex_unlock(&conference_bridge->playback_lock);
- cap = ast_format_cap_destroy(cap);
- return -1;
- }
- cap = ast_format_cap_destroy(cap);
-
- conference_bridge->playback_chan->bridge = conference_bridge->bridge;
-
- if (ast_call(conference_bridge->playback_chan, "", 0)) {
- ast_hangup(conference_bridge->playback_chan);
- conference_bridge->playback_chan = NULL;
+ if (alloc_playback_chan(conference_bridge)) {
ast_mutex_unlock(&conference_bridge->playback_lock);
return -1;
}
-
- ast_debug(1, "Created a playback channel to conference bridge '%s'\n", conference_bridge->name);
-
underlying_channel = conference_bridge->playback_chan->tech->bridged_channel(conference_bridge->playback_chan, NULL);
} else {
/* Channel was already available so we just need to add it back into the bridge */
More information about the asterisk-commits
mailing list