mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1143575. Make GetClock return a TimeStamp as well as the stream time. r=cpearce
This makes MediaDecoderStateMachine::GetVideoStreamPosition compute a time that's more consistent with the audio clock.
This commit is contained in:
parent
2490c4dbb8
commit
fd0c8ca202
@ -2547,7 +2547,7 @@ int64_t MediaDecoderStateMachine::GetStreamClock() const
|
||||
return mStreamStartTime + mDecodedStream->GetPosition();
|
||||
}
|
||||
|
||||
int64_t MediaDecoderStateMachine::GetVideoStreamPosition() const
|
||||
int64_t MediaDecoderStateMachine::GetVideoStreamPosition(TimeStamp aTimeStamp) const
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
@ -2557,13 +2557,13 @@ int64_t MediaDecoderStateMachine::GetVideoStreamPosition() const
|
||||
}
|
||||
|
||||
// Time elapsed since we started playing.
|
||||
int64_t delta = DurationToUsecs(TimeStamp::Now() - mPlayStartTime);
|
||||
int64_t delta = DurationToUsecs(aTimeStamp - mPlayStartTime);
|
||||
// Take playback rate into account.
|
||||
delta *= mPlaybackRate;
|
||||
return mPlayDuration + delta;
|
||||
}
|
||||
|
||||
int64_t MediaDecoderStateMachine::GetClock() const
|
||||
int64_t MediaDecoderStateMachine::GetClock(TimeStamp* aTimeStamp) const
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
@ -2573,6 +2573,7 @@ int64_t MediaDecoderStateMachine::GetClock() const
|
||||
// audio, or don't have audio, use the system clock. If our output is being
|
||||
// fed to a MediaStream, use that stream as the source of the clock.
|
||||
int64_t clock_time = -1;
|
||||
TimeStamp t;
|
||||
if (!IsPlaying()) {
|
||||
clock_time = mPlayDuration;
|
||||
} else {
|
||||
@ -2581,11 +2582,15 @@ int64_t MediaDecoderStateMachine::GetClock() const
|
||||
} else if (HasAudio() && !mAudioCompleted) {
|
||||
clock_time = GetAudioClock();
|
||||
} else {
|
||||
t = TimeStamp::Now();
|
||||
// Audio is disabled on this system. Sync to the system clock.
|
||||
clock_time = GetVideoStreamPosition();
|
||||
clock_time = GetVideoStreamPosition(t);
|
||||
}
|
||||
NS_ASSERTION(GetMediaTime() <= clock_time, "Clock should go forwards.");
|
||||
}
|
||||
if (aTimeStamp) {
|
||||
*aTimeStamp = t.IsNull() ? TimeStamp::Now() : t;
|
||||
}
|
||||
|
||||
return clock_time;
|
||||
}
|
||||
@ -2605,8 +2610,8 @@ void MediaDecoderStateMachine::UpdateRenderedVideoFrames()
|
||||
SendStreamData();
|
||||
}
|
||||
|
||||
const int64_t clock_time = GetClock();
|
||||
TimeStamp nowTime = TimeStamp::Now();
|
||||
TimeStamp nowTime;
|
||||
const int64_t clock_time = GetClock(&nowTime);
|
||||
// Skip frames up to the frame at the playback position, and figure out
|
||||
// the time remaining until it's time to display the next frame.
|
||||
int64_t remainingTime = AUDIO_DURATION_USECS;
|
||||
@ -2999,8 +3004,9 @@ MediaDecoderStateMachine::LogicalPlaybackRateChanged()
|
||||
if (!HasAudio() && IsPlaying()) {
|
||||
// Remember how much time we've spent in playing the media
|
||||
// for playback rate will change from now on.
|
||||
mPlayDuration = GetVideoStreamPosition();
|
||||
SetPlayStartTime(TimeStamp::Now());
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
mPlayDuration = GetVideoStreamPosition(now);
|
||||
SetPlayStartTime(now);
|
||||
}
|
||||
|
||||
mPlaybackRate = mLogicalPlaybackRate;
|
||||
|
@ -469,13 +469,15 @@ protected:
|
||||
|
||||
// Get the video stream position, taking the |playbackRate| change into
|
||||
// account. This is a position in the media, not the duration of the playback
|
||||
// so far.
|
||||
int64_t GetVideoStreamPosition() const;
|
||||
// so far. Returns the position for the given time aTimeStamp.
|
||||
int64_t GetVideoStreamPosition(TimeStamp aTimeStamp) const;
|
||||
|
||||
// Return the current time, either the audio clock if available (if the media
|
||||
// has audio, and the playback is possible), or a clock for the video.
|
||||
// Called on the state machine thread.
|
||||
int64_t GetClock() const;
|
||||
// If aTimeStamp is non-null, set *aTimeStamp to the TimeStamp corresponding
|
||||
// to the returned stream time.
|
||||
int64_t GetClock(TimeStamp* aTimeStamp = nullptr) const;
|
||||
|
||||
nsresult DropAudioUpToSeekTarget(AudioData* aSample);
|
||||
nsresult DropVideoUpToSeekTarget(VideoData* aSample);
|
||||
|
Loading…
Reference in New Issue
Block a user