aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_chanspy.c
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-09-05 20:02:48 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2006-09-05 20:02:48 +0000
commit4095dc1815f82e9e0b61948958a268f86278206d (patch)
tree0a0758df6f24d736dce0c5d8b0f438e361c114b8 /apps/app_chanspy.c
parent29b9b4cb0b97b71217c3a5df1b62195c7c4ae77f (diff)
Merge in last round of spy fixes. This should hopefully eliminate all the issues people have been seeing by distinctly separating what each component (core/spy) is responsible for. Core is responsible for adding a spy to a channel, feeding frames to the spy, removing the spy from a channel, and telling the spy to stop. Spy is responsible for reading frames in, and cleaning up after itself.
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@42054 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_chanspy.c')
-rw-r--r--apps/app_chanspy.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index 450b0a8b1..fe71bbef1 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -207,21 +207,6 @@ static int start_spying(struct ast_channel *chan, struct ast_channel *spychan, s
return res;
}
-static void stop_spying(struct ast_channel *chan, struct ast_channel_spy *spy)
-{
- /* If our status has changed to DONE, then the channel we're spying on is gone....
- DON'T TOUCH IT!!! RUN AWAY!!! */
- if (spy->status == CHANSPY_DONE)
- return;
-
- if (!chan)
- return;
-
- ast_mutex_lock(&chan->lock);
- ast_channel_spy_remove(chan, spy);
- ast_mutex_unlock(&chan->lock);
-};
-
/* Map 'volume' levels from -4 through +4 into
decibel (dB) settings for channel drivers
*/
@@ -338,7 +323,13 @@ static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int
}
}
ast_deactivate_generator(chan);
- stop_spying(spyee, &csth.spy);
+
+ if (csth.spy.chan) {
+ csth.spy.status = CHANSPY_DONE;
+ ast_mutex_lock(&csth.spy.chan->lock);
+ ast_channel_spy_remove(csth.spy.chan, &csth.spy);
+ ast_mutex_unlock(&csth.spy.chan->lock);
+ }
if (option_verbose >= 2) {
ast_verbose(VERBOSE_PREFIX_2 "Done Spying on channel %s\n", name);
@@ -347,7 +338,7 @@ static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int
running = 0;
}
- ast_mutex_destroy(&csth.spy.lock);
+ ast_channel_spy_free(&csth.spy);
return running;
}