aboutsummaryrefslogtreecommitdiffstats
path: root/channel.c
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-06-12 21:37:29 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-06-12 21:37:29 +0000
commit0b6398c91883f311a5ff859543a274c200573cc7 (patch)
tree33e3902339afa1101d5d3406b27c84ef97680fc0 /channel.c
parent9e51f68551eecb187323fab3de95079e888fda91 (diff)
Merged revisions 33724 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r33724 | file | 2006-06-12 18:34:38 -0300 (Mon, 12 Jun 2006) | 2 lines Greatly simply the mixmonitor thread, and move channel reference directly to spy structure so that the core can modify it. ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@33725 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channel.c')
-rw-r--r--channel.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/channel.c b/channel.c
index a3b9ba968..398bf59ab 100644
--- a/channel.c
+++ b/channel.c
@@ -1122,6 +1122,9 @@ struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const
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);
@@ -1191,7 +1194,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)
@@ -1205,6 +1215,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);
@@ -1242,6 +1254,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)