SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file, switch_input_args_t *args)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
- int16_t *abuf;
+ int16_t *abuf = NULL;
switch_dtmf_t dtmf = {0};
uint32_t interval = 0, samples = 0, framelen, sample_start = 0;
uint32_t ilen = 0;
const char *prebuf;
const char *alt = NULL;
- switch_zmalloc(abuf, FILE_STARTSAMPLES * sizeof(*abuf));
-
switch_channel_pre_answer(channel);
prefix = switch_channel_get_variable(channel, "sound_prefix");
}
-
if (!prefix) {
prefix = SWITCH_GLOBAL_dirs.base_dir;
}
-
if (!strstr(file, SWITCH_URL_SEPARATOR)) {
if (!switch_is_file_path(file)) {
file = switch_core_session_sprintf(session, "%s%s%s", prefix, SWITCH_PATH_SEPARATOR, file);
asis = 1;
}
+ switch_zmalloc(abuf, FILE_STARTSAMPLES * sizeof(*abuf));
write_frame.data = abuf;
write_frame.buflen = FILE_STARTSAMPLES;
if (done || olen <= 0) {
break;
}
-
if (!asis) {
if (fh->speed > 2) {
end:
- free(abuf);
+ switch_safe_free(abuf);
switch_core_session_reset(session, SWITCH_TRUE);
return status;