Index: apps/app_meetme.c =================================================================== --- apps/app_meetme.c (revision 98514) +++ apps/app_meetme.c (working copy) @@ -1531,10 +1531,13 @@ struct timeval nexteventts = { 0, }; int to; int setusercount = 0; + int silencethreshold; if (!(user = ast_calloc(1, sizeof(*user)))) return ret; + silencethreshold = ast_dsp_get_threshold_from_settings(); + /* Possible timeout waiting for marked user */ if ((confflags & CONFFLAG_WAITMARKED) && !ast_strlen_zero(optargs[OPT_ARG_WAITMARKED]) && @@ -1699,7 +1702,7 @@ "%s/meetme/meetme-username-%s-%d", ast_config_AST_SPOOL_DIR, conf->confno, user->user_no); if (confflags & CONFFLAG_INTROUSERNOREVIEW) - res = ast_play_and_record(chan, "vm-rec-name", user->namerecloc, 10, "sln", &duration, 128, 0, NULL); + res = ast_play_and_record(chan, "vm-rec-name", user->namerecloc, 10, "sln", &duration, silencethreshold, 0, NULL); else res = ast_record_review(chan, "vm-rec-name", user->namerecloc, 10, "sln", &duration, NULL); if (res == -1) Index: apps/app_minivm.c =================================================================== --- apps/app_minivm.c (revision 98514) +++ apps/app_minivm.c (working copy) @@ -2362,7 +2362,6 @@ /* First, set some default settings */ global_externnotify[0] = '\0'; global_logfile[0] = '\0'; - global_silencethreshold = 256; global_vmmaxmessage = 2000; global_maxgreet = 2000; global_vmminmessage = 0; @@ -2377,6 +2376,8 @@ memset(&global_stats, 0, sizeof(global_stats)); global_stats.reset = ast_tvnow(); + global_silencethreshold = ast_dsp_get_threshold_from_settings(); + /* Make sure we could load configuration file */ if (!cfg) { ast_log(LOG_WARNING, "Failed to load configuration file. Module activated with default settings.\n"); Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 98514) +++ apps/app_voicemail.c (working copy) @@ -8296,7 +8296,7 @@ } /* Silence treshold */ - silencethreshold = 256; + silencethreshold = ast_dsp_get_threshold_from_settings(); if ((val = ast_variable_retrieve(cfg, "general", "silencethreshold"))) silencethreshold = atoi(val); Index: apps/app_dial.c =================================================================== --- apps/app_dial.c (revision 98514) +++ apps/app_dial.c (working copy) @@ -55,6 +55,7 @@ #include "asterisk/privacy.h" #include "asterisk/stringfields.h" #include "asterisk/global_datastores.h" +#include "asterisk/dsp.h" static char *app = "Dial"; @@ -1116,6 +1117,7 @@ char callerid[60]; int res; char *l; + int silencethreshold; if (!ast_strlen_zero(chan->cid.cid_num)) { l = ast_strdupa(chan->cid.cid_num); @@ -1189,8 +1191,9 @@ "At the tone, please say your name:" */ + silencethreshold = ast_dsp_get_threshold_from_settings(); ast_answer(chan); - res = ast_play_and_record(chan, "priv-recordintro", pa->privintro, 4, "gsm", &duration, 128, 2000, 0); /* NOTE: I've reduced the total time to 4 sec */ + res = ast_play_and_record(chan, "priv-recordintro", pa->privintro, 4, "gsm", &duration, silencethreshold, 2000, 0); /* NOTE: I've reduced the total time to 4 sec */ /* don't think we'll need a lock removed, we took care of conflicts by naming the pa.privintro file */ if (res == -1) { Index: apps/app_waitforsilence.c =================================================================== --- apps/app_waitforsilence.c (revision 98514) +++ apps/app_waitforsilence.c (working copy) @@ -71,7 +71,7 @@ static int do_waiting(struct ast_channel *chan, int silencereqd, time_t waitstart, int timeout) { struct ast_frame *f; int dspsilence = 0; - static int silencethreshold = 128; + int silencethreshold; int rfmt = 0; int res = 0; struct ast_dsp *sildet; /* silence detector dsp */ @@ -89,6 +89,7 @@ ast_log(LOG_WARNING, "Unable to create silence detector :(\n"); return -1; } + silencethreshold = ast_dsp_get_threshold_from_settings(); ast_dsp_set_threshold(sildet, silencethreshold); /* Await silence... */ Index: apps/app_amd.c =================================================================== --- apps/app_amd.c (revision 98514) +++ apps/app_amd.c (working copy) @@ -339,6 +339,8 @@ struct ast_variable *var = NULL; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; + dfltSilenceThreshold = ast_dsp_get_threshold_from_settings(); + if (!(cfg = ast_config_load("amd.conf", config_flags))) { ast_log(LOG_ERROR, "Configuration file amd.conf missing.\n"); return -1; Index: apps/app_record.c =================================================================== --- apps/app_record.c (revision 98514) +++ apps/app_record.c (working copy) @@ -107,6 +107,7 @@ int rfmt = 0; int ioflags; int waitres; + int silencethreshold; struct ast_silence_generator *silgen = NULL; struct ast_flags flags = { 0, }; AST_DECLARE_APP_ARGS(args, @@ -243,7 +244,8 @@ ast_log(LOG_WARNING, "Unable to create silence detector :(\n"); return -1; } - ast_dsp_set_threshold(sildet, 256); + silencethreshold = ast_dsp_get_threshold_from_settings(); + ast_dsp_set_threshold(sildet, silencethreshold); } /* Create the directory if it does not exist. */ Index: apps/app_followme.c =================================================================== --- apps/app_followme.c (revision 98514) +++ apps/app_followme.c (working copy) @@ -51,6 +51,7 @@ #include "asterisk/utils.h" #include "asterisk/causes.h" #include "asterisk/astdb.h" +#include "asterisk/dsp.h" #include "asterisk/app.h" static char *app = "FollowMe"; @@ -882,9 +883,12 @@ char *argstr; char namerecloc[255]; int duration = 0; + int silencethreshold; struct ast_channel *caller; struct ast_channel *outbound; static char toast[80]; + + silencethreshold = ast_dsp_get_threshold_from_settings(); AST_DECLARE_APP_ARGS(args, AST_APP_ARG(followmeid); @@ -954,7 +958,7 @@ duration = 5; if (ast_test_flag(&targs.followmeflags, FOLLOWMEFLAG_RECORDNAME)) - if (ast_play_and_record(chan, "vm-rec-name", namerecloc, 5, "sln", &duration, 128, 0, NULL) < 0) + if (ast_play_and_record(chan, "vm-rec-name", namerecloc, 5, "sln", &duration, silencethreshold, 0, NULL) < 0) goto outrun; if (!ast_fileexists(namerecloc, NULL, chan->language)) Index: include/asterisk/dsp.h =================================================================== --- include/asterisk/dsp.h (revision 98514) +++ include/asterisk/dsp.h (working copy) @@ -108,4 +108,10 @@ /*! \brief Get tcount (Threshold counter) */ int ast_dsp_get_tcount(struct ast_dsp *dsp); +/*! \brief Get silence threshold from dsp.conf*/ +int ast_dsp_get_threshold_from_settings(void); + +/* \brief Reloads dsp settings from dsp.conf*/ +int ast_dsp_reload(void); + #endif /* _ASTERISK_DSP_H */ Index: main/loader.c =================================================================== --- main/loader.c (revision 98514) +++ main/loader.c (working copy) @@ -46,6 +46,7 @@ #include "asterisk/rtp.h" #include "asterisk/http.h" #include "asterisk/lock.h" +#include "asterisk/dsp.h" #ifdef DLFCNCOMPAT #include "asterisk/dlfcn-compat.h" @@ -247,6 +248,7 @@ { "rtp", ast_rtp_reload }, { "http", ast_http_reload }, { "logger", logger_reload }, + { "dsp", ast_dsp_reload}, { NULL, NULL } }; Index: main/app.c =================================================================== --- main/app.c (revision 98514) +++ main/app.c (working copy) @@ -1268,7 +1268,7 @@ int ast_record_review(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, const char *path) { - int silencethreshold = 128; + int silencethreshold; int maxsilence = 0; int res = 0; int cmd = 0; @@ -1286,6 +1286,8 @@ cmd = '3'; /* Want to start by recording */ + silencethreshold = ast_dsp_get_threshold_from_settings(); + while ((cmd >= 0) && (cmd != 't')) { switch (cmd) { case '1': Index: main/dsp.c =================================================================== --- main/dsp.c (revision 98514) +++ main/dsp.c (working copy) @@ -52,6 +52,7 @@ #include "asterisk/ulaw.h" #include "asterisk/alaw.h" #include "asterisk/utils.h" +#include "asterisk/config.h" /*! Number of goertzels for progress detect */ enum gsamp_size { @@ -166,6 +167,8 @@ #define BUSYDETECT_MARTIN #endif +#define CONFIG_FILE_NAME "dsp.conf" + typedef struct { int v2; int v3; @@ -1394,3 +1397,43 @@ { return dsp->tcount; } + +static int threshold = -1; + +int ast_dsp_get_threshold_from_settings() +{ + const int default_threshold = 256; + + struct ast_flags config_flags = { 0 }; + struct ast_config *cfg; + struct ast_variable *var; + + if(-1 == threshold) { + threshold = default_threshold; + cfg = ast_config_load(CONFIG_FILE_NAME, config_flags); + + if (!cfg) { + ast_log(LOG_WARNING, "No %s file :(\n", CONFIG_FILE_NAME); + } + else { + for (var = ast_variable_browse(cfg, "default"); var; var = var->next) { + if (!strcasecmp(var->name, "silencethreshold")){ + if(sscanf(var->value, "%d", &threshold) != 1) { + ast_log(LOG_WARNING, "Error processing file %s :(\n", CONFIG_FILE_NAME); + threshold = default_threshold; + } + break; + } + } + } + } + return threshold; +} + +int ast_dsp_reload(void) +{ + threshold = -1; + ast_dsp_get_threshold_from_settings(); + + return 0; +} Index: res/res_agi.c =================================================================== --- res/res_agi.c (revision 98514) +++ res/res_agi.c (working copy) @@ -1255,7 +1255,9 @@ char *silencestr=NULL; int rfmt=0; + int silencethreshold; + /* XXX EAGI FIXME XXX */ if (argc < 6) @@ -1295,7 +1297,8 @@ ast_log(LOG_WARNING, "Unable to create silence detector :(\n"); return -1; } - ast_dsp_set_threshold(sildet, 256); + silencethreshold = ast_dsp_get_threshold_from_settings(); + ast_dsp_set_threshold(sildet, silencethreshold); } /* backward compatibility, if no offset given, arg[6] would have been