diff options
author | David M. Lee <dlee@digium.com> | 2013-05-23 20:11:35 +0000 |
---|---|---|
committer | David M. Lee <dlee@digium.com> | 2013-05-23 20:11:35 +0000 |
commit | 10ba6bf8a8114278ca974861ecebcb3a827d8d5b (patch) | |
tree | 1406ede124cf9665cb9f9244f9339b6cb522aa8b /res/stasis/control.c | |
parent | 3464e0919afe398717b93b20fff37560c6d4478f (diff) |
This patch implements the REST API's for POST /channels/{channelId}/play
and GET /playback/{playbackId}.
This allows an external application to initiate playback of a sound on a
channel while the channel is in the Stasis application.
/play commands are issued asynchronously, and return immediately with
the URL of the associated /playback resource. Playback commands queue up,
playing in succession. The /playback resource shows the state of a
playback operation as enqueued, playing or complete. (Although the
operation will only be in the 'complete' state for a very short time,
since it is almost immediately freed up).
(closes issue ASTERISK-21283)
(closes issue ASTERISK-21586)
Review: https://reviewboard.asterisk.org/r/2531/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@389587 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/stasis/control.c')
-rw-r--r-- | res/stasis/control.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/res/stasis/control.c b/res/stasis/control.c index e32781b5f..1cc818616 100644 --- a/res/stasis/control.c +++ b/res/stasis/control.c @@ -56,7 +56,8 @@ struct stasis_app_control *control_create(struct ast_channel *channel) return NULL; } - control->command_queue = ao2_container_alloc_list(0, 0, NULL, NULL); + control->command_queue = ao2_container_alloc_list( + AO2_ALLOC_OPT_LOCK_MUTEX, 0, NULL, NULL); control->channel = channel; @@ -75,10 +76,8 @@ static struct stasis_app_command *exec_command( return NULL; } - ao2_lock(control); - ao2_ref(command, +1); + /* command_queue is a thread safe list; no lock needed */ ao2_link(control->command_queue, command); - ao2_unlock(control); ao2_ref(command, +1); return command; @@ -182,8 +181,6 @@ int control_dispatch_all(struct stasis_app_control *control, struct ao2_iterator i; void *obj; - SCOPED_AO2LOCK(lock, control); - ast_assert(control->channel == chan); i = ao2_iterator_init(control->command_queue, AO2_ITERATOR_UNLINK); |