summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/app_voicemail.c12
-rw-r--r--include/asterisk/file.h11
-rw-r--r--main/app.c12
3 files changed, 27 insertions, 8 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index a69b306f2..673990ca4 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -10617,7 +10617,7 @@ static int load_config(int reload)
char *cat;
struct ast_variable *var;
const char *val;
- char *q, *stringp;
+ char *q, *stringp, *tmp;
int x;
int tmpadsi[4];
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
@@ -10926,8 +10926,16 @@ static int load_config(int reload)
}
val = ast_variable_retrieve(cfg, "general", "format");
- if (!val)
+ if (!val) {
val = "wav";
+ } else {
+ tmp = ast_strdupa(val);
+ val = ast_format_str_reduce(tmp);
+ if (!val) {
+ ast_log(LOG_ERROR, "Error processing format string, defaulting to format 'wav'\n");
+ val = "wav";
+ }
+ }
ast_copy_string(vmfmts, val, sizeof(vmfmts));
skipms = 3000;
diff --git a/include/asterisk/file.h b/include/asterisk/file.h
index 43b32fd12..8def42ae5 100644
--- a/include/asterisk/file.h
+++ b/include/asterisk/file.h
@@ -40,6 +40,9 @@ extern "C" {
struct ast_filestream;
struct ast_format;
+/*! The maximum number of formats we expect to see in a format string */
+#define AST_MAX_FORMATS 10
+
/*! Convenient for waiting */
#define AST_DIGIT_ANY "0123456789#*ABCD"
#define AST_DIGIT_ANYNUM "0123456789"
@@ -325,6 +328,14 @@ int ast_file_init(void);
#define AST_RESERVED_POINTERS 20
+/*! Remove duplicate formats from a format string. */
+/*!
+ * \param fmts a format string, this string will be modified
+ * \retval NULL error
+ * \return a pointer to the reduced format string, this is a pointer to fmts
+ */
+char *ast_format_str_reduce(char *fmts);
+
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
diff --git a/main/app.c b/main/app.c
index 881f99dad..1c17984f4 100644
--- a/main/app.c
+++ b/main/app.c
@@ -55,7 +55,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
AST_THREADSTORAGE_PUBLIC(ast_str_thread_global_buf);
-#define MAX_OTHER_FORMATS 10
+#define AST_MAX_FORMATS 10
static AST_RWLIST_HEAD_STATIC(groups, ast_group_info);
@@ -693,8 +693,8 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
char *fmts;
char comment[256];
int x, fmtcnt = 1, res = -1, outmsg = 0;
- struct ast_filestream *others[MAX_OTHER_FORMATS];
- char *sfmt[MAX_OTHER_FORMATS];
+ struct ast_filestream *others[AST_MAX_FORMATS];
+ char *sfmt[AST_MAX_FORMATS];
char *stringp = NULL;
time_t start, end;
struct ast_dsp *sildet = NULL; /* silence detector dsp */
@@ -747,8 +747,8 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
sfmt[0] = ast_strdupa(fmts);
while ((fmt = strsep(&stringp, "|"))) {
- if (fmtcnt > MAX_OTHER_FORMATS - 1) {
- ast_log(LOG_WARNING, "Please increase MAX_OTHER_FORMATS in app.c\n");
+ if (fmtcnt > AST_MAX_FORMATS - 1) {
+ ast_log(LOG_WARNING, "Please increase AST_MAX_FORMATS in file.h\n");
break;
}
sfmt[fmtcnt++] = ast_strdupa(fmt);
@@ -938,7 +938,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
}
if (prepend && outmsg) {
- struct ast_filestream *realfiles[MAX_OTHER_FORMATS];
+ struct ast_filestream *realfiles[AST_MAX_FORMATS];
struct ast_frame *fr;
for (x = 0; x < fmtcnt; x++) {