Bug 1265978. Part 2 - add methods to MediaDecoder and MDSM to dump debugging info. r=jya.

MozReview-Commit-ID: Dbc5FT627uL
This commit is contained in:
JW Wang 2016-04-22 14:18:26 +08:00
Родитель 6bfff83925
Коммит 94b009f556
5 изменённых файлов: 49 добавлений и 1 удалений

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

@ -567,7 +567,9 @@ HTMLMediaElement::GetMozDebugReaderData(nsAString& aString)
void
HTMLMediaElement::MozDumpDebugInfo()
{
// Tell mDecoder to dump debugging info.
if (mDecoder) {
mDecoder->DumpDebugInfo();
}
}
already_AddRefed<DOMMediaStream>

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

@ -51,11 +51,15 @@ static const uint64_t ESTIMATED_DURATION_FUZZ_FACTOR_USECS = USECS_PER_S / 2;
// avoid redefined macro in unified build
#undef DECODER_LOG
#undef DUMP_LOG
LazyLogModule gMediaDecoderLog("MediaDecoder");
#define DECODER_LOG(x, ...) \
MOZ_LOG(gMediaDecoderLog, LogLevel::Debug, ("Decoder=%p " x, this, ##__VA_ARGS__))
#define DUMP_LOG(x, ...) \
NS_DebugBreak(NS_DEBUG_WARNING, nsPrintfCString("Decoder=%p " x, this, ##__VA_ARGS__).get(), nullptr, nullptr, -1)
static const char*
ToPlayStateStr(MediaDecoder::PlayState aState)
{
@ -1872,6 +1876,18 @@ MediaDecoder::NextFrameBufferedStatus()
: MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE;
}
void
MediaDecoder::DumpDebugInfo()
{
DUMP_LOG("metadata: channels=%u rate=%u hasAudio=%d hasVideo=%d, "
"state: mPlayState=%s mIsDormant=%d, mShuttingDown=%d",
mInfo->mAudio.mChannels, mInfo->mAudio.mRate, mInfo->HasAudio(), mInfo->HasVideo(),
PlayStateStr(), mIsDormant, mShuttingDown);
if (!mShuttingDown && GetStateMachine()) {
GetStateMachine()->DumpDebugInfo();
}
}
void
MediaDecoder::NotifyAudibleStateChanged()
{

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

@ -499,6 +499,8 @@ private:
// data. Used for debugging purposes.
virtual void GetMozDebugReaderData(nsAString& aString) {}
virtual void DumpDebugInfo();
protected:
virtual ~MediaDecoder();

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

@ -63,6 +63,7 @@ using namespace mozilla::media;
#undef LOG
#undef DECODER_LOG
#undef VERBOSE_LOG
#undef DUMP_LOG
#define LOG(m, l, x, ...) \
MOZ_LOG(m, l, ("Decoder=%p " x, mDecoderID, ##__VA_ARGS__))
@ -79,6 +80,9 @@ using namespace mozilla::media;
#define DECODER_WARN(x, ...) \
DECODER_WARN_HELPER(0, (nsPrintfCString("Decoder=%p " x, mDecoderID, ##__VA_ARGS__).get()))
#define DUMP_LOG(x, ...) \
NS_DebugBreak(NS_DEBUG_WARNING, nsPrintfCString("Decoder=%p " x, mDecoderID, ##__VA_ARGS__).get(), nullptr, nullptr, -1)
// Certain constants get stored as member variables and then adjusted by various
// scale factors on a per-decoder basis. We want to make sure to avoid using these
// constants directly, so we put them in a namespace.
@ -2664,6 +2668,28 @@ uint32_t MediaDecoderStateMachine::GetAmpleVideoFrames() const
: std::max<uint32_t>(sVideoQueueDefaultSize, MIN_VIDEO_QUEUE_SIZE);
}
void
MediaDecoderStateMachine::DumpDebugInfo()
{
MOZ_ASSERT(NS_IsMainThread());
// It is fine to capture a raw pointer here because MediaDecoder only call
// this function before shutdown begins.
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([this] () {
DUMP_LOG(
"GetMediaTime=%lld GetClock=%lld "
"mState=%s mPlayState=%d mDecodingFirstFrame=%d IsPlaying=%d "
"mAudioStatus=%s mVideoStatus=%s mDecodedAudioEndTime=%lld mDecodedVideoEndTime=%lld "
"mIsAudioPrerolling=%d mIsVideoPrerolling=%d",
GetMediaTime(), mMediaSink->IsStarted() ? GetClock() : -1,
gMachineStateStr[mState], mPlayState.Ref(), mDecodingFirstFrame, IsPlaying(),
AudioRequestStatus(), VideoRequestStatus(), mDecodedAudioEndTime, mDecodedVideoEndTime,
mIsAudioPrerolling, mIsVideoPrerolling);
});
OwnerThread()->DispatchStateChange(r.forget());
}
void MediaDecoderStateMachine::AddOutputStream(ProcessedMediaStream* aStream,
bool aFinishWhenEnded)
{

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

@ -156,6 +156,8 @@ public:
DECODER_STATE_ERROR
};
void DumpDebugInfo();
void AddOutputStream(ProcessedMediaStream* aStream, bool aFinishWhenEnded);
// Remove an output stream added with AddOutputStream.
void RemoveOutputStream(MediaStream* aStream);