diff options
author | Mark Michelson <mmichelson@digium.com> | 2016-08-10 15:14:09 -0500 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2016-08-18 09:51:24 -0500 |
commit | 5aa877305223faab5a1119276a934893ab9dc138 (patch) | |
tree | 5694687b7fb908758e401260e8608e8377aade9c /apps/confbridge | |
parent | 57f4e4428a830c89436bf5025ca815a4e35776ac (diff) |
ConfBridge: Rework announcer channel methodology
One feature that confbridge has is the ability to play sounds to all
participants in the conference. Prior to this commit, the algorithm for
this was as follows:
* Grab the playback lock
* Push the conference announcer channel into the bridge
* Play back the sound
* Pull the conference announcer channel from the bridge
* Release the playback lock
The issue here is that the act of adding the playback channel to the
bridge and removing it for each announcement is expensive. Amongst the
expenses:
* The announcer channel is imparted into the bridge, meaning a new
thread is spun up for each playback.
* When the announcer is added or removed from the bridge, it results
in the BRIDGEPEER channel variable being set on all channels in the
bridge. This requires keeping the bridge locked and locking each
individual channel in order to set it.
* There's also just the general overhead of adding the channel and
removing it from the bridge. The bridge potentially has to reconfigure
every single time
With this commit, the paradigm for playing back announcements has
shifted.
* The announcer channel is now added to the bridge when the conference
is allocated, and it is hung up when the conference is destroyed.
* A taskprocessor is used to queue playbacks onto the announcer channel.
This keeps the behavior from before where playbacks do not overlap.
* The announcer channel is no longer placed into the bridge as
departable. Since we are not constantly removing the channel from
the bridge, it is safe to add the channel using an independent thread
and simply hang the channel up when it is time for the conference to
be destroyed.
The use of the taskprocessor for playbacks opens up the interesting
possibility of having asynchronous announcements played. In this commit,
however, the behavior is still exactly the same as it previously was.
ASTERISK-26289
Reported by Mark Michelson
Change-Id: Ic5cd2c4b98a1eaa1715eb7a5b35d62f1a76d78a5
Diffstat (limited to 'apps/confbridge')
-rw-r--r-- | apps/confbridge/conf_chan_announce.c | 30 | ||||
-rw-r--r-- | apps/confbridge/include/confbridge.h | 12 |
2 files changed, 2 insertions, 40 deletions
diff --git a/apps/confbridge/conf_chan_announce.c b/apps/confbridge/conf_chan_announce.c index ff3049908..4060b99c4 100644 --- a/apps/confbridge/conf_chan_announce.c +++ b/apps/confbridge/conf_chan_announce.c @@ -143,31 +143,6 @@ struct ast_channel_tech *conf_announce_get_tech(void) return &announce_tech; } -void conf_announce_channel_depart(struct ast_channel *chan) -{ - struct announce_pvt *p = ast_channel_tech_pvt(chan); - - if (!p) { - return; - } - - ao2_ref(p, +1); - ao2_lock(p); - if (!ast_test_flag(&p->base, AST_UNREAL_CARETAKER_THREAD)) { - ao2_unlock(p); - ao2_ref(p, -1); - return; - } - ast_clear_flag(&p->base, AST_UNREAL_CARETAKER_THREAD); - chan = p->base.chan; - ao2_unlock(p); - ao2_ref(p, -1); - if (chan) { - ast_bridge_depart(chan); - ast_channel_unref(chan); - } -} - int conf_announce_channel_push(struct ast_channel *ast) { struct ast_bridge_features *features; @@ -186,20 +161,17 @@ int conf_announce_channel_push(struct ast_channel *ast) if (!chan) { return -1; } - ast_channel_ref(chan); } features = ast_bridge_features_new(); if (!features) { - ast_channel_unref(chan); return -1; } ast_set_flag(&features->feature_flags, AST_BRIDGE_CHANNEL_FLAG_IMMOVABLE); /* Impart the output channel into the bridge */ if (ast_bridge_impart(p->bridge, chan, NULL, features, - AST_BRIDGE_IMPART_CHAN_DEPARTABLE)) { - ast_channel_unref(chan); + AST_BRIDGE_IMPART_CHAN_INDEPENDENT)) { return -1; } ao2_lock(p); diff --git a/apps/confbridge/include/confbridge.h b/apps/confbridge/include/confbridge.h index 5ae042113..5d71a63bc 100644 --- a/apps/confbridge/include/confbridge.h +++ b/apps/confbridge/include/confbridge.h @@ -228,9 +228,9 @@ struct confbridge_conference { struct ast_channel *record_chan; /*!< Channel used for recording the conference */ struct ast_str *record_filename; /*!< Recording filename. */ struct ast_str *orig_rec_file; /*!< Previous b_profile.rec_file. */ - ast_mutex_t playback_lock; /*!< Lock used for playback channel */ AST_LIST_HEAD_NOLOCK(, confbridge_user) active_list; /*!< List of users participating in the conference bridge */ AST_LIST_HEAD_NOLOCK(, confbridge_user) waiting_list; /*!< List of users waiting to join the conference bridge */ + struct ast_taskprocessor *playback_queue; /*!< Queue for playing back bridge announcements and managing the announcer channel */ }; extern struct ao2_container *conference_bridges; @@ -610,16 +610,6 @@ struct ast_channel_tech *conf_record_get_tech(void); struct ast_channel_tech *conf_announce_get_tech(void); /*! - * \brief Remove the announcer channel from the conference. - * \since 12.0.0 - * - * \param chan Either channel in the announcer channel pair. - * - * \return Nothing - */ -void conf_announce_channel_depart(struct ast_channel *chan); - -/*! * \brief Push the announcer channel into the conference. * \since 12.0.0 * |