a/v sync, proper indenting and always queue next frame. warn when we get out of sync (when playing audio)

This commit is contained in:
niels
2014-12-22 21:52:39 +01:00
parent 0edda68f7c
commit 6e60a04445

View File

@@ -2609,7 +2609,7 @@ static void veejay_playback_cycle(veejay_t * info)
return ; return ;
} }
for(n = 0; n < QUEUE_LEN ; n ++ ) { for(n = 0; n < QUEUE_LEN ; n ++ ) {
veejay_mjpeg_queue_buf(info, n,1 ); veejay_mjpeg_queue_buf(info, n,1 );
} }
@@ -2706,29 +2706,28 @@ static void veejay_playback_cycle(veejay_t * info)
skipv = 0; skipv = 0;
skipa = 0; skipa = 0;
skipi = 0; skipi = 0;
if (info->sync_correction) { if (info->sync_correction) {
if (stats.tdiff > settings->spvf) { if (stats.tdiff > settings->spvf) {
skipa = 1; skipa = 1;
// skipv = 1; if (info->sync_ins_frames && current_speed != 0) {
if (info->sync_ins_frames && current_speed != 0) { skipi = 1;
skipi = 1; }
} nvcorr++;
nvcorr++; stats.num_corrs_a++;
stats.num_corrs_a++; stats.tdiff -= settings->spvf;
stats.tdiff -= settings->spvf; stats.stats_changed = 1;
stats.stats_changed = 1; }
} if (stats.tdiff < -settings->spvf) {
if (stats.tdiff < -settings->spvf) { /* Video is behind audio */
/* Video is behind audio */ skipv = 1;
skipv = 1; if (!info->sync_skip_frames && current_speed != 0) {
if (!info->sync_skip_frames && current_speed != 0) skipi = 1;
skipi = 1; }
nvcorr--;
nvcorr--; stats.num_corrs_b++;
stats.num_corrs_b++; stats.tdiff += settings->spvf;
stats.tdiff += settings->spvf; stats.stats_changed = 1;
stats.stats_changed = 1; }
}
} }
frame = n % QUEUE_LEN; frame = n % QUEUE_LEN;
@@ -2762,18 +2761,14 @@ static void veejay_playback_cycle(veejay_t * info)
} }
#ifdef HAVE_SDL #ifdef HAVE_SDL
te = SDL_GetTicks(); te = SDL_GetTicks();
info->real_fps = (int)( te - ts ); info->real_fps = (int)( te - ts );
#else #else
info->real_fps = 0; info->real_fps = 0;
#endif #endif
if( info->real_fps > (1000* settings->spvf ) && info->audio ) { if( info->real_fps > (1000 * settings->spvf ) && info->audio == AUDIO_PLAY) {
veejay_msg(VEEJAY_MSG_WARNING, "Rendering video frame takes too long! (measured %ld ms).", info->real_fps); veejay_msg(VEEJAY_MSG_WARNING, "Rendering audio/video frame takes too long (measured %ld ms). Can't keep pace with audio!", info->real_fps);
//continue;
} }
if(!info->audio && skipv )
continue;
veejay_mjpeg_queue_buf(info,frame, 1 ); veejay_mjpeg_queue_buf(info,frame, 1 );
stats.nqueue ++; stats.nqueue ++;
@@ -2782,9 +2777,7 @@ static void veejay_playback_cycle(veejay_t * info)
/* output statistics */ /* output statistics */
if (el->has_audio && (info->audio==AUDIO_PLAY)) if (el->has_audio && (info->audio==AUDIO_PLAY))
stats.audio = settings->audio_mute ? 0 : 1; stats.audio = settings->audio_mute ? 0 : 1;
stats.stats_changed = 0; stats.stats_changed = 0;
// stats.frame = settings->current_frame_num;
// stats.nsync = 0;
} }
FINISH: FINISH:
@@ -2793,8 +2786,8 @@ static void veejay_playback_cycle(veejay_t * info)
* Never try to sync on the last buffer, it is a hostage of * Never try to sync on the last buffer, it is a hostage of
* the codec since it is played over and over again * the codec since it is played over and over again
*/ */
if (info->audio_running || info->audio ==AUDIO_PLAY) if (info->audio_running || info->audio == AUDIO_PLAY)
vj_perform_audio_stop(info); vj_perform_audio_stop(info);
} }
/****************************************************** /******************************************************