Bug 1163227: Part6. Always notify MediaSourceReader of new data on its own task queue. r=mattwoodrow

This commit is contained in:
Jean-Yves Avenard 2015-05-25 15:09:16 +10:00
parent 2b44f4a3e5
commit 04ba19f488
2 changed files with 18 additions and 7 deletions

View File

@ -241,7 +241,7 @@ TrackBuffer::AppendData(MediaLargeByteBuffer* aData, int64_t aTimestampOffset)
// Tell our reader that we have more data to ensure that playback starts if
// required when data is appended.
mParentDecoder->GetReader()->MaybeNotifyHaveData();
NotifyTimeRangesChanged();
mInitializationPromise.Resolve(gotMedia, __func__);
return p;
@ -263,11 +263,20 @@ TrackBuffer::AppendDataToCurrentResource(MediaLargeByteBuffer* aData, uint32_t a
mCurrentDecoder->NotifyDataArrived(reinterpret_cast<const char*>(aData->Elements()),
aData->Length(), appendOffset);
mParentDecoder->NotifyBytesDownloaded();
mParentDecoder->NotifyTimeRangesChanged();
NotifyTimeRangesChanged();
return true;
}
void
TrackBuffer::NotifyTimeRangesChanged()
{
RefPtr<nsIRunnable> task =
NS_NewRunnableMethod(mParentDecoder->GetReader(),
&MediaSourceReader::NotifyTimeRangesChanged);
mParentDecoder->GetReader()->GetTaskQueue()->Dispatch(task.forget());
}
class DecoderSorter
{
public:
@ -433,7 +442,7 @@ TrackBuffer::EvictData(double aPlaybackTime,
}
if (evicted) {
mParentDecoder->NotifyTimeRangesChanged();
NotifyTimeRangesChanged();
}
return evicted;
@ -501,7 +510,7 @@ TrackBuffer::EvictBefore(double aTime)
mInitializedDecoders[i]->GetReader()->NotifyDataRemoved();
}
}
mParentDecoder->NotifyTimeRangesChanged();
NotifyTimeRangesChanged();
}
media::TimeIntervals
@ -797,7 +806,7 @@ TrackBuffer::CompleteInitializeDecoder(SourceBufferDecoder* aDecoder)
// Tell our reader that we have more data to ensure that playback starts if
// required when data is appended.
mParentDecoder->GetReader()->MaybeNotifyHaveData();
NotifyTimeRangesChanged();
MSE_DEBUG("Reader %p activated",
aDecoder->GetReader());
@ -839,7 +848,7 @@ TrackBuffer::RegisterDecoder(SourceBufferDecoder* aDecoder)
return false;
}
mInitializedDecoders.AppendElement(aDecoder);
mParentDecoder->NotifyTimeRangesChanged();
NotifyTimeRangesChanged();
return true;
}
@ -1115,7 +1124,7 @@ TrackBuffer::RangeRemoval(media::TimeUnit aStart,
RemoveEmptyDecoders(decoders);
mParentDecoder->NotifyTimeRangesChanged();
NotifyTimeRangesChanged();
return true;
}

View File

@ -129,6 +129,8 @@ private:
// data is appended to the current decoder's SourceBufferResource.
bool AppendDataToCurrentResource(MediaLargeByteBuffer* aData,
uint32_t aDuration /* microseconds */);
// Queue on the parent's decoder task queue a call to NotifyTimeRangesChanged.
void NotifyTimeRangesChanged();
// Queue execution of InitializeDecoder on mTaskQueue.
bool QueueInitializeDecoder(SourceBufferDecoder* aDecoder);