mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1091008 - Reimplement HasLowUndecodedData in terms of GetBuffered. r=cpearce
Since GetBuffered now has a sane implementation for MSE, this should make this function sane for MSE as well.
This commit is contained in:
parent
d3266de598
commit
18278b4669
@ -92,6 +92,15 @@ public:
|
||||
static const index_type NoIndex = index_type(-1);
|
||||
|
||||
index_type Find(double aTime);
|
||||
|
||||
bool Contains(double aStart, double aEnd) {
|
||||
index_type target = Find(aStart);
|
||||
if (target == NoIndex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mRanges[target].mEnd >= aEnd;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -1855,28 +1855,29 @@ bool MediaDecoderStateMachine::HasLowUndecodedData()
|
||||
return HasLowUndecodedData(mLowDataThresholdUsecs);
|
||||
}
|
||||
|
||||
bool MediaDecoderStateMachine::HasLowUndecodedData(double aUsecs)
|
||||
bool MediaDecoderStateMachine::HasLowUndecodedData(int64_t aUsecs)
|
||||
{
|
||||
AssertCurrentThreadInMonitor();
|
||||
NS_ASSERTION(mState > DECODER_STATE_DECODING_METADATA,
|
||||
"Must have loaded metadata for GetBuffered() to work");
|
||||
|
||||
bool reliable;
|
||||
double bytesPerSecond = mDecoder->ComputePlaybackRate(&reliable);
|
||||
if (!reliable) {
|
||||
// Default to assuming we have enough
|
||||
return false;
|
||||
}
|
||||
nsRefPtr<dom::TimeRanges> buffered = new dom::TimeRanges();
|
||||
nsresult rv = mReader->GetBuffered(buffered.get());
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
MediaResource* stream = mDecoder->GetResource();
|
||||
int64_t currentPos = stream->Tell();
|
||||
int64_t requiredPos = currentPos + int64_t((aUsecs/1000000.0)*bytesPerSecond);
|
||||
int64_t length = stream->GetLength();
|
||||
if (length >= 0) {
|
||||
requiredPos = std::min(requiredPos, length);
|
||||
int64_t endOfDecodedVideoData = INT64_MAX;
|
||||
if (HasVideo() && !VideoQueue().AtEndOfStream()) {
|
||||
endOfDecodedVideoData = VideoQueue().Peek() ? VideoQueue().Peek()->GetEndTime() : mVideoFrameEndTime;
|
||||
}
|
||||
int64_t endOfDecodedAudioData = INT64_MAX;
|
||||
if (HasAudio() && !AudioQueue().AtEndOfStream()) {
|
||||
endOfDecodedAudioData = AudioQueue().Peek() ? AudioQueue().Peek()->GetEndTime() : GetAudioClock();
|
||||
}
|
||||
int64_t endOfDecodedData = std::min(endOfDecodedVideoData, endOfDecodedAudioData);
|
||||
|
||||
return stream->GetCachedDataEnd(currentPos) < requiredPos;
|
||||
return endOfDecodedData != INT64_MAX &&
|
||||
!buffered->Contains(static_cast<double>(endOfDecodedData) / USECS_PER_S,
|
||||
static_cast<double>(std::min(endOfDecodedData + aUsecs, GetDuration())) / USECS_PER_S);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -427,7 +427,7 @@ protected:
|
||||
bool HasLowUndecodedData();
|
||||
|
||||
// Returns true if we have less than aUsecs of undecoded data available.
|
||||
bool HasLowUndecodedData(double aUsecs);
|
||||
bool HasLowUndecodedData(int64_t aUsecs);
|
||||
|
||||
// Returns the number of unplayed usecs of audio we've got decoded and/or
|
||||
// pushed to the hardware waiting to play. This is how much audio we can
|
||||
|
Loading…
Reference in New Issue
Block a user