diff options
author | George Joseph <gjoseph@digium.com> | 2017-05-25 19:01:57 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-05-25 19:01:57 -0500 |
commit | 366b10a5007b1e4b3ec8dcf569b9b07f92c4770e (patch) | |
tree | ec1a59a5ebf8e1e9eecf59370cc22b26c225f94b /res/res_agi.c | |
parent | 915acf1e5d6ca69c9d12e873068efffeb42d2e98 (diff) | |
parent | d847fe6585bee14b6b9f76d0b6c50b0b4d5bf9cc (diff) |
Merge "res_agi: Allow configuration of audio format of EAGI pipe"
Diffstat (limited to 'res/res_agi.c')
-rw-r--r-- | res/res_agi.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/res/res_agi.c b/res/res_agi.c index 229ce7277..3af4cdb4f 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -4575,15 +4575,30 @@ static int eagi_exec(struct ast_channel *chan, const char *data) { int res; struct ast_format *readformat; + struct ast_format *requested_format = NULL; + const char *requested_format_name; if (ast_check_hangup(chan)) { ast_log(LOG_ERROR, "EAGI cannot be run on a dead/hungup channel, please use AGI.\n"); return 0; } + + requested_format_name = pbx_builtin_getvar_helper(chan, "EAGI_AUDIO_FORMAT"); + if (requested_format_name) { + requested_format = ast_format_cache_get(requested_format_name); + if (requested_format) { + ast_verb(3, "<%s> Setting EAGI audio pipe format to %s\n", + ast_channel_name(chan), ast_format_get_name(requested_format)); + } else { + ast_log(LOG_ERROR, "Could not find requested format: %s\n", requested_format_name); + } + } + readformat = ao2_bump(ast_channel_readformat(chan)); - if (ast_set_read_format(chan, ast_format_slin)) { + if (ast_set_read_format(chan, requested_format ?: ast_format_slin)) { ast_log(LOG_WARNING, "Unable to set channel '%s' to linear mode\n", ast_channel_name(chan)); - ao2_ref(readformat, -1); + ao2_cleanup(requested_format); + ao2_cleanup(readformat); return -1; } res = agi_exec_full(chan, data, 1, 0); @@ -4593,7 +4608,8 @@ static int eagi_exec(struct ast_channel *chan, const char *data) ast_format_get_name(readformat)); } } - ao2_ref(readformat, -1); + ao2_cleanup(requested_format); + ao2_cleanup(readformat); return res; } |