Bug 1366362: P1. Fix style. r?gerald
MozReview-Commit-ID: 3eDT8kY1tCZ
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -237,17 +237,17 @@ public:
virtual RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget);
virtual RefPtr<ShutdownPromise> HandleShutdown();
virtual void HandleVideoSuspendTimeout() = 0;
virtual void HandleResumeVideoDecoding(const TimeUnit& aTarget);
- virtual void HandlePlayStateChanged(MediaDecoder::PlayState aPlayState) {}
+ virtual void HandlePlayStateChanged(MediaDecoder::PlayState aPlayState) { }
virtual nsCString GetDebugInfo() { return nsCString(); }
private:
template <class S, typename R, typename... As>
auto ReturnTypeHelper(R(S::*)(As...)) -> R;
void Crash(const char* aReason, const char* aSite)
@@ -262,17 +262,17 @@ private:
protected:
enum class EventVisibility : int8_t
{
Observable,
Suppressed
};
using Master = MediaDecoderStateMachine;
- explicit StateObject(Master* aPtr) : mMaster(aPtr) {}
+ explicit StateObject(Master* aPtr) : mMaster(aPtr) { }
TaskQueue* OwnerThread() const { return mMaster->mTaskQueue; }
MediaResource* Resource() const { return mMaster->mResource; }
MediaDecoderReaderWrapper* Reader() const { return mMaster->mReader; }
const MediaInfo& Info() const { return mMaster->Info(); }
bool IsExpectingMoreData() const
{
// We are expecting more data if either the resource states so, or if we
// have a waiting promise pending (such as with non-MSE EME).
@@ -364,25 +364,19 @@ public:
OnMetadataRead(Move(aMetadata));
},
[this] (const MediaResult& aError) {
OnMetadataNotRead(aError);
})
->Track(mMetadataRequest);
}
- void Exit() override
- {
- mMetadataRequest.DisconnectIfExists();
- }
-
- State GetState() const override
- {
- return DECODER_STATE_DECODING_METADATA;
- }
+ void Exit() override { mMetadataRequest.DisconnectIfExists(); }
+
+ State GetState() const override { return DECODER_STATE_DECODING_METADATA; }
RefPtr<MediaDecoder::SeekPromise> HandleSeek(SeekTarget aTarget) override
{
MOZ_DIAGNOSTIC_ASSERT(false, "Can't seek while decoding metadata.");
return MediaDecoder::SeekPromise::CreateAndReject(true, __func__);
}
void HandleVideoSuspendTimeout() override
@@ -417,20 +411,17 @@ private:
* DECODING_FIRSTFRAME otherwise.
*/
class MediaDecoderStateMachine::WaitForCDMState
: public MediaDecoderStateMachine::StateObject
{
public:
explicit WaitForCDMState(Master* aPtr) : StateObject(aPtr) { }
- void Enter()
- {
- MOZ_ASSERT(!mMaster->mVideoDecodeSuspended);
- }
+ void Enter() { MOZ_ASSERT(!mMaster->mVideoDecodeSuspended); }
void Exit() override
{
// mPendingSeek is either moved in HandleCDMProxyReady() or should be
// rejected here before transition to SHUTDOWN.
mPendingSeek.RejectIfExists(__func__);
}
@@ -503,65 +494,41 @@ public:
void Exit() override
{
// mPendingSeek is either moved when exiting dormant or
// should be rejected here before transition to SHUTDOWN.
mPendingSeek.RejectIfExists(__func__);
}
- State GetState() const override
- {
- return DECODER_STATE_DORMANT;
- }
+ State GetState() const override { return DECODER_STATE_DORMANT; }
void HandleVideoSuspendTimeout() override
{
// Do nothing since we've released decoders in Enter().
}
void HandleResumeVideoDecoding(const TimeUnit&) override
{
// Do nothing since we won't resume decoding until exiting dormant.
}
void HandlePlayStateChanged(MediaDecoder::PlayState aPlayState) override;
- void HandleAudioDecoded(AudioData*) override
- {
- MaybeReleaseResources();
- }
+ void HandleAudioDecoded(AudioData*) override { MaybeReleaseResources(); }
void HandleVideoDecoded(VideoData*, TimeStamp) override
{
MaybeReleaseResources();
}
- void HandleWaitingForAudio() override
- {
- MaybeReleaseResources();
- }
- void HandleWaitingForVideo() override
- {
- MaybeReleaseResources();
- }
- void HandleAudioCanceled() override
- {
- MaybeReleaseResources();
- }
- void HandleVideoCanceled() override
- {
- MaybeReleaseResources();
- }
- void HandleEndOfAudio() override
- {
- MaybeReleaseResources();
- }
- void HandleEndOfVideo() override
- {
- MaybeReleaseResources();
- }
+ void HandleWaitingForAudio() override { MaybeReleaseResources(); }
+ void HandleWaitingForVideo() override { MaybeReleaseResources(); }
+ void HandleAudioCanceled() override { MaybeReleaseResources(); }
+ void HandleVideoCanceled() override { MaybeReleaseResources(); }
+ void HandleEndOfAudio() override { MaybeReleaseResources(); }
+ void HandleEndOfVideo() override { MaybeReleaseResources(); }
private:
void MaybeReleaseResources()
{
if (!mMaster->mAudioDataRequest.Exists() &&
!mMaster->mVideoDataRequest.Exists()) {
// Release decoders only when they are idle. Otherwise it might cause
// decode error later when resetting decoders during seeking.
@@ -590,20 +557,17 @@ public:
void Exit() override
{
// mPendingSeek is either moved in MaybeFinishDecodeFirstFrame()
// or should be rejected here before transition to SHUTDOWN.
mPendingSeek.RejectIfExists(__func__);
}
- State GetState() const override
- {
- return DECODER_STATE_DECODING_FIRSTFRAME;
- }
+ State GetState() const override { return DECODER_STATE_DECODING_FIRSTFRAME; }
void HandleAudioDecoded(AudioData* aAudio) override
{
mMaster->PushAudio(aAudio);
MaybeFinishDecodeFirstFrame();
}
void HandleVideoDecoded(VideoData* aVideo, TimeStamp aDecodeStart) override
@@ -1061,19 +1025,17 @@ private:
virtual TimeUnit CalculateNewCurrentTime() const = 0;
};
class MediaDecoderStateMachine::AccurateSeekingState
: public MediaDecoderStateMachine::SeekingState
{
public:
- explicit AccurateSeekingState(Master* aPtr) : SeekingState(aPtr)
- {
- }
+ explicit AccurateSeekingState(Master* aPtr) : SeekingState(aPtr) { }
RefPtr<MediaDecoder::SeekPromise> Enter(SeekJob&& aSeekJob,
EventVisibility aVisibility)
{
MOZ_ASSERT(aSeekJob.mTarget->IsAccurate() || aSeekJob.mTarget->IsFast());
mCurrentTimeBeforeSeek = mMaster->GetMediaTime();
return SeekingState::Enter(Move(aSeekJob), aVisibility);
}
@@ -1280,18 +1242,20 @@ private:
RefPtr<AudioData> audio = AudioQueue().PeekFront();
RefPtr<VideoData> video = VideoQueue().PeekFront();
// A situation that both audio and video approaches the end.
if (!audio && !video) {
return seekTime;
}
- const int64_t audioStart = audio ? audio->mTime.ToMicroseconds() : INT64_MAX;
- const int64_t videoStart = video ? video->mTime.ToMicroseconds() : INT64_MAX;
+ const int64_t audioStart =
+ audio ? audio->mTime.ToMicroseconds() : INT64_MAX;
+ const int64_t videoStart =
+ video ? video->mTime.ToMicroseconds() : INT64_MAX;
const int64_t audioGap = std::abs(audioStart - seekTime.ToMicroseconds());
const int64_t videoGap = std::abs(videoStart - seekTime.ToMicroseconds());
return TimeUnit::FromMicroseconds(
audioGap <= videoGap ? audioStart : videoStart);
}
MOZ_ASSERT(false, "AccurateSeekTask doesn't handle other seek types.");
return TimeUnit::Zero();
@@ -1454,32 +1418,35 @@ private:
MOZ_ASSERT(aVideo);
SLOG("DropVideoUpToSeekTarget() frame [%" PRId64 ", %" PRId64 "]",
aVideo->mTime.ToMicroseconds(), aVideo->GetEndTime().ToMicroseconds());
const auto target = mSeekJob.mTarget->GetTime();
// If the frame end time is less than the seek target, we won't want
// to display this frame after the seek, so discard it.
if (target >= aVideo->GetEndTime()) {
- SLOG("DropVideoUpToSeekTarget() pop video frame [%" PRId64 ", %" PRId64 "] target=%" PRId64,
- aVideo->mTime.ToMicroseconds(), aVideo->GetEndTime().ToMicroseconds(),
+ SLOG("DropVideoUpToSeekTarget() pop video frame [%" PRId64 ", %" PRId64
+ "] target=%" PRId64,
+ aVideo->mTime.ToMicroseconds(),
+ aVideo->GetEndTime().ToMicroseconds(),
target.ToMicroseconds());
mFirstVideoFrameAfterSeek = aVideo;
} else {
if (target >= aVideo->mTime &&
aVideo->GetEndTime() >= target) {
// The seek target lies inside this frame's time slice. Adjust the
// frame's start time to match the seek target.
aVideo->UpdateTimestamp(target);
}
mFirstVideoFrameAfterSeek = nullptr;
- SLOG("DropVideoUpToSeekTarget() found video frame [%" PRId64 ", %" PRId64 "] "
- "containing target=%" PRId64,
- aVideo->mTime.ToMicroseconds(), aVideo->GetEndTime().ToMicroseconds(),
+ SLOG("DropVideoUpToSeekTarget() found video frame [%" PRId64 ", %" PRId64
+ "] containing target=%" PRId64,
+ aVideo->mTime.ToMicroseconds(),
+ aVideo->GetEndTime().ToMicroseconds(),
target.ToMicroseconds());
MOZ_ASSERT(VideoQueue().GetSize() == 0,
"Should be the 1st sample after seeking");
mMaster->PushVideo(aVideo);
mDoneVideoSeeking = true;
}
@@ -1530,19 +1497,17 @@ DiscardFrames(MediaQueue<Type>& aQueue,
break;
}
}
class MediaDecoderStateMachine::NextFrameSeekingState
: public MediaDecoderStateMachine::SeekingState
{
public:
- explicit NextFrameSeekingState(Master* aPtr) : SeekingState(aPtr)
- {
- }
+ explicit NextFrameSeekingState(Master* aPtr) : SeekingState(aPtr) { }
RefPtr<MediaDecoder::SeekPromise> Enter(SeekJob&& aSeekJob,
EventVisibility aVisibility)
{
MOZ_ASSERT(aSeekJob.mTarget->IsNextFrame());
mCurrentTime = mMaster->GetMediaTime();
mDuration = mMaster->Duration();
return SeekingState::Enter(Move(aSeekJob), aVisibility);
@@ -1774,20 +1739,17 @@ public:
mMaster->ScheduleStateMachineIn(TimeUnit::FromMicroseconds(USECS_PER_S));
mMaster->UpdateNextFrameStatus(
MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_BUFFERING);
}
void Step() override;
- State GetState() const override
- {
- return DECODER_STATE_BUFFERING;
- }
+ State GetState() const override { return DECODER_STATE_BUFFERING; }
void HandleAudioDecoded(AudioData* aAudio) override
{
// This might be the sample we need to exit buffering.
// Schedule Step() to check it.
mMaster->PushAudio(aAudio);
mMaster->ScheduleStateMachine();
}
@@ -1795,20 +1757,17 @@ public:
void HandleVideoDecoded(VideoData* aVideo, TimeStamp aDecodeStart) override
{
// This might be the sample we need to exit buffering.
// Schedule Step() to check it.
mMaster->PushVideo(aVideo);
mMaster->ScheduleStateMachine();
}
- void HandleAudioCanceled() override
- {
- mMaster->RequestAudioData();
- }
+ void HandleAudioCanceled() override { mMaster->RequestAudioData(); }
void HandleVideoCanceled() override
{
mMaster->RequestVideoData(false, media::TimeUnit());
}
void HandleWaitingForAudio() override
{
--- a/dom/media/SeekJob.h
+++ b/dom/media/SeekJob.h
@@ -9,17 +9,18 @@
#include "mozilla/MozPromise.h"
#include "MediaDecoder.h"
#include "MediaDecoderReader.h"
#include "SeekTarget.h"
namespace mozilla {
-struct SeekJob {
+struct SeekJob
+{
SeekJob() = default;
SeekJob(SeekJob&& aOther) = default;
SeekJob& operator=(SeekJob&& aOther) = default;
~SeekJob();
bool Exists() const;
void Resolve(const char* aCallSite);
void RejectIfExists(const char* aCallSite);
--- a/dom/media/SeekTarget.h
+++ b/dom/media/SeekTarget.h
@@ -6,93 +6,81 @@
#ifndef SEEK_TARGET_H
#define SEEK_TARGET_H
#include "TimeUnits.h"
namespace mozilla {
-enum class MediaDecoderEventVisibility : int8_t {
+enum class MediaDecoderEventVisibility : int8_t
+{
Observable,
Suppressed
};
// Stores the seek target; the time to seek to, and whether an Accurate,
// "Fast" (nearest keyframe), or "Video Only" (no audio seek) seek was
// requested.
-struct SeekTarget {
- enum Type {
+struct SeekTarget
+{
+ enum Type
+ {
Invalid,
PrevSyncPoint,
Accurate,
NextFrame,
};
SeekTarget()
: mTime(media::TimeUnit::Invalid())
, mType(SeekTarget::Invalid)
, mVideoOnly(false)
{
}
- SeekTarget(int64_t aTimeUsecs,
- Type aType,
- bool aVideoOnly = false)
+ SeekTarget(int64_t aTimeUsecs, Type aType, bool aVideoOnly = false)
: mTime(media::TimeUnit::FromMicroseconds(aTimeUsecs))
, mType(aType)
, mVideoOnly(aVideoOnly)
{
}
- SeekTarget(const media::TimeUnit& aTime,
- Type aType,
- bool aVideoOnly = false)
+ SeekTarget(const media::TimeUnit& aTime, Type aType, bool aVideoOnly = false)
: mTime(aTime)
, mType(aType)
, mVideoOnly(aVideoOnly)
{
}
SeekTarget(const SeekTarget& aOther)
: mTime(aOther.mTime)
, mType(aOther.mType)
, mVideoOnly(aOther.mVideoOnly)
{
}
- bool IsValid() const {
- return mType != SeekTarget::Invalid;
- }
- void Reset() {
+ bool IsValid() const { return mType != SeekTarget::Invalid; }
+ void Reset()
+ {
mTime = media::TimeUnit::Invalid();
mType = SeekTarget::Invalid;
mVideoOnly = false;
}
- media::TimeUnit GetTime() const {
+ media::TimeUnit GetTime() const
+ {
NS_ASSERTION(mTime.IsValid(), "Invalid SeekTarget");
return mTime;
}
- void SetTime(const media::TimeUnit& aTime) {
+ void SetTime(const media::TimeUnit& aTime)
+ {
NS_ASSERTION(aTime.IsValid(), "Invalid SeekTarget destination");
mTime = aTime;
}
- void SetType(Type aType) {
- mType = aType;
- }
- void SetVideoOnly(bool aVideoOnly) {
- mVideoOnly = aVideoOnly;
- }
- bool IsFast() const {
- return mType == SeekTarget::Type::PrevSyncPoint;
- }
- bool IsAccurate() const {
- return mType == SeekTarget::Type::Accurate;
- }
- bool IsNextFrame() const {
- return mType == SeekTarget::Type::NextFrame;
- }
- bool IsVideoOnly() const {
- return mVideoOnly;
- }
+ void SetType(Type aType) { mType = aType; }
+ void SetVideoOnly(bool aVideoOnly) { mVideoOnly = aVideoOnly; }
+ bool IsFast() const { return mType == SeekTarget::Type::PrevSyncPoint; }
+ bool IsAccurate() const { return mType == SeekTarget::Type::Accurate; }
+ bool IsNextFrame() const { return mType == SeekTarget::Type::NextFrame; }
+ bool IsVideoOnly() const { return mVideoOnly; }
private:
// Seek target time.
media::TimeUnit mTime;
// Whether we should seek "Fast", or "Accurate".
// "Fast" seeks to the seek point preceding mTime, whereas
// "Accurate" seeks as close as possible to mTime.
Type mType;