Bug 1675409 - Migrated MediaSampleMarkerPayload to Markers 2.0 API - r=gregtatum

Differential Revision: https://phabricator.services.mozilla.com/D96043
This commit is contained in:
Gerald Squelart 2020-11-18 21:49:52 +00:00
Родитель fea07678c1
Коммит c3d6e979a5
7 изменённых файлов: 32 добавлений и 47 удалений

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

@ -15,6 +15,7 @@
#include "mozilla/Logging.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/NotNull.h"
#include "mozilla/ProfilerMarkerTypes.h"
#include "mozilla/SharedThreadPool.h"
#include "mozilla/Sprintf.h"
#include "mozilla/StaticPrefs_media.h"
@ -42,12 +43,8 @@
# define MDSM_ERROR_MARKER(tag, error, markerTime) \
PROFILER_ADD_MARKER_WITH_PAYLOAD(tag, MEDIA_PLAYBACK, TextMarkerPayload, \
(error, markerTime))
# define MDSM_SAMPLE_MARKER(tag, startTime, endTime) \
PROFILER_ADD_MARKER_WITH_PAYLOAD( \
tag, MEDIA_PLAYBACK, MediaSampleMarkerPayload, (startTime, endTime))
#else
# define MDSM_ERROR_MARKER(tag, error, markerTime)
# define MDSM_SAMPLE_MARKER(tag, startTime, endTime)
#endif
namespace mozilla {
@ -2859,8 +2856,9 @@ void MediaDecoderStateMachine::PushAudio(AudioData* aSample) {
MOZ_ASSERT(OnTaskQueue());
MOZ_ASSERT(aSample);
AudioQueue().Push(aSample);
MDSM_SAMPLE_MARKER("MDSM::PushAudio", aSample->mTime.ToMicroseconds(),
aSample->GetEndTime().ToMicroseconds());
PROFILER_MARKER("MDSM::PushAudio", MEDIA_PLAYBACK, {}, MediaSampleMarker,
aSample->mTime.ToMicroseconds(),
aSample->GetEndTime().ToMicroseconds());
}
void MediaDecoderStateMachine::PushVideo(VideoData* aSample) {
@ -2868,8 +2866,9 @@ void MediaDecoderStateMachine::PushVideo(VideoData* aSample) {
MOZ_ASSERT(aSample);
aSample->mFrameID = ++mCurrentFrameID;
VideoQueue().Push(aSample);
MDSM_SAMPLE_MARKER("MDSM::PushVideo", aSample->mTime.ToMicroseconds(),
aSample->GetEndTime().ToMicroseconds());
PROFILER_MARKER("MDSM::PushVideo", MEDIA_PLAYBACK, {}, MediaSampleMarker,
aSample->mTime.ToMicroseconds(),
aSample->GetEndTime().ToMicroseconds());
}
void MediaDecoderStateMachine::OnAudioPopped(const RefPtr<AudioData>& aSample) {

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

@ -12,28 +12,11 @@
#include "mozilla/CheckedInt.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/ProfilerMarkerTypes.h"
#include "mozilla/StaticPrefs_media.h"
#include "mozilla/StaticPrefs_dom.h"
#include "nsPrintfCString.h"
#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
# define PROFILER_AUDIO_MARKER(tag, sample) \
do { \
uint64_t startTime = (sample)->mTime.ToMicroseconds(); \
uint64_t endTime = (sample)->GetEndTime().ToMicroseconds(); \
auto profilerTag = (tag); \
mOwnerThread->Dispatch(NS_NewRunnableFunction( \
"AudioSink:AddMarker", [profilerTag, startTime, endTime] { \
PROFILER_ADD_MARKER_WITH_PAYLOAD(profilerTag, MEDIA_PLAYBACK, \
MediaSampleMarkerPayload, \
(startTime, endTime)); \
})); \
} while (0)
#else
# define PROFILER_AUDIO_MARKER(tag, sample)
#endif
namespace mozilla {
extern LazyLogModule gMediaDecoderLog;
@ -271,7 +254,16 @@ UniquePtr<AudioStream::Chunk> AudioSink::PopFrames(uint32_t aFrames) {
SINK_LOG_V("playing audio at time=%" PRId64 " offset=%u length=%u",
mCurrentData->mTime.ToMicroseconds(),
mCurrentData->Frames() - mCursor->Available(), framesToPop);
PROFILER_AUDIO_MARKER("PlayAudio", mCurrentData);
#ifdef MOZ_GECKO_PROFILER
mOwnerThread->Dispatch(NS_NewRunnableFunction(
"AudioSink:AddMarker",
[startTime = mCurrentData->mTime.ToMicroseconds(),
endTime = mCurrentData->GetEndTime().ToMicroseconds()] {
PROFILER_MARKER("PlayAudio", MEDIA_PLAYBACK, {}, MediaSampleMarker,
startTime, endTime);
}));
#endif // MOZ_GECKO_PROFILER
UniquePtr<AudioStream::Chunk> chunk =
MakeUnique<Chunk>(mCurrentData, framesToPop, mCursor->Ptr());

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

@ -16,6 +16,7 @@
#include "VideoUtils.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/ProfilerMarkerTypes.h"
#include "mozilla/StaticPrefs_browser.h"
#include "mozilla/StaticPrefs_media.h"
@ -29,15 +30,6 @@ extern mozilla::LazyLogModule gMediaDecoderLog;
#define VSINK_LOG_V(x, ...) \
MOZ_LOG(gMediaDecoderLog, LogLevel::Verbose, (FMT(x, ##__VA_ARGS__)))
#ifdef MOZ_GECKO_PROFILER
# include "ProfilerMarkerPayload.h"
# define VSINK_ADD_PROFILER_MARKER(tag, startTime, endTime) \
PROFILER_ADD_MARKER_WITH_PAYLOAD( \
tag, MEDIA_PLAYBACK, MediaSampleMarkerPayload, (startTime, endTime))
#else
# define VSINK_ADD_PROFILER_MARKER(tag, startTime, endTime)
#endif
namespace mozilla {
using namespace mozilla::layers;
@ -463,8 +455,9 @@ void VideoSink::RenderVideoFrames(int32_t aMaxFrames, int64_t aClockTime,
frame->mTime.ToMicroseconds(), frame->mFrameID,
VideoQueue().GetSize());
if (!wasSent) {
VSINK_ADD_PROFILER_MARKER("PlayVideo", frame->mTime.ToMicroseconds(),
frame->GetEndTime().ToMicroseconds());
PROFILER_MARKER("PlayVideo", MEDIA_PLAYBACK, {}, MediaSampleMarker,
frame->mTime.ToMicroseconds(),
frame->GetEndTime().ToMicroseconds());
}
}
@ -503,8 +496,9 @@ void VideoSink::UpdateRenderedVideoFrames() {
VSINK_LOG_V("discarding video frame mTime=%" PRId64
" clock_time=%" PRId64,
frame->mTime.ToMicroseconds(), clockTime.ToMicroseconds());
VSINK_ADD_PROFILER_MARKER("DiscardVideo", frame->mTime.ToMicroseconds(),
frame->GetEndTime().ToMicroseconds());
PROFILER_MARKER("DiscardVideo", MEDIA_PLAYBACK, {}, MediaSampleMarker,
frame->mTime.ToMicroseconds(),
frame->GetEndTime().ToMicroseconds());
}
}

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

@ -111,7 +111,7 @@ struct UserTimingMeasure {
}
};
struct MediaSample {
struct MediaSampleMarker {
static constexpr Span<const char> MarkerTypeName() {
return MakeStringSpan("MediaSample");
}

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

@ -3454,7 +3454,7 @@ void TestProfiler() {
MOZ_RELEASE_ASSERT(baseprofiler::AddMarker(
"media sample", mozilla::baseprofiler::category::OTHER, {},
mozilla::baseprofiler::markers::MediaSample{}, 123, 456));
mozilla::baseprofiler::markers::MediaSampleMarker{}, 123, 456));
printf("Sleep 1s...\n");
{
@ -4034,7 +4034,7 @@ void TestPredefinedMarkers() {
MOZ_RELEASE_ASSERT(mozilla::baseprofiler::AddMarkerToBuffer(
buffer, std::string_view("media"), mozilla::baseprofiler::category::OTHER,
{}, mozilla::baseprofiler::markers::MediaSample{}, 123, 456));
{}, mozilla::baseprofiler::markers::MediaSampleMarker{}, 123, 456));
# ifdef DEBUG
buffer.Dump();

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

@ -37,7 +37,7 @@ namespace geckoprofiler::markers {
using Tracing = mozilla::baseprofiler::markers::Tracing;
using UserTimingMark = mozilla::baseprofiler::markers::UserTimingMark;
using UserTimingMeasure = mozilla::baseprofiler::markers::UserTimingMeasure;
using MediaSample = mozilla::baseprofiler::markers::MediaSample;
using MediaSampleMarker = mozilla::baseprofiler::markers::MediaSampleMarker;
using ContentBuildMarker = mozilla::baseprofiler::markers::ContentBuildMarker;
struct ScreenshotPayload {

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

@ -953,9 +953,9 @@ TEST(GeckoProfiler, Markers)
{}, geckoprofiler::markers::Text{},
"Text text"));
MOZ_RELEASE_ASSERT(
profiler_add_marker("MediaSample", geckoprofiler::category::OTHER, {},
geckoprofiler::markers::MediaSample{}, 123, 456));
MOZ_RELEASE_ASSERT(profiler_add_marker(
"MediaSample", geckoprofiler::category::OTHER, {},
geckoprofiler::markers::MediaSampleMarker{}, 123, 456));
SpliceableChunkedJSONWriter w;
w.Start();