FS-10249: [mod_av] Audio gradually falls behind video in recordings -- init timer for audio only as well

This commit is contained in:
Anthony Minessale 2017-06-27 13:06:27 -05:00
parent 62ac7de80e
commit 236d6c0538
1 changed files with 6 additions and 2 deletions

View File

@ -2075,6 +2075,9 @@ static switch_status_t av_file_write(switch_file_handle_t *handle, void *data, s
}
}
if (!context->audio_timer.interval) {
switch_core_timer_init(&context->audio_timer, "soft", 1, handle->samplerate / 1000, context->pool);
}
while ((inuse = switch_buffer_inuse(context->audio_buffer)) >= bytes) {
AVPacket pkt = { 0 };
@ -2128,8 +2131,10 @@ static switch_status_t av_file_write(switch_file_handle_t *handle, void *data, s
ret = write_frame(context->fc, &context->audio_st.st->codec->time_base, context->audio_st.st, &pkt);
if (context->mutex) switch_mutex_unlock(context->mutex);
if (ret < 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error while writing audio frame: %s\n", get_error_text(ret));
context->errs++;
if ((context->errs % 10) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error while writing audio frame: %s\n", get_error_text(ret));
}
//switch_goto_status(SWITCH_STATUS_FALSE, end);
} else {
context->errs = 0;
@ -2640,7 +2645,6 @@ static switch_status_t av_file_write_video(switch_file_handle_t *handle, switch_
//switch_threadattr_priority_set(thd_attr, SWITCH_PRI_REALTIME);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_core_timer_init(&context->video_timer, "soft", 1, 90, context->pool);
switch_core_timer_init(&context->audio_timer, "soft", 1, handle->samplerate / 1000, context->pool);
context->eh.video_timer = &context->video_timer;
context->audio_st.frame->pts = 0;
context->audio_st.next_pts = 0;