]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6713 #resolve
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 4 Aug 2014 18:50:31 +0000 (23:50 +0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 4 Aug 2014 18:53:56 +0000 (23:53 +0500)
src/switch_core_media_bug.c
src/switch_ivr_async.c

index 9831d0099f79b50522b2e1eb798841adb37ca829..939ab5dae6e5cbc329f464b73f30ab9dff356925 100644 (file)
@@ -223,7 +223,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_read(switch_media_bug_t *b
                do_write = switch_buffer_inuse(bug->raw_write_buffer);
                switch_mutex_unlock(bug->write_mutex);
        }
-
+       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_ERROR,
+                                         "READ BUFFER %ld WRITE BUFFER %ld\n", do_read, do_write);
        if (bug->record_frame_size && bug->record_pre_buffer_max && (do_read || do_write) && bug->record_pre_buffer_count < bug->record_pre_buffer_max) {
                bug->record_pre_buffer_count++;
                return SWITCH_STATUS_FALSE;
index 3769965c989ef40648b2076db4d04e95ea5f5dc8..78d79c6be1e58cc7cfdbd8aa7671ce11b8ddf00e 100644 (file)
@@ -1328,44 +1328,47 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
                        frame.data = data;
                        frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
 
+                       for (;;) {
+                               status = switch_core_media_bug_read(bug, &frame, SWITCH_FALSE);
 
-                       status = switch_core_media_bug_read(bug, &frame, SWITCH_FALSE);
-
-                       if (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK) {
+                               if (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK) {
                                
-                               len = (switch_size_t) frame.datalen / 2;
+                                       len = (switch_size_t) frame.datalen / 2;
 
-                               if (len && switch_core_file_write(rh->fh, mask ? null_data : data, &len) != SWITCH_STATUS_SUCCESS && rh->hangup_on_error) {
-                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error writing %s\n", rh->file);
-                                       switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
-                                       switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
-                                       return SWITCH_FALSE;
-                               }
+                                       if (len && switch_core_file_write(rh->fh, mask ? null_data : data, &len) != SWITCH_STATUS_SUCCESS && rh->hangup_on_error) {
+                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error writing %s\n", rh->file);
+                                               switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
+                                               switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
+                                               return SWITCH_FALSE;
+                                       }
 
-                               /* check for silence timeout */
-                               if (rh->silence_threshold) {
-                                       switch_codec_implementation_t read_impl = { 0 };
-                                       switch_core_session_get_read_impl(session, &read_impl);
-                                       if (is_silence_frame(&frame, rh->silence_threshold, &read_impl)) {
-                                               if (!rh->silence_time) {
-                                                       /* start of silence */
-                                                       rh->silence_time = switch_micro_time_now();
-                                               } else {
-                                                       /* continuing silence */
-                                                       int duration_ms = (int)((switch_micro_time_now() - rh->silence_time) / 1000);
-                                                       if (rh->silence_timeout_ms > 0 && duration_ms >= rh->silence_timeout_ms) {
-                                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Recording file %s timeout: %i >= %i\n", rh->file, duration_ms, rh->silence_timeout_ms);
-                                                               switch_core_media_bug_set_flag(bug, SMBF_PRUNE);
+                                       /* check for silence timeout */
+                                       if (rh->silence_threshold) {
+                                               switch_codec_implementation_t read_impl = { 0 };
+                                               switch_core_session_get_read_impl(session, &read_impl);
+                                               if (is_silence_frame(&frame, rh->silence_threshold, &read_impl)) {
+                                                       if (!rh->silence_time) {
+                                                               /* start of silence */
+                                                               rh->silence_time = switch_micro_time_now();
+                                                       } else {
+                                                               /* continuing silence */
+                                                               int duration_ms = (int)((switch_micro_time_now() - rh->silence_time) / 1000);
+                                                               if (rh->silence_timeout_ms > 0 && duration_ms >= rh->silence_timeout_ms) {
+                                                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Recording file %s timeout: %i >= %i\n", rh->file, duration_ms, rh->silence_timeout_ms);
+                                                                       switch_core_media_bug_set_flag(bug, SMBF_PRUNE);
+                                                               }
+                                                       }
+                                               } else { /* not silence */
+                                                       if (rh->silence_time) {
+                                                               /* end of silence */
+                                                               rh->silence_time = 0;
+                                                               /* switch from initial timeout to final timeout */
+                                                               rh->silence_timeout_ms = rh->final_timeout_ms;
                                                        }
-                                               }
-                                       } else { /* not silence */
-                                               if (rh->silence_time) {
-                                                       /* end of silence */
-                                                       rh->silence_time = 0;
-                                                       /* switch from initial timeout to final timeout */
-                                                       rh->silence_timeout_ms = rh->final_timeout_ms;
                                                }
                                        }
+                               } else {
+                                       break;
                                }
                        }
                }