mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1129732: Part3. Assume buffered range starting close enough to 0 to be 0. r=mattwoodrow
This commit is contained in:
parent
22f6bc4805
commit
25805626b7
@ -39,6 +39,9 @@ extern PRLogModuleInfo* GetMediaSourceAPILog();
|
||||
// prevent evicting the current playback point.
|
||||
#define MSE_EVICT_THRESHOLD_TIME 2.0
|
||||
|
||||
// Time in microsecond under which a timestamp will be considered to be 0.
|
||||
#define FUZZ_TIMESTAMP_OFFSET 100000
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
TrackBuffer::TrackBuffer(MediaSourceDecoder* aParentDecoder, const nsACString& aType)
|
||||
@ -46,6 +49,7 @@ TrackBuffer::TrackBuffer(MediaSourceDecoder* aParentDecoder, const nsACString& a
|
||||
, mType(aType)
|
||||
, mLastStartTimestamp(0)
|
||||
, mLastTimestampOffset(0)
|
||||
, mAdjustedTimestamp(0)
|
||||
, mShutdown(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(TrackBuffer);
|
||||
@ -185,7 +189,8 @@ TrackBuffer::AppendData(LargeDataBuffer* aData, int64_t aTimestampOffset)
|
||||
if (newInitData) {
|
||||
if (!gotInit) {
|
||||
// We need a new decoder, but we can't initialize it yet.
|
||||
nsRefPtr<SourceBufferDecoder> decoder = NewDecoder(aTimestampOffset);
|
||||
nsRefPtr<SourceBufferDecoder> decoder =
|
||||
NewDecoder(aTimestampOffset - mAdjustedTimestamp);
|
||||
// The new decoder is stored in mDecoders/mCurrentDecoder, so we
|
||||
// don't need to do anything with 'decoder'. It's only a placeholder.
|
||||
if (!decoder) {
|
||||
@ -193,7 +198,7 @@ TrackBuffer::AppendData(LargeDataBuffer* aData, int64_t aTimestampOffset)
|
||||
return p;
|
||||
}
|
||||
} else {
|
||||
if (!decoders.NewDecoder(aTimestampOffset)) {
|
||||
if (!decoders.NewDecoder(aTimestampOffset - mAdjustedTimestamp)) {
|
||||
mInitializationPromise.Reject(NS_ERROR_FAILURE, __func__);
|
||||
return p;
|
||||
}
|
||||
@ -218,7 +223,8 @@ TrackBuffer::AppendData(LargeDataBuffer* aData, int64_t aTimestampOffset)
|
||||
// This data is earlier in the timeline than data we have already
|
||||
// processed or not continuous, so we must create a new decoder
|
||||
// to handle the decoding.
|
||||
if (!hadCompleteInitData || !decoders.NewDecoder(aTimestampOffset)) {
|
||||
if (!hadCompleteInitData ||
|
||||
!decoders.NewDecoder(aTimestampOffset - mAdjustedTimestamp)) {
|
||||
mInitializationPromise.Reject(NS_ERROR_FAILURE, __func__);
|
||||
return p;
|
||||
}
|
||||
@ -234,6 +240,12 @@ TrackBuffer::AppendData(LargeDataBuffer* aData, int64_t aTimestampOffset)
|
||||
mLastEndTimestamp.emplace(end);
|
||||
}
|
||||
|
||||
if (gotMedia && start > 0 &&
|
||||
(start < FUZZ_TIMESTAMP_OFFSET || start < mAdjustedTimestamp)) {
|
||||
AdjustDecodersTimestampOffset(mAdjustedTimestamp - start);
|
||||
mAdjustedTimestamp = start;
|
||||
}
|
||||
|
||||
if (!AppendDataToCurrentResource(aData, end - start)) {
|
||||
mInitializationPromise.Reject(NS_ERROR_FAILURE, __func__);
|
||||
return p;
|
||||
@ -913,4 +925,13 @@ TrackBuffer::RangeRemoval(int64_t aStart, int64_t aEnd)
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
TrackBuffer::AdjustDecodersTimestampOffset(int32_t aOffset)
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(mParentDecoder->GetReentrantMonitor());
|
||||
for (uint32_t i = 0; i < mDecoders.Length(); i++) {
|
||||
mDecoders[i]->SetTimestampOffset(mDecoders[i]->GetTimestampOffset() + aOffset);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -190,9 +190,11 @@ private:
|
||||
// AppendData. Accessed on the main thread only.
|
||||
int64_t mLastStartTimestamp;
|
||||
Maybe<int64_t> mLastEndTimestamp;
|
||||
void AdjustDecodersTimestampOffset(int32_t aOffset);
|
||||
|
||||
// The timestamp offset used by our current decoder, in microseconds.
|
||||
int64_t mLastTimestampOffset;
|
||||
int64_t mAdjustedTimestamp;
|
||||
|
||||
// Set when the first decoder used by this TrackBuffer is initialized.
|
||||
// Protected by mParentDecoder's monitor.
|
||||
|
Loading…
Reference in New Issue
Block a user