mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-31 20:45:34 +00:00
Fix external clock
This commit is contained in:
parent
2f37d31108
commit
05c6483257
2 changed files with 11 additions and 11 deletions
|
@ -128,7 +128,7 @@ static double get_video_clock(VideoState *is)
|
|||
|
||||
static double get_external_clock(VideoState *is)
|
||||
{
|
||||
return av_gettime() / 1000000.0;
|
||||
return ((uint64_t)av_gettime()-is->external_clock_base) / 1000000.0;
|
||||
}
|
||||
|
||||
static double get_master_clock(VideoState *is)
|
||||
|
@ -746,7 +746,7 @@ int VideoState::stream_open(int stream_index, AVFormatContext *pFormatCtx)
|
|||
this->audio_diff_avg_coef = exp(log(0.01 / AUDIO_DIFF_AVG_NB));
|
||||
this->audio_diff_avg_count = 0;
|
||||
/* Correct audio only if larger error than this */
|
||||
this->audio_diff_threshold = 2.0 * 0.025/* 25 ms */;
|
||||
this->audio_diff_threshold = 2.0 * 0.050/* 50 ms */;
|
||||
|
||||
memset(&this->audio_pkt, 0, sizeof(this->audio_pkt));
|
||||
|
||||
|
@ -831,6 +831,7 @@ void VideoState::init(const std::string& resourceName)
|
|||
audio_index = i;
|
||||
}
|
||||
|
||||
this->external_clock_base = av_gettime();
|
||||
if(audio_index >= 0)
|
||||
this->stream_open(audio_index, this->format_ctx);
|
||||
if(video_index >= 0)
|
||||
|
|
|
@ -55,12 +55,12 @@ namespace MWRender
|
|||
|
||||
struct VideoState {
|
||||
VideoState ()
|
||||
: videoStream(-1), audioStream(-1), av_sync_type(0), external_clock(0),
|
||||
external_clock_time(0), audio_clock(0), audio_st(NULL), audio_diff_cum(0),
|
||||
audio_diff_avg_coef(0), audio_diff_threshold(0), audio_diff_avg_count(0), frame_timer(0),
|
||||
frame_last_pts(0), frame_last_delay(0), video_clock(0), video_current_pts(0),
|
||||
video_current_pts_time(0), video_st(NULL), rgbaFrame(NULL), pictq_size(0), pictq_rindex(0),
|
||||
pictq_windex(0), quit(false), refresh(0), format_ctx(0), sws_context(NULL), display_ready(0)
|
||||
: videoStream(-1), audioStream(-1), av_sync_type(0), external_clock_base(0),
|
||||
audio_clock(0), audio_st(NULL), audio_diff_cum(0), audio_diff_avg_coef(0),
|
||||
audio_diff_threshold(0), audio_diff_avg_count(0), frame_timer(0), frame_last_pts(0),
|
||||
frame_last_delay(0), video_clock(0), video_current_pts(0), video_current_pts_time(0),
|
||||
video_st(NULL), rgbaFrame(NULL), pictq_size(0), pictq_rindex(0), pictq_windex(0),
|
||||
quit(false), refresh(0), format_ctx(0), sws_context(NULL), display_ready(0)
|
||||
{}
|
||||
|
||||
~VideoState()
|
||||
|
@ -95,9 +95,8 @@ namespace MWRender
|
|||
|
||||
int videoStream, audioStream;
|
||||
|
||||
int av_sync_type;
|
||||
double external_clock; /* external clock base */
|
||||
int64_t external_clock_time;
|
||||
int av_sync_type;
|
||||
uint64_t external_clock_base;
|
||||
|
||||
double audio_clock;
|
||||
AVStream *audio_st;
|
||||
|
|
Loading…
Reference in a new issue