[Asterisk-cvs] asterisk dsp.c,1.19,1.20 pbx.c,1.106,1.107
markster at lists.digium.com
markster at lists.digium.com
Wed Mar 24 00:05:09 CST 2004
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv14764
Modified Files:
dsp.c pbx.c
Log Message:
Make FAX enableable/disablabable, fix async goto support properly
Index: dsp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/dsp.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- dsp.c 25 Jan 2004 19:51:01 -0000 1.19
+++ dsp.c 24 Mar 2004 05:01:44 -0000 1.20
@@ -56,6 +56,9 @@
/* Number of goertzels for progress detect */
#define GSAMP_SIZE 183
+/* Define if you want the fax detector -- NOT RECOMMENDED IN -STABLE */
+#define FAX_DETECT
+
#define HZ_350 0
#define HZ_440 1
#define HZ_480 2
@@ -130,11 +133,15 @@
goertzel_state_t row_out[4];
goertzel_state_t col_out[4];
+#ifdef FAX_DETECT
goertzel_state_t fax_tone;
+#endif
#ifdef OLD_DSP_ROUTINES
goertzel_state_t row_out2nd[4];
goertzel_state_t col_out2nd[4];
+#ifdef FAX_DETECT
goertzel_state_t fax_tone2nd;
+#endif
int hit1;
int hit2;
int hit3;
@@ -153,7 +160,9 @@
int digit_hits[16];
+#ifdef FAX_DETECT
int fax_hits;
+#endif
} dtmf_detect_state_t;
typedef struct
@@ -176,7 +185,9 @@
int current_digits;
int detected_digits;
int lost_digits;
+#ifdef FAX_DETECT
int fax_hits;
+#endif
} mf_detect_state_t;
static float dtmf_row[] =
@@ -193,7 +204,9 @@
700.0, 900.0, 1100.0, 1300.0, 1500.0, 1700.0
};
+#ifdef FAX_DETECT
static float fax_freq = 1100.0;
+#endif
static char dtmf_positions[] = "123A" "456B" "789C" "*0#D";
@@ -294,6 +307,7 @@
s->energy = 0.0;
}
+#ifdef FAX_DETECT
/* Same for the fax dector */
goertzel_init (&s->fax_tone, fax_freq, 102);
@@ -301,6 +315,7 @@
/* Same for the fax dector 2nd harmonic */
goertzel_init (&s->fax_tone2nd, fax_freq * 2.0, 102);
#endif
+#endif /* FAX_DETECT */
s->current_sample = 0;
s->detected_digits = 0;
@@ -348,10 +363,12 @@
float row_energy[4];
float col_energy[4];
+#ifdef FAX_DETECT
float fax_energy;
#ifdef OLD_DSP_ROUTINES
float fax_energy_2nd;
#endif
+#endif /* FAX_DETECT */
float famp;
float v1;
int i;
@@ -422,11 +439,12 @@
s->col_out[3].v2 = s->col_out[3].v3;
s->col_out[3].v3 = s->col_out[3].fac*s->col_out[3].v2 - v1 + famp;
+#ifdef FAX_DETECT
/* Update fax tone */
v1 = s->fax_tone.v2;
s->fax_tone.v2 = s->fax_tone.v3;
s->fax_tone.v3 = s->fax_tone.fac*s->fax_tone.v2 - v1 + famp;
-
+#endif /* FAX_DETECT */
#ifdef OLD_DSP_ROUTINES
v1 = s->col_out2nd[0].v2;
s->col_out2nd[0].v2 = s->col_out2nd[0].v3;
@@ -460,9 +478,13 @@
s->row_out2nd[3].v2 = s->row_out2nd[3].v3;
s->row_out2nd[3].v3 = s->row_out2nd[3].fac*s->row_out2nd[3].v2 - v1 + famp;
- v1 = s->fax_tone.v2;
+
+#ifdef FAX_DETECT
+ /* Update fax tone */
+ v1 = s->fax_tone.v2;
s->fax_tone2nd.v2 = s->fax_tone2nd.v3;
s->fax_tone2nd.v3 = s->fax_tone2nd.fac*s->fax_tone2nd.v2 - v1 + famp;
+#endif /* FAX_DETECT */
#endif
}
#endif
@@ -478,8 +500,10 @@
continue;
}
+#ifdef FAX_DETECT
/* Detect the fax energy, too */
fax_energy = goertzel_result(&s->fax_tone);
+#endif
/* We are at the end of a DTMF detection block */
/* Find the peak row and the peak column */
@@ -582,6 +606,7 @@
#endif
}
}
+#ifdef FAX_DETECT
#ifdef OLD_DSP_ROUTINES
if (!hit && (fax_energy >= FAX_THRESHOLD) && (fax_energy > s->energy * 21.0)) {
fax_energy_2nd = goertzel_result(&s->fax_tone2nd);
@@ -622,6 +647,7 @@
}
s->fax_hits = 0;
}
+#endif /* FAX_DETECT */
#ifdef OLD_DSP_ROUTINES
s->hit1 = s->hit2;
s->hit2 = s->hit3;
@@ -641,10 +667,12 @@
goertzel_reset(&s->col_out2nd[i]);
#endif
}
+#ifdef FAX_DETECT
goertzel_reset (&s->fax_tone);
#ifdef OLD_DSP_ROUTINES
goertzel_reset (&s->fax_tone2nd);
#endif
+#endif
s->energy = 0.0;
s->current_sample = 0;
}
@@ -1633,9 +1661,13 @@
goertzel_reset(&dsp->td.dtmf.col_out2nd[i]);
#endif
}
+#ifdef FAX_DETECT
goertzel_reset (&dsp->td.dtmf.fax_tone);
+#endif
#ifdef OLD_DSP_ROUTINES
+#ifdef FAX_DETECT
goertzel_reset (&dsp->td.dtmf.fax_tone2nd);
+#endif
dsp->td.dtmf.hit1 = dsp->td.dtmf.hit2 = dsp->td.dtmf.hit3 = dsp->td.dtmf.hit4 = dsp->td.dtmf.mhit = 0;
#else
dsp->td.dtmf.hits[2] = dsp->td.dtmf.hits[1] = dsp->td.dtmf.hits[0] = dsp->td.dtmf.mhit = 0;
Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -d -r1.106 -r1.107
--- pbx.c 19 Mar 2004 06:36:25 -0000 1.106
+++ pbx.c 24 Mar 2004 05:01:44 -0000 1.107
@@ -3519,7 +3519,6 @@
the PBX, we have to make a new channel, masquerade, and start the PBX
at the new location */
struct ast_channel *tmpchan;
- struct ast_frame *f;
tmpchan = ast_channel_alloc(0);
if (tmpchan) {
snprintf(tmpchan->name, sizeof(tmpchan->name), "AsyncGoto/%s", chan->name);
@@ -3547,10 +3546,10 @@
if (needlock)
ast_mutex_unlock(&chan->lock);
- /* Make the masquerade happen by reading a frame from the tmp channel */
- f = ast_read(tmpchan);
- if (f)
- ast_frfree(f);
+ /* Grab the locks and get going */
+ ast_mutex_lock(&tmpchan->lock);
+ ast_do_masquerade(tmpchan, 0);
+ ast_mutex_unlock(&tmpchan->lock);
/* Start the PBX going on our stolen channel */
if (ast_pbx_start(tmpchan)) {
ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmpchan->name);
More information about the svn-commits
mailing list