[asterisk-commits] trunk r20514 - /trunk/channel.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sun Apr 16 08:51:55 MST 2006
Author: rizzo
Date: Sun Apr 16 10:51:53 2006
New Revision: 20514
URL: http://svn.digium.com/view/asterisk?rev=20514&view=rev
Log:
simplify logic in ast_generic_bridge()
Modified:
trunk/channel.c
Modified: trunk/channel.c
URL: http://svn.digium.com/view/asterisk/trunk/channel.c?rev=20514&r1=20513&r2=20514&view=diff
==============================================================================
--- trunk/channel.c (original)
+++ trunk/channel.c Sun Apr 16 10:51:53 2006
@@ -3277,7 +3277,6 @@
/* Copy voice back and forth between the two channels. */
struct ast_channel *cs[3];
struct ast_frame *f;
- struct ast_channel *who = NULL;
enum ast_bridge_result res = AST_BRIDGE_COMPLETE;
int o0nativeformats;
int o1nativeformats;
@@ -3296,6 +3295,8 @@
watch_c1_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_1;
for (;;) {
+ struct ast_channel *who, *other;
+
if ((c0->tech_pvt != pvt0) || (c1->tech_pvt != pvt1) ||
(o0nativeformats != c0->nativeformats) ||
(o1nativeformats != c1->nativeformats)) {
@@ -3333,10 +3334,12 @@
break;
}
+ other = (who == c0) ? c1 : c0; /* the 'other' channel */
+
if ((f->frametype == AST_FRAME_CONTROL) && !(config->flags & AST_BRIDGE_IGNORE_SIGS)) {
if ((f->subclass == AST_CONTROL_HOLD) || (f->subclass == AST_CONTROL_UNHOLD) ||
(f->subclass == AST_CONTROL_VIDUPDATE)) {
- ast_indicate(who == c0 ? c1 : c0, f->subclass);
+ ast_indicate(other, f->subclass);
} else {
*fo = f;
*rc = who;
@@ -3354,28 +3357,20 @@
(f->frametype == AST_FRAME_MODEM) ||
#endif
(f->frametype == AST_FRAME_TEXT)) {
- if (f->frametype == AST_FRAME_DTMF) {
- if (((who == c0) && watch_c0_dtmf) ||
- ((who == c1) && watch_c1_dtmf)) {
- *rc = who;
- *fo = f;
- res = AST_BRIDGE_COMPLETE;
- ast_log(LOG_DEBUG, "Got DTMF on channel (%s)\n", who->name);
- break;
- } else {
- goto tackygoto;
- }
- } else {
-#if 0
- ast_log(LOG_DEBUG, "Read from %s\n", who->name);
- if (who == last)
- ast_log(LOG_DEBUG, "Servicing channel %s twice in a row?\n", last->name);
- last = who;
-#endif
-tackygoto:
- ast_write((who == c0) ? c1 : c0, f);
+ /* monitored dtmf causes exit from bridge */
+ int monitored_source = (who == c0) ? watch_c0_dtmf : watch_c1_dtmf;
+
+ if (f->frametype == AST_FRAME_DTMF && monitored_source) {
+ *fo = f;
+ *rc = who;
+ res = AST_BRIDGE_COMPLETE;
+ ast_log(LOG_DEBUG, "Got DTMF on channel (%s)\n", who->name);
+ break;
}
- }
+ /* other frames go to the other side */
+ ast_write(other, f);
+ }
+ /* XXX do we want to pass on also frames not matched above ? */
ast_frfree(f);
/* Swap who gets priority */
More information about the asterisk-commits
mailing list