]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add playback_timeout_sec to core and make it useful in valet_parking
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 18 Jun 2010 23:07:31 +0000 (18:07 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 18 Jun 2010 23:07:31 +0000 (18:07 -0500)
src/mod/applications/mod_valet_parking/mod_valet_parking.c
src/switch_ivr_play_say.c

index 430cd2f73e1b283261e3b6ae00bf29d7cde315c6..aee49c76e92b8dca9a44a13c9732815a5db88803 100644 (file)
@@ -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);
index 3f19b9b96e9c3d49634a16600da1c25a5ca7ebee..0e0322452c8ace2c0b90afc2fd9d0b2320af05f3 100644 (file)
@@ -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;