[asterisk-commits] file: branch file/audiohooks-1.4 r87818 - /team/file/audiohooks-1.4/main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Oct 31 11:20:24 CDT 2007
Author: file
Date: Wed Oct 31 11:20:23 2007
New Revision: 87818
URL: http://svn.digium.com/view/asterisk?view=rev&rev=87818
Log:
Add audiohooks to channel.c
Modified:
team/file/audiohooks-1.4/main/channel.c
Modified: team/file/audiohooks-1.4/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/file/audiohooks-1.4/main/channel.c?view=diff&rev=87818&r1=87817&r2=87818
==============================================================================
--- team/file/audiohooks-1.4/main/channel.c (original)
+++ team/file/audiohooks-1.4/main/channel.c Wed Oct 31 11:20:23 2007
@@ -1391,6 +1391,11 @@
/* Don't actually hang up a channel that will masquerade as someone else, or
if someone is going to masquerade as us */
ast_channel_lock(chan);
+
+ if (chan->audiohooks) {
+ ast_audiohook_detach_list(chan->audiohooks);
+ chan->audiohooks = NULL;
+ }
if (chan->masq) {
if (ast_do_masquerade(chan))
@@ -2082,6 +2087,12 @@
chan->emulate_dtmf_duration = AST_DEFAULT_EMULATE_DTMF_DURATION;
ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass, chan->emulate_dtmf_duration, chan->name);
}
+ if (chan->audiohooks) {
+ struct ast_frame *old_frame = f;
+ f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
+ if (old_frame != f)
+ ast_frfree(old_frame);
+ }
} else {
struct timeval now = ast_tvnow();
if (ast_test_flag(chan, AST_FLAG_IN_DTMF)) {
@@ -2103,6 +2114,12 @@
} else {
ast_log(LOG_DTMF, "DTMF end passthrough '%c' on %s\n", f->subclass, chan->name);
chan->dtmf_tv = now;
+ }
+ if (chan->audiohooks) {
+ struct ast_frame *old_frame = f;
+ f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
+ if (old_frame != f)
+ ast_frfree(old_frame);
}
}
break;
@@ -2164,6 +2181,12 @@
f->subclass = chan->emulate_dtmf_digit;
f->len = ast_tvdiff_ms(now, chan->dtmf_tv);
chan->dtmf_tv = now;
+ if (chan->audiohooks) {
+ struct ast_frame *old_frame = f;
+ f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
+ if (old_frame != f)
+ ast_frfree(old_frame);
+ }
ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass, chan->name);
} else {
/* Drop voice frames while we're still in the middle of the digit */
@@ -2178,7 +2201,12 @@
ast_frfree(f);
f = &ast_null_frame;
} else if ((f->frametype == AST_FRAME_VOICE)) {
-
+ if (chan->audiohooks) {
+ struct ast_frame *old_frame = f;
+ f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f);
+ if (old_frame != f)
+ ast_frfree(old_frame);
+ }
if (chan->monitor && chan->monitor->read_stream ) {
/* XXX what does this do ? */
#ifndef MONITOR_CONSTANT_DELAY
@@ -2469,7 +2497,7 @@
int ast_write(struct ast_channel *chan, struct ast_frame *fr)
{
int res = -1;
- struct ast_frame *f = NULL;
+ struct ast_frame *f = NULL, *f2 = NULL;
/* Stop if we're a zombie or need a soft hangup */
ast_channel_lock(chan);
@@ -2517,6 +2545,12 @@
chan->tech->indicate(chan, fr->subclass, fr->data, fr->datalen);
break;
case AST_FRAME_DTMF_BEGIN:
+ if (chan->audiohooks) {
+ struct ast_frame *old_frame = fr;
+ fr = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr);
+ if (old_frame != fr)
+ f = fr;
+ }
ast_clear_flag(chan, AST_FLAG_BLOCKING);
ast_channel_unlock(chan);
res = ast_senddigit_begin(chan, fr->subclass);
@@ -2524,6 +2558,12 @@
CHECK_BLOCKING(chan);
break;
case AST_FRAME_DTMF_END:
+ if (chan->audiohooks) {
+ struct ast_frame *old_frame = fr;
+ fr = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr);
+ if (old_frame != fr)
+ f = fr;
+ }
ast_clear_flag(chan, AST_FLAG_BLOCKING);
ast_channel_unlock(chan);
res = ast_senddigit_end(chan, fr->subclass, fr->len);
@@ -2550,6 +2590,13 @@
case AST_FRAME_VOICE:
if (chan->tech->write == NULL)
break; /*! \todo XXX should return 0 maybe ? */
+
+ if (chan->audiohooks) {
+ struct ast_frame *old_frame = fr;
+ fr = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr);
+ if (old_frame != fr)
+ f2 = fr;
+ }
/* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
if (fr->subclass == chan->rawwriteformat)
@@ -2558,7 +2605,7 @@
f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr;
/* If we have no frame of audio, then we have to bail out */
- if (f == NULL) {
+ if (!f) {
res = 0;
break;
}
@@ -2621,6 +2668,8 @@
if (f && f != fr)
ast_frfree(f);
+ if (f2)
+ ast_frfree(f2);
ast_clear_flag(chan, AST_FLAG_BLOCKING);
/* Consider a write failure to force a soft hangup */
if (res < 0)
More information about the asterisk-commits
mailing list