提交 3253bcb3 authored 作者: Anthony Minessale's avatar Anthony Minessale

FS-3147 --resolve I finally tracked this down to the actual recordings generated…

FS-3147 --resolve I finally tracked this down to the actual recordings generated by mod_conference.  This patch delays the recording slightly to allow time for the buffer to fill up, we were riding it so closely that sometimes we would come up short and inject silence into the file to preserve time passing
上级 3ad4ae0a
......@@ -2823,6 +2823,9 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th
uint32_t rlen;
switch_size_t data_buf_len;
switch_event_t *event;
int no_data = 0;
int lead_in = 20;
switch_size_t len = 0;
data_buf_len = samples * sizeof(int16_t);
......@@ -2910,9 +2913,15 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th
switch_event_fire(&event);
}
while (switch_test_flag(member, MFLAG_RUNNING) && switch_test_flag(conference, CFLAG_RUNNING) && conference->count) {
switch_size_t len = 0;
len = 0;
if (lead_in) {
lead_in--;
goto loop;
}
mux_used = (uint32_t) switch_buffer_inuse(member->mux_buffer);
if (switch_test_flag(member, MFLAG_FLUSH_BUFFER)) {
......@@ -2925,36 +2934,64 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th
switch_clear_flag_locked(member, MFLAG_FLUSH_BUFFER);
}
again:
if (switch_test_flag((&fh), SWITCH_FILE_PAUSE)) {
switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER);
} else {
if (mux_used) {
/* Flush the output buffer and write all the data (presumably muxed) to the file */
switch_mutex_lock(member->audio_out_mutex);
low_count = 0;
goto loop;
}
if ((rlen = (uint32_t) switch_buffer_read(member->mux_buffer, data_buf, data_buf_len))) {
len = (switch_size_t) rlen / sizeof(int16_t);
}
switch_mutex_unlock(member->audio_out_mutex);
if (mux_used >= data_buf_len) {
/* Flush the output buffer and write all the data (presumably muxed) to the file */
switch_mutex_lock(member->audio_out_mutex);
low_count = 0;
if ((rlen = (uint32_t) switch_buffer_read(member->mux_buffer, data_buf, data_buf_len))) {
len = (switch_size_t) rlen / sizeof(int16_t);
no_data = 0;
}
switch_mutex_unlock(member->audio_out_mutex);
}
if (len < (switch_size_t) samples) {
memset(data_buf + (len * sizeof(int16_t)), 255, ((switch_size_t) samples - len) * sizeof(int16_t));
len = (switch_size_t) samples;
if (len == 0) {
mux_used = (uint32_t) switch_buffer_inuse(member->mux_buffer);
if (mux_used >= data_buf_len) {
goto again;
}
if (!len || switch_core_file_write(&fh, data_buf, &len) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write Failed\n");
switch_clear_flag_locked(member, MFLAG_RUNNING);
if (++no_data < 2) {
goto loop;
}
memset(data_buf, 255, (switch_size_t) data_buf_len);
len = (switch_size_t) samples;
}
if (!len || switch_core_file_write(&fh, data_buf, &len) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write Failed\n");
switch_clear_flag_locked(member, MFLAG_RUNNING);
}
loop:
switch_core_timer_next(&timer);
} /* Rinse ... Repeat */
end:
for(;;) {
switch_mutex_lock(member->audio_out_mutex);
if ((rlen = (uint32_t) switch_buffer_read(member->mux_buffer, data_buf, data_buf_len))) {
len = (switch_size_t) rlen / sizeof(int16_t);
switch_core_file_write(&fh, data_buf, &len);
} else {
break;
}
switch_mutex_unlock(member->audio_out_mutex);
}
switch_safe_free(data_buf);
switch_core_timer_destroy(&timer);
conference_del_member(conference, member);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论