summaryrefslogtreecommitdiff
path: root/main/dsp.c
diff options
context:
space:
mode:
authorGeorge Joseph <george.joseph@fairview5.com>2015-04-06 19:04:32 +0000
committerGeorge Joseph <george.joseph@fairview5.com>2015-04-06 19:04:32 +0000
commite48f2e7897079936ef2cb91fd15b88c319a3cdc9 (patch)
tree1f3ca7e6d30c958207fbeba1275a3b6bb29fde8a /main/dsp.c
parent0543879228048f6580a75b098fb9f3a5ccec1ed8 (diff)
build: Fixes for gcc 5 compilation
These are fixes for compilation under gcc 5.0... chan_sip.c: In parse_request needed to make 'lim' unsigned. inline_api.h: Needed to add a check for '__GNUC_STDC_INLINE__' to detect C99 inline semantics (same as clang). ccss.c: In ast_cc_set_parm, needed to fix weird comparison. dsp.c: Needed to work around a possible compiler bug. It was throwing an array-bounds error but neither sgriepentrog, rmudgett nor I could figure out why. manager.c: In action_atxfer, needed to correct an array allocation. This patch will go to 11, 13, trunk. Review: https://reviewboard.asterisk.org/r/4581/ Reported-by: Jeffrey Ollie Tested-by: George Joseph ASTERISK-24932 #close ........ Merged revisions 434113 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 434114 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@434115 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/dsp.c')
-rw-r--r--main/dsp.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/main/dsp.c b/main/dsp.c
index a329dbb6b..335fb3db0 100644
--- a/main/dsp.c
+++ b/main/dsp.c
@@ -112,9 +112,11 @@ static struct progalias {
{ "uk", PROG_MODE_UK },
};
+#define FREQ_ARRAY_SIZE 7
+
static struct progress {
enum gsamp_size size;
- int freqs[7];
+ int freqs[FREQ_ARRAY_SIZE];
} modes[] = {
{ GSAMP_SIZE_NA, { 350, 440, 480, 620, 950, 1400, 1800 } }, /*!< North America */
{ GSAMP_SIZE_CR, { 425 } }, /*!< Costa Rica, Brazil */
@@ -389,7 +391,7 @@ struct ast_dsp {
struct ast_dsp_busy_pattern busy_cadence;
int historicnoise[DSP_HISTORY];
int historicsilence[DSP_HISTORY];
- goertzel_state_t freqs[7];
+ goertzel_state_t freqs[FREQ_ARRAY_SIZE];
int freqcount;
int gsamps;
enum gsamp_size gsamp_size;
@@ -1036,6 +1038,8 @@ static int __ast_dsp_call_progress(struct ast_dsp *dsp, short *s, int len)
int pass;
int newstate = DSP_TONE_STATE_SILENCE;
int res = 0;
+ int freqcount = dsp->freqcount > FREQ_ARRAY_SIZE ? FREQ_ARRAY_SIZE : dsp->freqcount;
+
while (len) {
/* Take the lesser of the number of samples we need and what we have */
pass = len;
@@ -1045,7 +1049,7 @@ static int __ast_dsp_call_progress(struct ast_dsp *dsp, short *s, int len)
for (x = 0; x < pass; x++) {
samp = s[x];
dsp->genergy += (int32_t) samp * (int32_t) samp;
- for (y = 0; y < dsp->freqcount; y++) {
+ for (y = 0; y < freqcount; y++) {
goertzel_sample(&dsp->freqs[y], samp);
}
}
@@ -1053,8 +1057,8 @@ static int __ast_dsp_call_progress(struct ast_dsp *dsp, short *s, int len)
dsp->gsamps += pass;
len -= pass;
if (dsp->gsamps == dsp->gsamp_size) {
- float hz[7];
- for (y = 0; y < 7; y++) {
+ float hz[FREQ_ARRAY_SIZE];
+ for (y = 0; y < FREQ_ARRAY_SIZE; y++) {
hz[y] = goertzel_result(&dsp->freqs[y]);
}
switch (dsp->progmode) {
@@ -1642,7 +1646,7 @@ static void ast_dsp_prog_reset(struct ast_dsp *dsp)
dsp->gsamp_size = modes[dsp->progmode].size;
dsp->gsamps = 0;
- for (x = 0; x < ARRAY_LEN(modes[dsp->progmode].freqs); x++) {
+ for (x = 0; x < FREQ_ARRAY_SIZE; x++) {
if (modes[dsp->progmode].freqs[x]) {
goertzel_init(&dsp->freqs[x], (float)modes[dsp->progmode].freqs[x], dsp->sample_rate);
max = x + 1;
@@ -1668,6 +1672,7 @@ static struct ast_dsp *__ast_dsp_new(unsigned int sample_rate)
dsp->digitmode = DSP_DIGITMODE_DTMF;
dsp->faxmode = DSP_FAXMODE_DETECT_CNG;
dsp->sample_rate = sample_rate;
+ dsp->freqcount = 0;
/* Initialize digit detector */
ast_digit_detect_init(&dsp->digit_state, dsp->digitmode & DSP_DIGITMODE_MF, dsp->sample_rate);
dsp->display_inband_dtmf_warning = 1;