add playback_timeout_sec to core and make it useful in valet_parking
This commit is contained in:
parent
6f41b446cb
commit
dac1243900
|
@ -279,11 +279,18 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
|||
args.buflen = sizeof(dbuf);
|
||||
|
||||
switch_mutex_unlock(lot->mutex);
|
||||
|
||||
if (!strcasecmp(music, "silence")) {
|
||||
switch_ivr_collect_digits_callback(session, &args, 0, 0);
|
||||
} else {
|
||||
switch_ivr_play_file(session, NULL, music, &args);
|
||||
music = "silence_stream://-1";
|
||||
}
|
||||
|
||||
while(switch_channel_ready(channel)) {
|
||||
switch_status_t pstatus = switch_ivr_play_file(session, NULL, music, &args);
|
||||
if (pstatus == SWITCH_STATUS_BREAK || pstatus == SWITCH_STATUS_TIMEOUT) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch_mutex_lock(lot->mutex);
|
||||
switch_core_hash_delete(lot->hash, ext);
|
||||
switch_mutex_unlock(lot->mutex);
|
||||
|
|
|
@ -913,9 +913,18 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||
int argc;
|
||||
int cur;
|
||||
int done = 0;
|
||||
int timeout_samples = 0;
|
||||
const char *var;
|
||||
|
||||
switch_core_session_get_read_impl(session, &read_impl);
|
||||
|
||||
if ((var = switch_channel_get_variable(channel, "playback_timeout_sec"))) {
|
||||
int tmp = atoi(var);
|
||||
if (tmp > 1) {
|
||||
timeout_samples = read_impl.actual_samples_per_second * tmp;
|
||||
}
|
||||
}
|
||||
|
||||
if ((play_delimiter_val = switch_channel_get_variable(channel, "playback_delimiter"))) {
|
||||
play_delimiter = *play_delimiter_val;
|
||||
|
||||
|
@ -1402,6 +1411,17 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||
fh->offset_pos += write_frame.samples / 2;
|
||||
status = switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0);
|
||||
|
||||
if (timeout_samples) {
|
||||
timeout_samples -= write_frame.samples;
|
||||
if (timeout_samples <= 0) {
|
||||
timeout_samples = 0;
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "timeout reached playing file\n");
|
||||
status = SWITCH_STATUS_TIMEOUT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (status == SWITCH_STATUS_MORE_DATA) {
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue