diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 4157d9a766..f67fc4a8a7 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -86,6 +86,7 @@ static inline switch_bool_t switch_is_moh(const char *s) return SWITCH_TRUE; } +#define switch_is_valid_rate(_tmp) (_tmp == 8000 || _tmp == 16000 || _tmp == 32000 || _tmp == 11025 || _tmp == 22050 || _tmp == 44100 || _tmp == 48000) static inline int switch_string_has_escaped_data(const char *in) { diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index bee547a5d8..d5113c4cc4 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -587,7 +587,7 @@ static vm_profile_t * load_profile(const char *profile_name) if (!switch_strlen_zero(val)) { tmp = atoi(val); } - if (tmp == 8000 || tmp == 16000 || tmp == 32000 || tmp == 11025 || tmp == 22050 || tmp == 44100) { + if (switch_is_valid_rate(tmp)) { record_sample_rate = tmp; } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid samplerate %s\n", val); diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c index f2cfc7c08d..cb2cc2b1e2 100644 --- a/src/switch_ivr_async.c +++ b/src/switch_ivr_async.c @@ -979,7 +979,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session(switch_core_session_t tmp = atoi(vval); - if (tmp == 8000 || tmp == 16000 || tmp == 32000 || tmp == 11025 || tmp == 22050 || tmp == 44100) { + if (switch_is_valid_rate(tmp)) { rh->fh->samplerate = tmp; } } diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c index 5d7dc0c837..6b80abc03a 100644 --- a/src/switch_ivr_play_say.c +++ b/src/switch_ivr_play_say.c @@ -421,7 +421,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se tmp = atoi(vval); - if (tmp == 8000 || tmp == 16000 || tmp == 32000 || tmp == 11025 || tmp == 22050 || tmp == 44100) { + if (switch_is_valid_rate(tmp)) { fh->samplerate = tmp; } }