mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1168004: Part1. Ensure buffered range referential starts at 0. r=bholley
This commit is contained in:
parent
5b53ba69e7
commit
2be0adf305
@ -537,12 +537,13 @@ public:
|
||||
}
|
||||
|
||||
// Shift all values by aOffset.
|
||||
void Shift(const T& aOffset)
|
||||
SelfType& Shift(const T& aOffset)
|
||||
{
|
||||
for (auto& interval : mIntervals) {
|
||||
interval.mStart = interval.mStart + aOffset;
|
||||
interval.mEnd = interval.mEnd + aOffset;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void SetFuzz(const T& aFuzz) {
|
||||
|
@ -1277,34 +1277,40 @@ MediaFormatReader::GetBuffered()
|
||||
{
|
||||
media::TimeIntervals videoti;
|
||||
media::TimeIntervals audioti;
|
||||
media::TimeIntervals intervals;
|
||||
|
||||
if (!mInitDone) {
|
||||
return media::TimeIntervals();
|
||||
return intervals;
|
||||
}
|
||||
int64_t startTime;
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
MOZ_ASSERT(mStartTime != -1, "Need to finish metadata decode first");
|
||||
startTime = mStartTime;
|
||||
}
|
||||
if (NS_IsMainThread()) {
|
||||
if (!mCachedTimeRangesStale) {
|
||||
return mCachedTimeRanges;
|
||||
if (mCachedTimeRangesStale) {
|
||||
MOZ_ASSERT(mMainThreadDemuxer);
|
||||
if (!mDataRange.IsEmpty()) {
|
||||
mMainThreadDemuxer->NotifyDataArrived(mDataRange.Length(), mDataRange.mStart);
|
||||
}
|
||||
if (mVideoTrackDemuxer) {
|
||||
videoti = mVideoTrackDemuxer->GetBuffered();
|
||||
}
|
||||
if (mAudioTrackDemuxer) {
|
||||
audioti = mAudioTrackDemuxer->GetBuffered();
|
||||
}
|
||||
if (HasAudio() && HasVideo()) {
|
||||
mCachedTimeRanges = media::Intersection(Move(videoti), Move(audioti));
|
||||
} else if (HasAudio()) {
|
||||
mCachedTimeRanges = Move(audioti);
|
||||
} else if (HasVideo()) {
|
||||
mCachedTimeRanges = Move(videoti);
|
||||
}
|
||||
mDataRange = ByteInterval();
|
||||
mCachedTimeRangesStale = false;
|
||||
}
|
||||
MOZ_ASSERT(mMainThreadDemuxer);
|
||||
if (!mDataRange.IsEmpty()) {
|
||||
mMainThreadDemuxer->NotifyDataArrived(mDataRange.Length(), mDataRange.mStart);
|
||||
}
|
||||
if (mVideoTrackDemuxer) {
|
||||
videoti = mVideoTrackDemuxer->GetBuffered();
|
||||
}
|
||||
if (mAudioTrackDemuxer) {
|
||||
audioti = mAudioTrackDemuxer->GetBuffered();
|
||||
}
|
||||
if (HasAudio() && HasVideo()) {
|
||||
mCachedTimeRanges = Intersection(Move(videoti), Move(audioti));
|
||||
} else if (HasAudio()) {
|
||||
mCachedTimeRanges = Move(audioti);
|
||||
} else if (HasVideo()) {
|
||||
mCachedTimeRanges = Move(videoti);
|
||||
}
|
||||
mDataRange = ByteInterval();
|
||||
mCachedTimeRangesStale = false;
|
||||
return mCachedTimeRanges;
|
||||
intervals = mCachedTimeRanges;
|
||||
} else {
|
||||
if (OnTaskQueue()) {
|
||||
// Ensure we have up to date buffered time range.
|
||||
@ -1323,17 +1329,16 @@ MediaFormatReader::GetBuffered()
|
||||
MonitorAutoLock lock(mAudio.mMonitor);
|
||||
audioti = mAudio.mTimeRanges;
|
||||
}
|
||||
}
|
||||
if (HasAudio() && HasVideo()) {
|
||||
videoti.Intersection(audioti);
|
||||
return videoti;
|
||||
} else if (HasAudio()) {
|
||||
return audioti;
|
||||
} else if (HasVideo()) {
|
||||
return videoti;
|
||||
if (HasAudio() && HasVideo()) {
|
||||
intervals = media::Intersection(Move(videoti), Move(audioti));
|
||||
} else if (HasAudio()) {
|
||||
intervals = Move(audioti);
|
||||
} else if (HasVideo()) {
|
||||
intervals = Move(videoti);
|
||||
}
|
||||
}
|
||||
|
||||
return media::TimeIntervals();
|
||||
return intervals.Shift(media::TimeUnit::FromMicroseconds(-startTime));
|
||||
}
|
||||
|
||||
bool MediaFormatReader::IsDormantNeeded()
|
||||
|
Loading…
Reference in New Issue
Block a user