mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1091008 - Factor out IsDataCachedToEndOfResource() into a higher-level question and answer it sensibly for MSE. r=cpearce
This commit is contained in:
parent
f94c96cce1
commit
93eb6d095d
@ -679,11 +679,22 @@ void MediaDecoder::QueueMetadata(int64_t aPublishTime,
|
||||
}
|
||||
|
||||
bool
|
||||
MediaDecoder::IsDataCachedToEndOfResource()
|
||||
MediaDecoder::IsExpectingMoreData()
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
|
||||
return (mResource &&
|
||||
mResource->IsDataCachedToEndOfResource(mDecoderPosition));
|
||||
|
||||
// If there's no resource, we're probably just getting set up.
|
||||
if (!mResource) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we've downloaded anything, we're not waiting for anything.
|
||||
if (mResource->IsDataCachedToEndOfResource(mDecoderPosition)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise, we should be getting data unless the stream is suspended.
|
||||
return !mResource->IsSuspended();
|
||||
}
|
||||
|
||||
void MediaDecoder::MetadataLoaded(MediaInfo* aInfo, MetadataTags* aTags)
|
||||
|
@ -798,9 +798,12 @@ public:
|
||||
// Call on the main thread only.
|
||||
void FirstFrameLoaded();
|
||||
|
||||
// Returns true if the resource has been loaded. Acquires the monitor.
|
||||
// Call from any thread.
|
||||
virtual bool IsDataCachedToEndOfResource();
|
||||
// Returns true if the this decoder is expecting any more data to arrive
|
||||
// sometime in the not-too-distant future, either from the network or from
|
||||
// an appendBuffer call on a MediaSource element.
|
||||
//
|
||||
// Acquires the monitor. Call from any thread.
|
||||
virtual bool IsExpectingMoreData();
|
||||
|
||||
// Called when the video has completed playing.
|
||||
// Call on the main thread only.
|
||||
|
@ -2421,9 +2421,8 @@ nsresult MediaDecoderStateMachine::RunStateMachine()
|
||||
if ((isLiveStream || !mDecoder->CanPlayThrough()) &&
|
||||
elapsed < TimeDuration::FromSeconds(mBufferingWait * mPlaybackRate) &&
|
||||
(mQuickBuffering ? HasLowDecodedData(QUICK_BUFFERING_LOW_DATA_USECS)
|
||||
: HasLowUndecodedData(mBufferingWait * USECS_PER_S)) &&
|
||||
!mDecoder->IsDataCachedToEndOfResource() &&
|
||||
!resource->IsSuspended())
|
||||
: HasLowUndecodedData(mBufferingWait * USECS_PER_S)) &&
|
||||
mDecoder->IsExpectingMoreData())
|
||||
{
|
||||
DECODER_LOG("Buffering: wait %ds, timeout in %.3lfs %s",
|
||||
mBufferingWait, mBufferingWait - elapsed.ToSeconds(),
|
||||
@ -2682,12 +2681,10 @@ void MediaDecoderStateMachine::AdvanceFrame()
|
||||
|
||||
// Check to see if we don't have enough data to play up to the next frame.
|
||||
// If we don't, switch to buffering mode.
|
||||
MediaResource* resource = mDecoder->GetResource();
|
||||
if (mState == DECODER_STATE_DECODING &&
|
||||
mDecoder->GetState() == MediaDecoder::PLAY_STATE_PLAYING &&
|
||||
HasLowDecodedData(remainingTime + EXHAUSTED_DATA_MARGIN_USECS) &&
|
||||
!mDecoder->IsDataCachedToEndOfResource() &&
|
||||
!resource->IsSuspended()) {
|
||||
mDecoder->IsExpectingMoreData()) {
|
||||
if (JustExitedQuickBuffering() || HasLowUndecodedData()) {
|
||||
if (currentFrame) {
|
||||
VideoQueue().PushFront(currentFrame.forget());
|
||||
|
@ -164,6 +164,13 @@ MediaSourceDecoder::Ended()
|
||||
mon.NotifyAll();
|
||||
}
|
||||
|
||||
bool
|
||||
MediaSourceDecoder::IsExpectingMoreData()
|
||||
{
|
||||
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
|
||||
return !mReader->IsEnded();
|
||||
}
|
||||
|
||||
void
|
||||
MediaSourceDecoder::SetMediaSourceDuration(double aDuration)
|
||||
{
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
void OnTrackBufferConfigured(TrackBuffer* aTrackBuffer, const MediaInfo& aInfo);
|
||||
|
||||
void Ended();
|
||||
bool IsExpectingMoreData() MOZ_OVERRIDE;
|
||||
|
||||
void SetMediaSourceDuration(double aDuration);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user