mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 05:11:03 +00:00
import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1175768 - Remove bogus check. r=jya (6d1b387f4) - Bug 1175768 - Make the logic in MDSM::NotifyDataArrived apply to mObservedDuration. r=jya (90dcae693) - Bug 1175768 - Dispatch UpdateEstimatedMediaDuration. r=jya (f003b4646) - Bug 1175768 - Dispatch NotifyDataArrived and remove the aBuffer argument. r=jya (e6eaf8eb1) - Bug 1175768 - Misc changes to Intervals/TimeUnit. r=jya (786da5ba2) - Bug 1174220 - Part 2: Use MediaByteBuffer instead of MediaLargeByteBuffer. r=jya (59fe3c482) - Bug 1175768 - Use mirroring for buffered ranges. r=jya (5100aba5e) - Bug 1175768 - Throttle NotifyDataArrived. r=jya (4bb13775b) - Bug 1178680 - Remove MediaDecoder::Observe as we have MediaShutdownManager. r=cpearce. (ba9b728ea) - Bug 1178437 - Do the dormant-enabled tracking on the main thread. r=jww,r=jya (b0287df66)
This commit is contained in:
@@ -187,6 +187,7 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
|
||||
mDelayedScheduler(this),
|
||||
mState(DECODER_STATE_DECODING_NONE, "MediaDecoderStateMachine::mState"),
|
||||
mPlayDuration(0),
|
||||
mBuffered(mTaskQueue, TimeIntervals(), "MediaDecoderStateMachine::mBuffered (Mirror)"),
|
||||
mDuration(mTaskQueue, NullableTimeUnit(), "MediaDecoderStateMachine::mDuration (Canonical"),
|
||||
mEstimatedDuration(mTaskQueue, NullableTimeUnit(),
|
||||
"MediaDecoderStateMachine::mEstimatedDuration (Mirror)"),
|
||||
@@ -296,6 +297,7 @@ MediaDecoderStateMachine::InitializationTask()
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
|
||||
// Connect mirrors.
|
||||
mBuffered.Connect(mReader->CanonicalBuffered());
|
||||
mEstimatedDuration.Connect(mDecoder->CanonicalEstimatedDuration());
|
||||
mExplicitDuration.Connect(mDecoder->CanonicalExplicitDuration());
|
||||
mPlayState.Connect(mDecoder->CanonicalPlayState());
|
||||
@@ -306,6 +308,7 @@ MediaDecoderStateMachine::InitializationTask()
|
||||
mPreservesPitch.Connect(mDecoder->CanonicalPreservesPitch());
|
||||
|
||||
// Initialize watchers.
|
||||
mWatchManager.Watch(mBuffered, &MediaDecoderStateMachine::BufferedRangeUpdated);
|
||||
mWatchManager.Watch(mState, &MediaDecoderStateMachine::UpdateNextFrameStatus);
|
||||
mWatchManager.Watch(mAudioCompleted, &MediaDecoderStateMachine::UpdateNextFrameStatus);
|
||||
mWatchManager.Watch(mVolume, &MediaDecoderStateMachine::VolumeChanged);
|
||||
@@ -1414,11 +1417,6 @@ void MediaDecoderStateMachine::RecomputeDuration()
|
||||
mDuration = Some(duration);
|
||||
}
|
||||
|
||||
bool MediaDecoderStateMachine::IsDormantNeeded()
|
||||
{
|
||||
return mReader->IsDormantNeeded();
|
||||
}
|
||||
|
||||
void MediaDecoderStateMachine::SetDormant(bool aDormant)
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
@@ -1617,33 +1615,20 @@ void MediaDecoderStateMachine::LogicallySeekingChanged()
|
||||
ScheduleStateMachine();
|
||||
}
|
||||
|
||||
void MediaDecoderStateMachine::NotifyDataArrived(const char* aBuffer,
|
||||
uint32_t aLength,
|
||||
int64_t aOffset)
|
||||
void MediaDecoderStateMachine::BufferedRangeUpdated()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
|
||||
mReader->NotifyDataArrived(aBuffer, aLength, aOffset);
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
|
||||
// While playing an unseekable stream of unknown duration, mDuration is
|
||||
// updated (in AdvanceFrame()) as we play. But if data is being downloaded
|
||||
// faster than played, mDuration won't reflect the end of playable data
|
||||
// While playing an unseekable stream of unknown duration, mObservedDuration
|
||||
// is updated (in AdvanceFrame()) as we play. But if data is being downloaded
|
||||
// faster than played, mObserved won't reflect the end of playable data
|
||||
// since we haven't played the frame at the end of buffered data. So update
|
||||
// mDuration here as new data is downloaded to prevent such a lag.
|
||||
//
|
||||
// Make sure to only do this if we have a start time, otherwise the reader
|
||||
// doesn't know how to compute GetBuffered.
|
||||
if (!mDecoder->IsInfinite() || !HaveStartTime())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
media::TimeIntervals buffered{mDecoder->GetBuffered()};
|
||||
if (!buffered.IsInvalid()) {
|
||||
// mObservedDuration here as new data is downloaded to prevent such a lag.
|
||||
if (!mBuffered.Ref().IsInvalid()) {
|
||||
bool exists;
|
||||
media::TimeUnit end{buffered.GetEnd(&exists)};
|
||||
media::TimeUnit end{mBuffered.Ref().GetEnd(&exists)};
|
||||
if (exists) {
|
||||
ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
|
||||
mDuration = Some(std::max<TimeUnit>(Duration(), end));
|
||||
mObservedDuration = std::max(mObservedDuration.Ref(), end);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2038,17 +2023,16 @@ bool MediaDecoderStateMachine::HasLowUndecodedData(int64_t aUsecs)
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
AssertCurrentThreadInMonitor();
|
||||
NS_ASSERTION(mState > DECODER_STATE_DECODING_FIRSTFRAME,
|
||||
"Must have loaded first frame for GetBuffered() to work");
|
||||
"Must have loaded first frame for mBuffered to be valid");
|
||||
|
||||
// If we don't have a duration, GetBuffered is probably not going to produce
|
||||
// If we don't have a duration, mBuffered is probably not going to have
|
||||
// a useful buffered range. Return false here so that we don't get stuck in
|
||||
// buffering mode for live streams.
|
||||
if (Duration().IsInfinite()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
media::TimeIntervals buffered{mReader->GetBuffered()};
|
||||
if (buffered.IsInvalid()) {
|
||||
if (mBuffered.Ref().IsInvalid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2070,7 +2054,7 @@ bool MediaDecoderStateMachine::HasLowUndecodedData(int64_t aUsecs)
|
||||
}
|
||||
media::TimeInterval interval(media::TimeUnit::FromMicroseconds(endOfDecodedData),
|
||||
media::TimeUnit::FromMicroseconds(std::min(endOfDecodedData + aUsecs, Duration().ToMicroseconds())));
|
||||
return endOfDecodedData != INT64_MAX && !buffered.Contains(interval);
|
||||
return endOfDecodedData != INT64_MAX && !mBuffered.Ref().Contains(interval);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -2122,8 +2106,7 @@ MediaDecoderStateMachine::OnMetadataRead(MetadataHolder* aMetadata)
|
||||
mStartTimeRendezvous->AwaitStartTime()->Then(TaskQueue(), __func__,
|
||||
[self] () -> void {
|
||||
NS_ENSURE_TRUE_VOID(!self->IsShutdown());
|
||||
ReentrantMonitorAutoEnter mon(self->mDecoder->GetReentrantMonitor());
|
||||
self->mReader->SetStartTime(self->StartTime());
|
||||
self->mReader->DispatchSetStartTime(self->StartTime());
|
||||
},
|
||||
[] () -> void { NS_WARNING("Setting start time on reader failed"); }
|
||||
);
|
||||
@@ -2462,6 +2445,7 @@ MediaDecoderStateMachine::FinishShutdown()
|
||||
VideoQueue().ClearListeners();
|
||||
|
||||
// Disconnect canonicals and mirrors before shutting down our task queue.
|
||||
mBuffered.DisconnectIfConnected();
|
||||
mEstimatedDuration.DisconnectIfConnected();
|
||||
mExplicitDuration.DisconnectIfConnected();
|
||||
mPlayState.DisconnectIfConnected();
|
||||
|
||||
Reference in New Issue
Block a user