mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-15 08:44:14 +00:00
automerge commit
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2-netsec@33750 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
15
channel.c
15
channel.c
@@ -964,6 +964,9 @@ void ast_channel_free(struct ast_channel *chan)
|
||||
|
||||
int ast_channel_spy_add(struct ast_channel *chan, struct ast_channel_spy *spy)
|
||||
{
|
||||
/* Link the owner channel to the spy */
|
||||
spy->chan = chan;
|
||||
|
||||
if (!ast_test_flag(spy, CHANSPY_FORMAT_AUDIO)) {
|
||||
ast_log(LOG_WARNING, "Could not add channel spy '%s' to channel '%s', only audio format spies are supported.\n",
|
||||
spy->type, chan->name);
|
||||
@@ -1034,7 +1037,14 @@ void ast_channel_spy_stop_by_type(struct ast_channel *chan, const char *type)
|
||||
|
||||
void ast_channel_spy_trigger_wait(struct ast_channel_spy *spy)
|
||||
{
|
||||
ast_cond_wait(&spy->trigger, &spy->lock);
|
||||
struct timeval tv;
|
||||
struct timespec ts;
|
||||
|
||||
tv = ast_tvadd(ast_tvnow(), ast_samp2tv(50000, 1000));
|
||||
ts.tv_sec = tv.tv_sec;
|
||||
ts.tv_nsec = tv.tv_usec * 1000;
|
||||
|
||||
ast_cond_timedwait(&spy->trigger, &spy->lock, &ts);
|
||||
}
|
||||
|
||||
void ast_channel_spy_remove(struct ast_channel *chan, struct ast_channel_spy *spy)
|
||||
@@ -1048,6 +1058,8 @@ void ast_channel_spy_remove(struct ast_channel *chan, struct ast_channel_spy *sp
|
||||
|
||||
ast_mutex_lock(&spy->lock);
|
||||
|
||||
spy->chan = NULL;
|
||||
|
||||
for (f = spy->read_queue.head; f; f = spy->read_queue.head) {
|
||||
spy->read_queue.head = f->next;
|
||||
ast_frfree(f);
|
||||
@@ -1085,6 +1097,7 @@ static void detach_spies(struct ast_channel *chan)
|
||||
/* Marking the spies as done is sufficient. Chanspy or spy users will get the picture. */
|
||||
AST_LIST_TRAVERSE(&chan->spies->list, spy, list) {
|
||||
ast_mutex_lock(&spy->lock);
|
||||
spy->chan = NULL;
|
||||
if (spy->status == CHANSPY_RUNNING)
|
||||
spy->status = CHANSPY_DONE;
|
||||
if (ast_test_flag(spy, CHANSPY_TRIGGER_MODE) != CHANSPY_TRIGGER_NONE)
|
||||
|
Reference in New Issue
Block a user