зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1331862. Part 1 - extract code to functions for reuse. r=kaku
MozReview-Commit-ID: 9QNTaBxGUFq --HG-- extra : rebase_source : 98e95c60cbd66a5df4571644e4a6415f5bdbc371 extra : intermediate-source : 9dcd71ff0f89beda838f09865dfaa7f96983e430 extra : source : b0cf54f37556f520e45a001dcfa681e4a612a927
This commit is contained in:
Родитель
6a796d5276
Коммит
da6c0492b0
|
@ -1728,15 +1728,21 @@ MediaDecoder::NextFrameBufferedStatus()
|
|||
: MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE;
|
||||
}
|
||||
|
||||
nsCString
|
||||
MediaDecoder::GetDebugInfo()
|
||||
{
|
||||
return nsPrintfCString(
|
||||
"channels=%u rate=%u hasAudio=%d hasVideo=%d mPlayState=%s mdsm=%p",
|
||||
mInfo ? mInfo->mAudio.mChannels : 0, mInfo ? mInfo->mAudio.mRate : 0,
|
||||
mInfo ? mInfo->HasAudio() : 0, mInfo ? mInfo->HasVideo() : 0,
|
||||
PlayStateStr(), GetStateMachine());
|
||||
}
|
||||
|
||||
void
|
||||
MediaDecoder::DumpDebugInfo()
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
|
||||
DUMP_LOG("metadata: channels=%u rate=%u hasAudio=%d hasVideo=%d, "
|
||||
"state: mPlayState=%s mdsm=%p",
|
||||
mInfo ? mInfo->mAudio.mChannels : 0, mInfo ? mInfo->mAudio.mRate : 0,
|
||||
mInfo ? mInfo->HasAudio() : 0, mInfo ? mInfo->HasVideo() : 0,
|
||||
PlayStateStr(), GetStateMachine());
|
||||
DUMP_LOG("%s", GetDebugInfo().get());
|
||||
|
||||
nsAutoCString str;
|
||||
GetMozDebugReaderData(str);
|
||||
|
|
|
@ -544,6 +544,8 @@ protected:
|
|||
static const int DEFAULT_NEXT_FRAME_AVAILABLE_BUFFERED = 250000;
|
||||
|
||||
private:
|
||||
nsCString GetDebugInfo();
|
||||
|
||||
// Called when the metadata from the media file has been loaded by the
|
||||
// state machine. Call on the main thread only.
|
||||
void MetadataLoaded(nsAutoPtr<MediaInfo> aInfo,
|
||||
|
|
|
@ -71,7 +71,6 @@ using namespace mozilla::media;
|
|||
#undef SFMT
|
||||
#undef SLOG
|
||||
#undef SWARN
|
||||
#undef SDUMP
|
||||
|
||||
#define FMT(x, ...) "Decoder=%p " x, mDecoderID, ##__VA_ARGS__
|
||||
#define DECODER_LOG(x, ...) MOZ_LOG(gMediaDecoderLog, LogLevel::Debug, (FMT(x, ##__VA_ARGS__)))
|
||||
|
@ -84,7 +83,6 @@ using namespace mozilla::media;
|
|||
#define SFMT(x, ...) "Decoder=%p state=%s " x, mMaster->mDecoderID, ToStateStr(GetState()), ##__VA_ARGS__
|
||||
#define SLOG(x, ...) MOZ_LOG(gMediaDecoderLog, LogLevel::Debug, (SFMT(x, ##__VA_ARGS__)))
|
||||
#define SWARN(x, ...) NS_WARNING(nsPrintfCString(SFMT(x, ##__VA_ARGS__)).get())
|
||||
#define SDUMP(x, ...) NS_DebugBreak(NS_DEBUG_WARNING, nsPrintfCString(SFMT(x, ##__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
|
||||
|
@ -245,7 +243,7 @@ public:
|
|||
|
||||
virtual void HandlePlayStateChanged(MediaDecoder::PlayState aPlayState) {}
|
||||
|
||||
virtual void DumpDebugInfo() {}
|
||||
virtual nsCString GetDebugInfo() { return nsCString(); }
|
||||
|
||||
private:
|
||||
template <class S, typename R, typename... As>
|
||||
|
@ -744,9 +742,9 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void DumpDebugInfo() override
|
||||
nsCString GetDebugInfo() override
|
||||
{
|
||||
SDUMP("mIsPrerolling=%d", mIsPrerolling);
|
||||
return nsPrintfCString("mIsPrerolling=%d", mIsPrerolling);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -3649,6 +3647,23 @@ uint32_t MediaDecoderStateMachine::GetAmpleVideoFrames() const
|
|||
: std::max<uint32_t>(sVideoQueueDefaultSize, MIN_VIDEO_QUEUE_SIZE);
|
||||
}
|
||||
|
||||
nsCString
|
||||
MediaDecoderStateMachine::GetDebugInfo()
|
||||
{
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
return nsPrintfCString(
|
||||
"GetMediaTime=%lld GetClock=%lld mMediaSink=%p "
|
||||
"state=%s mPlayState=%d mSentFirstFrameLoadedEvent=%d IsPlaying=%d "
|
||||
"mAudioStatus=%s mVideoStatus=%s mDecodedAudioEndTime=%lld mDecodedVideoEndTime=%lld "
|
||||
"mAudioCompleted=%d mVideoCompleted=%d ",
|
||||
GetMediaTime(), mMediaSink->IsStarted() ? GetClock() : -1, mMediaSink.get(),
|
||||
ToStateStr(), mPlayState.Ref(), mSentFirstFrameLoadedEvent, IsPlaying(),
|
||||
AudioRequestStatus(), VideoRequestStatus(), mDecodedAudioEndTime, mDecodedVideoEndTime,
|
||||
mAudioCompleted, mVideoCompleted)
|
||||
+ mStateObj->GetDebugInfo() + nsCString("\n")
|
||||
+ mMediaSink->GetDebugInfo();
|
||||
}
|
||||
|
||||
void
|
||||
MediaDecoderStateMachine::DumpDebugInfo()
|
||||
{
|
||||
|
@ -3657,17 +3672,7 @@ MediaDecoderStateMachine::DumpDebugInfo()
|
|||
// It is fine to capture a raw pointer here because MediaDecoder only call
|
||||
// this function before shutdown begins.
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction([this] () {
|
||||
mMediaSink->DumpDebugInfo();
|
||||
mStateObj->DumpDebugInfo();
|
||||
DUMP_LOG(
|
||||
"GetMediaTime=%lld GetClock=%lld mMediaSink=%p "
|
||||
"state=%s mPlayState=%d mSentFirstFrameLoadedEvent=%d IsPlaying=%d "
|
||||
"mAudioStatus=%s mVideoStatus=%s mDecodedAudioEndTime=%lld mDecodedVideoEndTime=%lld "
|
||||
"mAudioCompleted=%d mVideoCompleted=%d",
|
||||
GetMediaTime(), mMediaSink->IsStarted() ? GetClock() : -1, mMediaSink.get(),
|
||||
ToStateStr(), mPlayState.Ref(), mSentFirstFrameLoadedEvent, IsPlaying(),
|
||||
AudioRequestStatus(), VideoRequestStatus(), mDecodedAudioEndTime, mDecodedVideoEndTime,
|
||||
mAudioCompleted, mVideoCompleted);
|
||||
DUMP_LOG("%s", GetDebugInfo().get());
|
||||
});
|
||||
|
||||
// Since the task is run asynchronously, it is possible other tasks get first
|
||||
|
|
|
@ -239,6 +239,8 @@ private:
|
|||
static const char* ToStr(NextFrameStatus aStatus);
|
||||
const char* ToStateStr();
|
||||
|
||||
nsCString GetDebugInfo();
|
||||
|
||||
// Functions used by assertions to ensure we're calling things
|
||||
// on the appropriate threads.
|
||||
bool OnTaskQueue() const;
|
||||
|
|
|
@ -21,9 +21,6 @@
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
#undef DUMP_LOG
|
||||
#define DUMP_LOG(x, ...) NS_DebugBreak(NS_DEBUG_WARNING, nsPrintfCString(x, ##__VA_ARGS__).get(), nullptr, nullptr, -1)
|
||||
|
||||
/*
|
||||
* A container class to make it easier to pass the playback info all the
|
||||
* way to DecodedStreamGraphListener from DecodedStream.
|
||||
|
@ -130,7 +127,7 @@ public:
|
|||
void SetPlaying(bool aPlaying);
|
||||
MediaEventSource<int64_t>& OnOutput();
|
||||
void Forget();
|
||||
void DumpDebugInfo();
|
||||
nsCString GetDebugInfo();
|
||||
|
||||
/* The following group of fields are protected by the decoder's monitor
|
||||
* and can be read or written on any thread.
|
||||
|
@ -220,10 +217,10 @@ DecodedStreamData::Forget()
|
|||
mListener->Forget();
|
||||
}
|
||||
|
||||
void
|
||||
DecodedStreamData::DumpDebugInfo()
|
||||
nsCString
|
||||
DecodedStreamData::GetDebugInfo()
|
||||
{
|
||||
DUMP_LOG(
|
||||
return nsPrintfCString(
|
||||
"DecodedStreamData=%p mPlaying=%d mAudioFramesWritten=%lld "
|
||||
"mNextAudioTime=%lld mNextVideoTime=%lld mHaveSentFinish=%d "
|
||||
"mHaveSentFinishAudio=%d mHaveSentFinishVideo=%d",
|
||||
|
@ -765,16 +762,14 @@ DecodedStream::DisconnectListener()
|
|||
mVideoFinishListener.Disconnect();
|
||||
}
|
||||
|
||||
void
|
||||
DecodedStream::DumpDebugInfo()
|
||||
nsCString
|
||||
DecodedStream::GetDebugInfo()
|
||||
{
|
||||
AssertOwnerThread();
|
||||
DUMP_LOG(
|
||||
return nsPrintfCString(
|
||||
"DecodedStream=%p mStartTime=%lld mLastOutputTime=%lld mPlaying=%d mData=%p",
|
||||
this, mStartTime.valueOr(-1), mLastOutputTime, mPlaying, mData.get());
|
||||
if (mData) {
|
||||
mData->DumpDebugInfo();
|
||||
}
|
||||
this, mStartTime.valueOr(-1), mLastOutputTime, mPlaying, mData.get())
|
||||
+ (mData ? nsCString("\n") + mData->GetDebugInfo() : nsCString());
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
bool IsStarted() const override;
|
||||
bool IsPlaying() const override;
|
||||
|
||||
void DumpDebugInfo() override;
|
||||
nsCString GetDebugInfo() override;
|
||||
|
||||
protected:
|
||||
virtual ~DecodedStream();
|
||||
|
|
|
@ -119,9 +119,9 @@ public:
|
|||
// Must be called after playback stopped.
|
||||
virtual void Shutdown() {}
|
||||
|
||||
// Dump debugging information to the logs.
|
||||
// Return a string containing debugging information.
|
||||
// Can be called in any phase.
|
||||
virtual void DumpDebugInfo() {}
|
||||
virtual nsCString GetDebugInfo() { return nsCString(); }
|
||||
|
||||
protected:
|
||||
virtual ~MediaSink() {}
|
||||
|
|
|
@ -13,12 +13,10 @@ namespace mozilla {
|
|||
extern LazyLogModule gMediaDecoderLog;
|
||||
|
||||
#undef FMT
|
||||
#undef DUMP_LOG
|
||||
|
||||
#define FMT(x, ...) "VideoSink=%p " x, this, ##__VA_ARGS__
|
||||
#define VSINK_LOG(x, ...) MOZ_LOG(gMediaDecoderLog, LogLevel::Debug, (FMT(x, ##__VA_ARGS__)))
|
||||
#define VSINK_LOG_V(x, ...) MOZ_LOG(gMediaDecoderLog, LogLevel::Verbose, (FMT(x, ##__VA_ARGS__)))
|
||||
#define DUMP_LOG(x, ...) NS_DebugBreak(NS_DEBUG_WARNING, nsPrintfCString(FMT(x, ##__VA_ARGS__)).get(), nullptr, nullptr, -1)
|
||||
|
||||
using namespace mozilla::layers;
|
||||
|
||||
|
@ -473,17 +471,17 @@ VideoSink::MaybeResolveEndPromise()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
VideoSink::DumpDebugInfo()
|
||||
nsCString
|
||||
VideoSink::GetDebugInfo()
|
||||
{
|
||||
AssertOwnerThread();
|
||||
DUMP_LOG(
|
||||
return nsPrintfCString(
|
||||
"IsStarted=%d IsPlaying=%d, VideoQueue: finished=%d size=%d, "
|
||||
"mVideoFrameEndTime=%lld mHasVideo=%d mVideoSinkEndRequest.Exists()=%d "
|
||||
"mEndPromiseHolder.IsEmpty()=%d",
|
||||
"mEndPromiseHolder.IsEmpty()=%d\n",
|
||||
IsStarted(), IsPlaying(), VideoQueue().IsFinished(), VideoQueue().GetSize(),
|
||||
mVideoFrameEndTime, mHasVideo, mVideoSinkEndRequest.Exists(), mEndPromiseHolder.IsEmpty());
|
||||
mAudioSink->DumpDebugInfo();
|
||||
mVideoFrameEndTime, mHasVideo, mVideoSinkEndRequest.Exists(), mEndPromiseHolder.IsEmpty())
|
||||
+ mAudioSink->GetDebugInfo();
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
|
||||
void Shutdown() override;
|
||||
|
||||
void DumpDebugInfo() override;
|
||||
nsCString GetDebugInfo() override;
|
||||
|
||||
private:
|
||||
virtual ~VideoSink();
|
||||
|
|
Загрузка…
Ссылка в новой задаче