module_name);
if (!strcasecmp(func, "play-file")) {
- status = switch_ivr_play_file(session, NULL, odata, args);
+ char *volume_str = (char *) switch_xml_attr_soft(action, "volume");
+ switch_file_handle_t pfh = { 0 };
+ if (volume_str && switch_is_number(volume_str)) {
+ int32_t volume = atoi(volume_str);
+
+ switch_normalize_volume_granular(volume)
+ pfh.volgranular = volume;
+
+ switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Setting playback volume to %d\n", pfh.volgranular);
+ }
+ status = switch_ivr_play_file(session, &pfh, odata, args);
} else if (!strcasecmp(func, "phrase")) {
char *name = (char *) switch_xml_attr_soft(action, "phrase");
status = switch_ivr_phrase_macro(session, name, odata, chan_lang, args);
}
#endif
#endif
- if (!switch_test_flag(fh, SWITCH_FILE_NATIVE) && fh->vol) {
- switch_change_sln_volume(write_frame.data, write_frame.datalen / 2, fh->vol);
+ if (!switch_test_flag(fh, SWITCH_FILE_NATIVE)) {
+ if (fh->volgranular) {
+ switch_change_sln_volume_granular(write_frame.data, write_frame.datalen / 2, fh->volgranular);
+ } else if (fh->vol) { /* deprecated 2022-Q1 */
+ switch_change_sln_volume(write_frame.data, write_frame.datalen / 2, fh->vol);
+ }
}
/* write silence while dmachine is in reading state */