Backed out changeset 9bd60f359de2 (bug 1767899) for causing build bustages on EventTargetCapability.h.

This commit is contained in:
Marian-Vasile Laza 2022-05-20 04:58:00 +03:00
Родитель 97a8f6862e
Коммит dfc5ffc7fa
2 изменённых файлов: 60 добавлений и 96 удалений

Просмотреть файл

@ -113,8 +113,7 @@ TrackBuffersManager::TrackBuffersManager(MediaSourceDecoder* aParentDecoder,
"media.mediasource.eviction_threshold.audio", 20 * 1024 * 1024)),
mEvictionState(EvictionState::NO_EVICTION_NEEDED),
mMutex("TrackBuffersManager"),
mTaskQueue(aParentDecoder->GetDemuxer()->GetTaskQueue()),
mTaskQueueCapability(Some(EventTargetCapability{mTaskQueue.get()})) {
mTaskQueue(aParentDecoder->GetDemuxer()->GetTaskQueue()) {
MOZ_ASSERT(NS_IsMainThread(), "Must be instanciated on the main thread");
DDLINKCHILD("parser", mParser.get());
}
@ -194,7 +193,7 @@ void TrackBuffersManager::ProcessTasks() {
return;
}
mTaskQueueCapability->AssertOnCurrentThread();
MOZ_ASSERT(OnTaskQueue());
typedef SourceBufferTask::Type Type;
if (mCurrentTask) {
@ -450,7 +449,7 @@ void TrackBuffersManager::Detach() {
}
void TrackBuffersManager::CompleteResetParserState() {
mTaskQueueCapability->AssertOnCurrentThread();
MOZ_ASSERT(OnTaskQueue());
AUTO_PROFILER_LABEL("TrackBuffersManager::CompleteResetParserState",
MEDIA_PLAYBACK);
MSE_DEBUG("");
@ -512,7 +511,7 @@ int64_t TrackBuffersManager::EvictionThreshold() const {
void TrackBuffersManager::DoEvictData(const TimeUnit& aPlaybackTime,
int64_t aSizeToEvict) {
mTaskQueueCapability->AssertOnCurrentThread();
MOZ_ASSERT(OnTaskQueue());
AUTO_PROFILER_LABEL("TrackBuffersManager::DoEvictData", MEDIA_PLAYBACK);
mEvictionState = EvictionState::EVICTION_COMPLETED;
@ -613,7 +612,7 @@ void TrackBuffersManager::DoEvictData(const TimeUnit& aPlaybackTime,
RefPtr<TrackBuffersManager::RangeRemovalPromise>
TrackBuffersManager::CodedFrameRemovalWithPromise(TimeInterval aInterval) {
mTaskQueueCapability->AssertOnCurrentThread();
MOZ_ASSERT(OnTaskQueue());
RefPtr<RangeRemovalTask> task = new RangeRemovalTask(aInterval);
RefPtr<RangeRemovalPromise> p = task->mPromise.Ensure(__func__);
@ -956,7 +955,6 @@ void TrackBuffersManager::SegmentParserLoop() {
->Then(
TaskQueueFromTaskQueue(), __func__,
[self](bool aNeedMoreData) {
self->mTaskQueueCapability->AssertOnCurrentThread();
self->mProcessingRequest.Complete();
if (aNeedMoreData) {
self->NeedMoreData();
@ -965,7 +963,6 @@ void TrackBuffersManager::SegmentParserLoop() {
}
},
[self](const MediaResult& aRejectValue) {
self->mTaskQueueCapability->AssertOnCurrentThread();
self->mProcessingRequest.Complete();
self->RejectAppend(aRejectValue, __func__);
})
@ -1028,7 +1025,7 @@ void TrackBuffersManager::ShutdownDemuxers() {
}
void TrackBuffersManager::CreateDemuxerforMIMEType() {
mTaskQueueCapability->AssertOnCurrentThread();
MOZ_ASSERT(OnTaskQueue());
MSE_DEBUG("mType.OriginalString=%s", mType.OriginalString().get());
ShutdownDemuxers();
@ -1236,7 +1233,7 @@ bool TrackBuffersManager::IsRepeatInitData(
}
void TrackBuffersManager::OnDemuxerInitDone(const MediaResult& aResult) {
mTaskQueueCapability->AssertOnCurrentThread();
MOZ_ASSERT(OnTaskQueue());
MOZ_DIAGNOSTIC_ASSERT(mInputDemuxer, "mInputDemuxer has been destroyed");
AUTO_PROFILER_LABEL("TrackBuffersManager::OnDemuxerInitDone", MEDIA_PLAYBACK);
@ -1524,7 +1521,6 @@ void TrackBuffersManager::OnDemuxerInitDone(const MediaResult& aResult) {
}
void TrackBuffersManager::OnDemuxerInitFailed(const MediaResult& aError) {
mTaskQueueCapability->AssertOnCurrentThread();
MSE_DEBUG("");
MOZ_ASSERT(aError != NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA);
mDemuxerInitRequest.Complete();
@ -1623,7 +1619,7 @@ void TrackBuffersManager::MaybeDispatchEncryptedEvent(
void TrackBuffersManager::OnVideoDemuxCompleted(
RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) {
mTaskQueueCapability->AssertOnCurrentThread();
MOZ_ASSERT(OnTaskQueue());
MSE_DEBUG("%zu video samples demuxed", aSamples->GetSamples().Length());
mVideoTracks.mDemuxRequest.Complete();
mVideoTracks.mQueuedSamples.AppendElements(aSamples->GetSamples());
@ -1647,7 +1643,7 @@ void TrackBuffersManager::DoDemuxAudio() {
void TrackBuffersManager::OnAudioDemuxCompleted(
RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) {
mTaskQueueCapability->AssertOnCurrentThread();
MOZ_ASSERT(OnTaskQueue());
MSE_DEBUG("%zu audio samples demuxed", aSamples->GetSamples().Length());
mAudioTracks.mDemuxRequest.Complete();
mAudioTracks.mQueuedSamples.AppendElements(aSamples->GetSamples());
@ -2675,7 +2671,7 @@ TimeUnit TrackBuffersManager::Seek(TrackInfo::TrackType aTrack,
uint32_t TrackBuffersManager::SkipToNextRandomAccessPoint(
TrackInfo::TrackType aTrack, const TimeUnit& aTimeThreadshold,
const media::TimeUnit& aFuzz, bool& aFound) {
mTaskQueueCapability->AssertOnCurrentThread();
MOZ_ASSERT(OnTaskQueue());
AUTO_PROFILER_LABEL("TrackBuffersManager::SkipToNextRandomAccessPoint",
MEDIA_PLAYBACK);
uint32_t parsed = 0;
@ -2776,7 +2772,7 @@ const MediaRawData* TrackBuffersManager::GetSample(TrackInfo::TrackType aTrack,
already_AddRefed<MediaRawData> TrackBuffersManager::GetSample(
TrackInfo::TrackType aTrack, const TimeUnit& aFuzz, MediaResult& aResult) {
mTaskQueueCapability->AssertOnCurrentThread();
MOZ_ASSERT(OnTaskQueue());
AUTO_PROFILER_LABEL("TrackBuffersManager::GetSample", MEDIA_PLAYBACK);
auto& trackData = GetTracksData(aTrack);
const TrackBuffer& track = GetTrackBuffer(aTrack);
@ -2911,7 +2907,7 @@ uint32_t TrackBuffersManager::Evictable(TrackInfo::TrackType aTrack) const {
TimeUnit TrackBuffersManager::GetNextRandomAccessPoint(
TrackInfo::TrackType aTrack, const TimeUnit& aFuzz) {
mTaskQueueCapability->AssertOnCurrentThread();
MOZ_ASSERT(OnTaskQueue());
// So first determine the current position in the track buffer if necessary.
if (NS_FAILED(SetNextGetSampleIndexIfNeeded(aTrack, aFuzz))) {
@ -2942,7 +2938,6 @@ TimeUnit TrackBuffersManager::GetNextRandomAccessPoint(
nsresult TrackBuffersManager::SetNextGetSampleIndexIfNeeded(
TrackInfo::TrackType aTrack, const TimeUnit& aFuzz) {
MOZ_ASSERT(OnTaskQueue());
auto& trackData = GetTracksData(aTrack);
const TrackBuffer& track = GetTrackBuffer(aTrack);
@ -3002,7 +2997,6 @@ RefPtr<GenericPromise> TrackBuffersManager::RequestDebugInfo(
return RequestDebugInfo(aInfo);
});
}
mTaskQueueCapability->AssertOnCurrentThread();
GetDebugInfo(aInfo);
return GenericPromise::CreateAndResolve(true, __func__);
}
@ -3057,7 +3051,7 @@ void TrackBuffersManager::GetDebugInfo(
void TrackBuffersManager::AddSizeOfResources(
MediaSourceDecoder::ResourceSizes* aSizes) const {
mTaskQueueCapability->AssertOnCurrentThread();
MOZ_ASSERT(OnTaskQueue());
if (mInputBuffer.isSome() && mInputBuffer->Buffer()) {
// mInputBuffer should be the sole owner of the underlying buffer, so this

Просмотреть файл

@ -8,7 +8,6 @@
#define MOZILLA_TRACKBUFFERSMANAGER_H_
#include "mozilla/Atomics.h"
#include "mozilla/EventTargetCapability.h"
#include "mozilla/Maybe.h"
#include "mozilla/Mutex.h"
#include "mozilla/NotNull.h"
@ -153,8 +152,7 @@ class TrackBuffersManager final
const media::TimeUnit& aFuzz,
MediaResult& aResult);
int32_t FindCurrentPosition(TrackInfo::TrackType aTrack,
const media::TimeUnit& aFuzz) const
REQUIRES(mTaskQueueCapability);
const media::TimeUnit& aFuzz) const;
// Will set the next GetSample index if needed. This information is determined
// through the value of mNextSampleTimecode. Return false if the index
@ -162,8 +160,7 @@ class TrackBuffersManager final
// This occurs if either the track buffer doesn't contain the required
// timecode or is empty.
nsresult SetNextGetSampleIndexIfNeeded(TrackInfo::TrackType aTrack,
const media::TimeUnit& aFuzz)
REQUIRES(mTaskQueueCapability);
const media::TimeUnit& aFuzz);
media::TimeUnit GetNextRandomAccessPoint(TrackInfo::TrackType aTrack,
const media::TimeUnit& aFuzz);
@ -183,103 +180,92 @@ class TrackBuffersManager final
// All following functions run on the taskqueue.
RefPtr<AppendPromise> DoAppendData(already_AddRefed<MediaByteBuffer> aData,
const SourceBufferAttributes& aAttributes);
void ScheduleSegmentParserLoop() REQUIRES(mTaskQueueCapability);
void SegmentParserLoop() REQUIRES(mTaskQueueCapability);
void InitializationSegmentReceived() REQUIRES(mTaskQueueCapability);
void ShutdownDemuxers() REQUIRES(mTaskQueueCapability);
void CreateDemuxerforMIMEType() REQUIRES(mTaskQueueCapability);
void ResetDemuxingState() REQUIRES(mTaskQueueCapability);
void NeedMoreData() REQUIRES(mTaskQueueCapability);
void RejectAppend(const MediaResult& aRejectValue, const char* aName)
REQUIRES(mTaskQueueCapability);
void ScheduleSegmentParserLoop();
void SegmentParserLoop();
void InitializationSegmentReceived();
void ShutdownDemuxers();
void CreateDemuxerforMIMEType();
void ResetDemuxingState();
void NeedMoreData();
void RejectAppend(const MediaResult& aRejectValue, const char* aName);
// Will return a promise that will be resolved once all frames of the current
// media segment have been processed.
RefPtr<CodedFrameProcessingPromise> CodedFrameProcessing()
REQUIRES(mTaskQueueCapability);
void CompleteCodedFrameProcessing() REQUIRES(mTaskQueueCapability);
RefPtr<CodedFrameProcessingPromise> CodedFrameProcessing();
void CompleteCodedFrameProcessing();
// Called by ResetParserState.
void CompleteResetParserState() REQUIRES(mTaskQueueCapability);
void CompleteResetParserState();
RefPtr<RangeRemovalPromise> CodedFrameRemovalWithPromise(
media::TimeInterval aInterval) REQUIRES(mTaskQueueCapability);
bool CodedFrameRemoval(media::TimeInterval aInterval)
REQUIRES(mTaskQueueCapability);
media::TimeInterval aInterval);
bool CodedFrameRemoval(media::TimeInterval aInterval);
// Removes all coded frames -- this is not to spec and should be used as a
// last resort to clear buffers only if other methods cannot.
void RemoveAllCodedFrames() REQUIRES(mTaskQueueCapability);
void SetAppendState(SourceBufferAttributes::AppendState aAppendState)
REQUIRES(mTaskQueueCapability);
void RemoveAllCodedFrames();
void SetAppendState(SourceBufferAttributes::AppendState aAppendState);
bool HasVideo() const { return mVideoTracks.mNumTracks > 0; }
bool HasAudio() const { return mAudioTracks.mNumTracks > 0; }
// The input buffer as per
// http://w3c.github.io/media-source/index.html#sourcebuffer-input-buffer
Maybe<MediaSpan> mInputBuffer GUARDED_BY(mTaskQueueCapability);
Maybe<MediaSpan> mInputBuffer;
// Buffer full flag as per
// https://w3c.github.io/media-source/#sourcebuffer-buffer-full-flag. Accessed
// on both the main thread and the task queue.
Atomic<bool> mBufferFull;
bool mFirstInitializationSegmentReceived GUARDED_BY(mTaskQueueCapability);
bool mChangeTypeReceived GUARDED_BY(mTaskQueueCapability);
bool mFirstInitializationSegmentReceived;
bool mChangeTypeReceived;
// Set to true once a new segment is started.
bool mNewMediaSegmentStarted GUARDED_BY(mTaskQueueCapability);
bool mActiveTrack GUARDED_BY(mTaskQueueCapability);
MediaContainerType mType GUARDED_BY(mTaskQueueCapability);
bool mNewMediaSegmentStarted;
bool mActiveTrack;
MediaContainerType mType;
// ContainerParser objects and methods.
// Those are used to parse the incoming input buffer.
// Recreate the ContainerParser and if aReuseInitData is true then
// feed it with the previous init segment found.
void RecreateParser(bool aReuseInitData) REQUIRES(mTaskQueueCapability);
void RecreateParser(bool aReuseInitData);
UniquePtr<ContainerParser> mParser;
// Demuxer objects and methods.
void AppendDataToCurrentInputBuffer(const MediaSpan& aData)
REQUIRES(mTaskQueueCapability);
void AppendDataToCurrentInputBuffer(const MediaSpan& aData);
RefPtr<MediaByteBuffer> mInitData GUARDED_BY(mTaskQueueCapability);
RefPtr<MediaByteBuffer> mInitData;
// Checks if a new set of init data is a repeat of the last set of init data
// received. Because streams may retransmit the same init data (or
// functionally equivalent init data) we do not want to perform costly
// operations each time we receive init data, only when it's actually
// different data.
bool IsRepeatInitData(const MediaInfo& aNewMediaInfo) const
REQUIRES(mTaskQueueCapability);
bool IsRepeatInitData(const MediaInfo& aNewMediaInfo) const;
// Temporary input buffer to handle partial media segment header.
// We store the current input buffer content into it should we need to
// reinitialize the demuxer once we have some samples and a discontinuity is
// detected.
Maybe<MediaSpan> mPendingInputBuffer GUARDED_BY(mTaskQueueCapability);
RefPtr<SourceBufferResource> mCurrentInputBuffer
GUARDED_BY(mTaskQueueCapability);
RefPtr<MediaDataDemuxer> mInputDemuxer GUARDED_BY(mTaskQueueCapability);
Maybe<MediaSpan> mPendingInputBuffer;
RefPtr<SourceBufferResource> mCurrentInputBuffer;
RefPtr<MediaDataDemuxer> mInputDemuxer;
// Length already processed in current media segment.
uint64_t mProcessedInput GUARDED_BY(mTaskQueueCapability);
Maybe<media::TimeUnit> mLastParsedEndTime GUARDED_BY(mTaskQueueCapability);
uint64_t mProcessedInput;
Maybe<media::TimeUnit> mLastParsedEndTime;
void OnDemuxerInitDone(const MediaResult& aResult);
void OnDemuxerInitFailed(const MediaResult& aFailure);
void OnDemuxerResetDone(const MediaResult& aResult)
REQUIRES(mTaskQueueCapability);
void OnDemuxerResetDone(const MediaResult& aResult);
MozPromiseRequestHolder<MediaDataDemuxer::InitPromise> mDemuxerInitRequest;
void OnDemuxFailed(TrackType aTrack, const MediaResult& aError)
REQUIRES(mTaskQueueCapability);
void DoDemuxVideo() REQUIRES(mTaskQueueCapability);
void OnDemuxFailed(TrackType aTrack, const MediaResult& aError);
void DoDemuxVideo();
void OnVideoDemuxCompleted(RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples);
void OnVideoDemuxFailed(const MediaResult& aError) {
mVideoTracks.mDemuxRequest.Complete();
mTaskQueueCapability->AssertOnCurrentThread();
OnDemuxFailed(TrackType::kVideoTrack, aError);
}
void DoDemuxAudio() REQUIRES(mTaskQueueCapability);
void DoDemuxAudio();
void OnAudioDemuxCompleted(RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples);
void OnAudioDemuxFailed(const MediaResult& aError) {
mAudioTracks.mDemuxRequest.Complete();
mTaskQueueCapability->AssertOnCurrentThread();
OnDemuxFailed(TrackType::kAudioTrack, aError);
}
@ -288,11 +274,9 @@ class TrackBuffersManager final
void MaybeDispatchEncryptedEvent(
const nsTArray<RefPtr<MediaRawData>>& aSamples);
void DoEvictData(const media::TimeUnit& aPlaybackTime, int64_t aSizeToEvict)
REQUIRES(mTaskQueueCapability);
void DoEvictData(const media::TimeUnit& aPlaybackTime, int64_t aSizeToEvict);
void GetDebugInfo(dom::TrackBuffersManagerDebugInfo& aInfo) const
REQUIRES(mTaskQueueCapability);
void GetDebugInfo(dom::TrackBuffersManagerDebugInfo& aInfo) const;
struct TrackData {
TrackData() : mNumTracks(0), mNeedRandomAccessPoint(true), mSizeBuffer(0) {}
@ -415,21 +399,16 @@ class TrackBuffersManager final
void AddSizeOfResources(MediaSourceDecoder::ResourceSizes* aSizes) const;
};
void CheckSequenceDiscontinuity(const media::TimeUnit& aPresentationTime)
REQUIRES(mTaskQueueCapability);
void ProcessFrames(TrackBuffer& aSamples, TrackData& aTrackData)
REQUIRES(mTaskQueueCapability);
media::TimeInterval PresentationInterval(const TrackBuffer& aSamples) const
REQUIRES(mTaskQueueCapability);
void CheckSequenceDiscontinuity(const media::TimeUnit& aPresentationTime);
void ProcessFrames(TrackBuffer& aSamples, TrackData& aTrackData);
media::TimeInterval PresentationInterval(const TrackBuffer& aSamples) const;
bool CheckNextInsertionIndex(TrackData& aTrackData,
const media::TimeUnit& aSampleTime)
REQUIRES(mTaskQueueCapability);
const media::TimeUnit& aSampleTime);
void InsertFrames(TrackBuffer& aSamples,
const media::TimeIntervals& aIntervals,
TrackData& aTrackData) REQUIRES(mTaskQueueCapability);
TrackData& aTrackData);
void UpdateHighestTimestamp(TrackData& aTrackData,
const media::TimeUnit& aHighestTime)
REQUIRES(mTaskQueueCapability);
const media::TimeUnit& aHighestTime);
// Remove all frames and their dependencies contained in aIntervals.
// Return the index at which frames were first removed or 0 if no frames
// removed.
@ -507,15 +486,14 @@ class TrackBuffersManager final
void ProcessTasks();
// Set if the TrackBuffersManager is currently processing a task.
// At this stage, this task is always a AppendBufferTask.
RefPtr<SourceBufferTask> mCurrentTask GUARDED_BY(mTaskQueueCapability);
RefPtr<SourceBufferTask> mCurrentTask;
// Current SourceBuffer state for ongoing task.
// Its content is returned to the SourceBuffer once the AppendBufferTask has
// completed.
UniquePtr<SourceBufferAttributes> mSourceBufferAttributes
GUARDED_BY(mTaskQueueCapability);
UniquePtr<SourceBufferAttributes> mSourceBufferAttributes;
// The current sourcebuffer append window. It's content is equivalent to
// mSourceBufferAttributes.mAppendWindowStart/End
media::TimeInterval mAppendWindow GUARDED_BY(mTaskQueueCapability);
media::TimeInterval mAppendWindow;
// Strong references to external objects.
nsMainThreadPtrHandle<MediaSourceDecoder> mParentDecoder;
@ -552,14 +530,6 @@ class TrackBuffersManager final
media::TimeIntervals mAudioBufferedRanges;
// MediaInfo of the first init segment read.
MediaInfo mInfo;
// End mutex protected members.
// EventTargetCapability used to ensure we're running on the task queue
// as expected for various accesses.
// TODO: we could store only this and dispatch to it, rather than also having
// mTaskQueue. However, there's special locking around mTaskQueue, so we keep
// both for now.
Maybe<EventTargetCapability<TaskQueue>> mTaskQueueCapability;
};
} // namespace mozilla