aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorpabelanger <pabelanger@f38db490-d61c-443f-a65b-d21fe96a405b>2010-06-07 17:34:45 +0000
committerpabelanger <pabelanger@f38db490-d61c-443f-a65b-d21fe96a405b>2010-06-07 17:34:45 +0000
commit6544b164d8ff6c2ebac7b65a52956f0313d3a89f (patch)
tree04f4ccbebd067023b2ca5c20e75fecb93d874b4a /main
parent3703d2ca4c790e77e4526bd9cdc75345deee2bd3 (diff)
Set threshold for silence detection defaults to 256
(closes issue #15685) Reported by: david_s5 Patches: dsp-silence-threshold-init.diff uploaded by dant (license 670) issue15685.patch.v5 uploaded by pabelanger (license 224) Tested by: danti Review: https://reviewboard.asterisk.org/r/670/ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@268690 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/dsp.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/main/dsp.c b/main/dsp.c
index 649ae9ffd..cba01b5f1 100644
--- a/main/dsp.c
+++ b/main/dsp.c
@@ -213,6 +213,12 @@ enum gsamp_thresh {
/* How many successive misses needed to consider end of a digit */
#define DTMF_MISSES_TO_END 3
+/*!
+ * \brief The default silence threshold we will use if an alternate
+ * configured value is not present or is invalid.
+ */
+static const int DEFAULT_SILENCE_THRESHOLD = 256;
+
#define CONFIG_FILE_NAME "dsp.conf"
typedef struct {
@@ -1674,19 +1680,25 @@ static int _dsp_init(int reload)
struct ast_config *cfg;
cfg = ast_config_load2(CONFIG_FILE_NAME, "dsp", config_flags);
- if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) {
+ if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
+ ast_verb(5, "Can't find dsp config file %s. Assuming default silencethreshold of %d.\n", CONFIG_FILE_NAME, DEFAULT_SILENCE_THRESHOLD);
+ thresholds[THRESHOLD_SILENCE] = DEFAULT_SILENCE_THRESHOLD;
+ return 0;
+ }
+
+ if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
}
- if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED) {
+ if (cfg) {
const char *value;
value = ast_variable_retrieve(cfg, "default", "silencethreshold");
if (value && sscanf(value, "%30d", &thresholds[THRESHOLD_SILENCE]) != 1) {
- ast_log(LOG_WARNING, "%s: '%s' is not a valid silencethreshold value\n", CONFIG_FILE_NAME, value);
- thresholds[THRESHOLD_SILENCE] = 256;
+ ast_verb(5, "%s: '%s' is not a valid silencethreshold value\n", CONFIG_FILE_NAME, value);
+ thresholds[THRESHOLD_SILENCE] = DEFAULT_SILENCE_THRESHOLD;
} else if (!value) {
- thresholds[THRESHOLD_SILENCE] = 256;
+ thresholds[THRESHOLD_SILENCE] = DEFAULT_SILENCE_THRESHOLD;
}
ast_config_destroy(cfg);