summaryrefslogtreecommitdiff
path: root/res/res_stasis_playback.c
diff options
context:
space:
mode:
authorJonathan Rose <jrose@digium.com>2014-08-22 16:52:51 +0000
committerJonathan Rose <jrose@digium.com>2014-08-22 16:52:51 +0000
commit33835e17a08641f3b54a9293a13a08ca30b43fd6 (patch)
tree484add3c1ec136e31d2fb1e0f2afcda4b005efe3 /res/res_stasis_playback.c
parent1498ae0830d946a9b8185131d510b1b864fd3d11 (diff)
ARI: Fix a crash caused by hanging during playback to a channel in a bridge
ASTERISK-24147 #close Reported by: Edvin Vidmar Review: https://reviewboard.asterisk.org/r/3908/ ........ Merged revisions 421879 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 421880 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@421881 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_stasis_playback.c')
-rw-r--r--res/res_stasis_playback.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/res/res_stasis_playback.c b/res/res_stasis_playback.c
index 832d6fc1b..1de774ff5 100644
--- a/res/res_stasis_playback.c
+++ b/res/res_stasis_playback.c
@@ -366,21 +366,21 @@ static void play_on_channel_in_bridge(struct ast_bridge_channel *bridge_channel,
* \brief \ref RAII_VAR function to remove a playback from the global list when
* leaving scope.
*/
-static void remove_from_playbacks(struct stasis_app_playback *playback)
+static void remove_from_playbacks(void *data)
{
+ struct stasis_app_playback *playback = data;
+
ao2_unlink_flags(playbacks, playback,
OBJ_POINTER | OBJ_UNLINK | OBJ_NODATA);
+ ao2_ref(playback, -1);
}
static int play_uri(struct stasis_app_control *control,
struct ast_channel *chan, void *data)
{
- RAII_VAR(struct stasis_app_playback *, playback, NULL,
- remove_from_playbacks);
+ struct stasis_app_playback *playback = data;
struct ast_bridge *bridge;
- playback = data;
-
if (!control) {
return -1;
}
@@ -434,7 +434,7 @@ struct stasis_app_playback *stasis_app_control_play_uri(
enum stasis_app_playback_target_type target_type,
int skipms, long offsetms, const char *id)
{
- RAII_VAR(struct stasis_app_playback *, playback, NULL, ao2_cleanup);
+ struct stasis_app_playback *playback;
if (skipms < 0 || offsetms < 0) {
return NULL;
@@ -444,6 +444,9 @@ struct stasis_app_playback *stasis_app_control_play_uri(
stasis_app_control_get_channel_id(control), uri);
playback = playback_create(control, id);
+ if (!playback) {
+ return NULL;
+ }
if (skipms == 0) {
skipms = PLAYBACK_DEFAULT_SKIPMS;
@@ -459,11 +462,8 @@ struct stasis_app_playback *stasis_app_control_play_uri(
playback->state = STASIS_PLAYBACK_STATE_QUEUED;
playback_publish(playback);
- /* A ref is kept in the playbacks container; no need to bump */
- stasis_app_send_command_async(control, play_uri, playback);
+ stasis_app_send_command_async(control, play_uri, ao2_bump(playback), remove_from_playbacks);
- /* Although this should be bumped for the caller */
- ao2_ref(playback, +1);
return playback;
}