[asterisk-commits] alecdavis: branch 10 r374370 - in /branches/10: ./ main/dsp.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Oct 3 23:18:54 CDT 2012


Author: alecdavis
Date: Wed Oct  3 23:18:44 2012
New Revision: 374370

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=374370
Log:
_dsp_init: bring inline with trunk

preparation for clean merge of DTMF TWIST patch

No functional changes, just style.

alecdavis (license 585)
Reported by: Alec Davis
Tested by: alecdavis

related https://reviewboard.asterisk.org/r/2141
........

Merged revisions 374365 from http://svn.asterisk.org/svn/asterisk/branches/1.8

Modified:
    branches/10/   (props changed)
    branches/10/main/dsp.c

Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/10/main/dsp.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/main/dsp.c?view=diff&rev=374370&r1=374369&r2=374370
==============================================================================
--- branches/10/main/dsp.c (original)
+++ branches/10/main/dsp.c Wed Oct  3 23:18:44 2012
@@ -1817,33 +1817,34 @@
 
 static int _dsp_init(int reload)
 {
+	struct ast_config *cfg;
+	struct ast_variable *v;
 	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
-	struct ast_config *cfg;
-
-	cfg = ast_config_load2(CONFIG_FILE_NAME, "dsp", config_flags);
+	int cfg_threshold;
+
+	if ((cfg = ast_config_load2(CONFIG_FILE_NAME, "dsp", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) {
+		return 0;
+	}
+
+	thresholds[THRESHOLD_SILENCE] = DEFAULT_SILENCE_THRESHOLD;
+
 	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) {
-		const char *value;
-
-		value = ast_variable_retrieve(cfg, "default", "silencethreshold");
-		if (value && sscanf(value, "%30d", &thresholds[THRESHOLD_SILENCE]) != 1) {
-			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] = DEFAULT_SILENCE_THRESHOLD;
-		}
-
-		ast_config_destroy(cfg);
-	}
+	for (v = ast_variable_browse(cfg, "default"); v; v = v->next) {
+		if (!strcasecmp(v->name, "silencethreshold")) {
+			if (sscanf(v->value, "%30d", &cfg_threshold) < 1) {
+				ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", v->value);
+			} else if (cfg_threshold < 0) {
+				ast_log(LOG_WARNING, "Invalid silence threshold '%d' specified, using default\n", cfg_threshold);
+			} else {
+				thresholds[THRESHOLD_SILENCE] = cfg_threshold;
+			}
+		}
+	}
+	ast_config_destroy(cfg);
+
 	return 0;
 }
 
@@ -1861,4 +1862,3 @@
 {
 	return _dsp_init(1);
 }
-




More information about the asterisk-commits mailing list