mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 13:23:53 +00:00
Always try to resync if the clock difference is large
This commit is contained in:
parent
f97eaec7ab
commit
582efcdb9b
1 changed files with 24 additions and 38 deletions
|
@ -11,7 +11,6 @@
|
||||||
#define MAX_AUDIOQ_SIZE (5 * 16 * 1024)
|
#define MAX_AUDIOQ_SIZE (5 * 16 * 1024)
|
||||||
#define MAX_VIDEOQ_SIZE (5 * 256 * 1024)
|
#define MAX_VIDEOQ_SIZE (5 * 256 * 1024)
|
||||||
#define AV_SYNC_THRESHOLD 0.01
|
#define AV_SYNC_THRESHOLD 0.01
|
||||||
#define AV_NOSYNC_THRESHOLD 10.0
|
|
||||||
#define SAMPLE_CORRECTION_PERCENT_MAX 10
|
#define SAMPLE_CORRECTION_PERCENT_MAX 10
|
||||||
#define AUDIO_DIFF_AVG_NB 20
|
#define AUDIO_DIFF_AVG_NB 20
|
||||||
|
|
||||||
|
@ -161,11 +160,8 @@ class MovieAudioDecoder : public MWSound::Sound_Decoder
|
||||||
if(is->av_sync_type == AV_SYNC_AUDIO_MASTER)
|
if(is->av_sync_type == AV_SYNC_AUDIO_MASTER)
|
||||||
return samples_size;
|
return samples_size;
|
||||||
|
|
||||||
double ref_clock = get_master_clock(is);
|
// accumulate the clock difference
|
||||||
double diff = get_audio_clock(is) - ref_clock;
|
double diff = get_audio_clock(is) - get_master_clock(is);
|
||||||
if(diff < AV_NOSYNC_THRESHOLD)
|
|
||||||
{
|
|
||||||
// accumulate the diffs
|
|
||||||
is->audio_diff_cum = diff + is->audio_diff_avg_coef *
|
is->audio_diff_cum = diff + is->audio_diff_avg_coef *
|
||||||
is->audio_diff_cum;
|
is->audio_diff_cum;
|
||||||
if(is->audio_diff_avg_count < AUDIO_DIFF_AVG_NB)
|
if(is->audio_diff_avg_count < AUDIO_DIFF_AVG_NB)
|
||||||
|
@ -185,13 +181,6 @@ class MovieAudioDecoder : public MWSound::Sound_Decoder
|
||||||
samples_size = wanted_size;
|
samples_size = wanted_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* difference is TOO big; reset diff stuff */
|
|
||||||
is->audio_diff_avg_count = 0;
|
|
||||||
is->audio_diff_cum = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return samples_size;
|
return samples_size;
|
||||||
}
|
}
|
||||||
|
@ -499,16 +488,13 @@ void VideoState::video_refresh_timer()
|
||||||
diff = vp->pts - ref_clock;
|
diff = vp->pts - ref_clock;
|
||||||
|
|
||||||
/* Skip or repeat the frame. Take delay into account
|
/* Skip or repeat the frame. Take delay into account
|
||||||
FFPlay still doesn't "know if this is the best guess." */
|
* FFPlay still doesn't "know if this is the best guess." */
|
||||||
sync_threshold = (delay > AV_SYNC_THRESHOLD) ? delay : AV_SYNC_THRESHOLD;
|
sync_threshold = std::max(delay, AV_SYNC_THRESHOLD);
|
||||||
if(fabs(diff) < AV_NOSYNC_THRESHOLD)
|
|
||||||
{
|
|
||||||
if(diff <= -sync_threshold)
|
if(diff <= -sync_threshold)
|
||||||
delay = 0;
|
delay = 0;
|
||||||
else if(diff >= sync_threshold)
|
else if(diff >= sync_threshold)
|
||||||
delay = 2 * delay;
|
delay = 2 * delay;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this->frame_timer += delay;
|
this->frame_timer += delay;
|
||||||
|
|
||||||
/* compute the REAL delay */
|
/* compute the REAL delay */
|
||||||
|
|
Loading…
Reference in a new issue