Bug 1402681 - part2 : add log.
MozReview-Commit-ID: 8qINxSCKrvg
--- a/dom/media/mediasource/SourceBufferTask.h
+++ b/dom/media/mediasource/SourceBufferTask.h
@@ -27,16 +27,17 @@ public:
Detach
};
typedef Pair<bool, SourceBufferAttributes> AppendBufferResult;
typedef MozPromise<AppendBufferResult, MediaResult, /* IsExclusive = */ true> AppendPromise;
typedef MozPromise<bool, nsresult, /* IsExclusive = */ true> RangeRemovalPromise;
virtual Type GetType() const = 0;
+ virtual const char* GetTypeName() const = 0;
template<typename ReturnType>
ReturnType* As()
{
MOZ_ASSERT(this->GetType() == ReturnType::sType);
return static_cast<ReturnType*>(this);
}
@@ -49,62 +50,68 @@ public:
AppendBufferTask(already_AddRefed<MediaByteBuffer> aData,
const SourceBufferAttributes& aAttributes)
: mBuffer(aData)
, mAttributes(aAttributes)
{}
static const Type sType = Type::AppendBuffer;
Type GetType() const override { return Type::AppendBuffer; }
+ const char* GetTypeName() const override { return "AppendBuffer"; }
RefPtr<MediaByteBuffer> mBuffer;
SourceBufferAttributes mAttributes;
MozPromiseHolder<AppendPromise> mPromise;
};
class AbortTask : public SourceBufferTask {
public:
static const Type sType = Type::Abort;
Type GetType() const override { return Type::Abort; }
+ const char* GetTypeName() const override { return "Abort"; }
};
class ResetTask : public SourceBufferTask {
public:
static const Type sType = Type::Reset;
Type GetType() const override { return Type::Reset; }
+ const char* GetTypeName() const override { return "Reset"; }
};
class RangeRemovalTask : public SourceBufferTask {
public:
explicit RangeRemovalTask(const media::TimeInterval& aRange)
: mRange(aRange)
{}
static const Type sType = Type::RangeRemoval;
Type GetType() const override { return Type::RangeRemoval; }
+ const char* GetTypeName() const override { return "RangeRemoval"; }
media::TimeInterval mRange;
MozPromiseHolder<RangeRemovalPromise> mPromise;
};
class EvictDataTask : public SourceBufferTask {
public:
EvictDataTask(const media::TimeUnit& aPlaybackTime, int64_t aSizetoEvict)
: mPlaybackTime(aPlaybackTime)
, mSizeToEvict(aSizetoEvict)
{}
static const Type sType = Type::EvictData;
Type GetType() const override { return Type::EvictData; }
+ const char* GetTypeName() const override { return "EvictData"; }
media::TimeUnit mPlaybackTime;
int64_t mSizeToEvict;
};
class DetachTask : public SourceBufferTask {
public:
static const Type sType = Type::Detach;
Type GetType() const override { return Type::Detach; }
+ const char* GetTypeName() const override { return "Detach"; }
};
} // end mozilla namespace
#endif
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -146,16 +146,18 @@ void
TrackBuffersManager::QueueTask(SourceBufferTask* aTask)
{
// The source buffer is a wrapped native, it would be unlinked twice and so
// the TrackBuffersManager::Detach() would also be called twice. Since the
// detach task has been done before, we could ignore this task.
if (!GetTaskQueue()) {
MOZ_ASSERT(aTask->GetType() == SourceBufferTask::Type::Detach,
"only detach task could happen here!");
+ MSE_DEBUG("Could not queue the task '%s' without task queue",
+ aTask->GetTypeName());
return;
}
if (!OnTaskQueue()) {
GetTaskQueue()->Dispatch(NewRunnableMethod<RefPtr<SourceBufferTask>>(
"TrackBuffersManager::QueueTask",
this,
&TrackBuffersManager::QueueTask,
@@ -178,16 +180,18 @@ TrackBuffersManager::ProcessTasks()
// current task complete.
return;
}
RefPtr<SourceBufferTask> task = mQueue.Pop();
if (!task) {
// nothing to do.
return;
}
+
+ MSE_DEBUG("Process task '%s'", task->GetTypeName());
switch (task->GetType()) {
case Type::AppendBuffer:
mCurrentTask = task;
if (!mInputBuffer) {
mInputBuffer = task->As<AppendBufferTask>()->mBuffer;
} else if (!mInputBuffer->AppendElements(*task->As<AppendBufferTask>()->mBuffer, fallible)) {
RejectAppend(NS_ERROR_OUT_OF_MEMORY, __func__);
return;