diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-05-28 15:17:37 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-05-28 15:17:37 +0000 |
commit | b8d711bffcb371cae419869cc8d15d150739d7d2 (patch) | |
tree | fe9ba0bc127f29f63b5a78582491be6cf4e580a8 /main | |
parent | af793f6c8d79ca54a1de528e63e15dfe611c00a7 (diff) |
Merged revisions 197543 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r197543 | mmichelson | 2009-05-28 09:58:06 -0500 (Thu, 28 May 2009) | 27 lines
Merged revisions 197537 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r197537 | mmichelson | 2009-05-28 09:49:13 -0500 (Thu, 28 May 2009) | 21 lines
Add flags to chanspy audiohook so that audio stays in sync.
There are two flags being added to the chanspy audiohook here. One
is the pre-existing AST_AUDIOHOOK_TRIGGER_SYNC flag. With this set,
we ensure that the read and write slinfactories on the audiohook do
not skew beyond a certain tolerance.
In addition, there is a new audiohook flag added here,
AST_AUDIOHOOK_SMALL_QUEUE. With this flag set, we do not allow for
a slinfactory to build up a substantial amount of audio before
flushing it. For this particular issue, this means that the person
spying on the call will hear the conversations in real time with very
little delay in the audio.
(closes issue #13745)
Reported by: geoffs
Patches:
13745.patch uploaded by mmichelson (license 60)
Tested by: snblitz
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@197548 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/audiohook.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/main/audiohook.c b/main/audiohook.c index 6f6e08b3a..f190b7d62 100644 --- a/main/audiohook.c +++ b/main/audiohook.c @@ -123,6 +123,7 @@ int ast_audiohook_write_frame(struct ast_audiohook *audiohook, enum ast_audiohoo struct ast_slinfactory *factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_factory : &audiohook->write_factory); struct ast_slinfactory *other_factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->write_factory : &audiohook->read_factory); struct timeval *rwtime = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_time : &audiohook->write_time), previous_time = *rwtime; + int our_factory_samples; int our_factory_ms; int other_factory_samples; int other_factory_ms; @@ -130,7 +131,8 @@ int ast_audiohook_write_frame(struct ast_audiohook *audiohook, enum ast_audiohoo /* Update last feeding time to be current */ *rwtime = ast_tvnow(); - our_factory_ms = ast_tvdiff_ms(*rwtime, previous_time) + (ast_slinfactory_available(factory) / 8); + our_factory_samples = ast_slinfactory_available(factory); + our_factory_ms = ast_tvdiff_ms(*rwtime, previous_time) + (our_factory_samples / 8); other_factory_samples = ast_slinfactory_available(other_factory); other_factory_ms = other_factory_samples / 8; @@ -141,6 +143,14 @@ int ast_audiohook_write_frame(struct ast_audiohook *audiohook, enum ast_audiohoo ast_slinfactory_flush(other_factory); } + if (ast_test_flag(audiohook, AST_AUDIOHOOK_SMALL_QUEUE) && (our_factory_samples > 640 || other_factory_samples > 640)) { + if (option_debug) { + ast_log(LOG_DEBUG, "Audiohook %p has stale audio in its factories. Flushing them both\n", audiohook); + } + ast_slinfactory_flush(factory); + ast_slinfactory_flush(other_factory); + } + /* Write frame out to respective factory */ ast_slinfactory_feed(factory, frame); |