Bug 1204430. Part 2 - mirror MediaDecoder::mMediaSeekable. r=kinetik.

This commit is contained in:
JW Wang 2015-09-21 13:49:01 +08:00
Родитель c22dac30b8
Коммит 9fd579e930
4 изменённых файлов: 19 добавлений и 8 удалений

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

@ -351,7 +351,6 @@ MediaDecoder::MediaDecoder() :
mDormantSupported(false),
mLogicalPosition(0.0),
mDuration(std::numeric_limits<double>::quiet_NaN()),
mMediaSeekable(true),
mReentrantMonitor("media.decoder"),
mIgnoreProgressData(false),
mInfiniteStream(false),
@ -407,7 +406,9 @@ MediaDecoder::MediaDecoder() :
mPlaybackRateReliable(AbstractThread::MainThread(), true,
"MediaDecoder::mPlaybackRateReliable (Canonical)"),
mDecoderPosition(AbstractThread::MainThread(), 0,
"MediaDecoder::mDecoderPosition (Canonical)")
"MediaDecoder::mDecoderPosition (Canonical)"),
mMediaSeekable(AbstractThread::MainThread(), true,
"MediaDecoder::mMediaSeekable (Canonical)")
{
MOZ_COUNT_CTOR(MediaDecoder);
MOZ_ASSERT(NS_IsMainThread());
@ -1124,8 +1125,8 @@ MediaDecoder::IsTransportSeekable()
bool MediaDecoder::IsMediaSeekable()
{
MOZ_ASSERT(NS_IsMainThread());
NS_ENSURE_TRUE(GetStateMachine(), false);
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
return mMediaSeekable;
}

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

@ -801,9 +801,6 @@ protected:
// Official duration of the media resource as observed by script.
double mDuration;
// True if the media is seekable (i.e. supports random access).
bool mMediaSeekable;
/******
* The following member variables can be accessed from any thread.
******/
@ -1001,6 +998,9 @@ protected:
// back again.
Canonical<int64_t> mDecoderPosition;
// True if the media is seekable (i.e. supports random access).
Canonical<bool> mMediaSeekable;
public:
AbstractCanonical<media::NullableTimeUnit>* CanonicalDurationOrNull() override;
AbstractCanonical<double>* CanonicalVolume() {
@ -1039,6 +1039,9 @@ public:
AbstractCanonical<int64_t>* CanonicalDecoderPosition() {
return &mDecoderPosition;
}
AbstractCanonical<bool>* CanonicalMediaSeekable() {
return &mMediaSeekable;
}
};
} // namespace mozilla

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

@ -249,6 +249,8 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
"MediaDecoderStateMachine::mPlaybackRateReliable (Mirror)"),
mDecoderPosition(mTaskQueue, 0,
"MediaDecoderStateMachine::mDecoderPosition (Mirror)"),
mMediaSeekable(mTaskQueue, true,
"MediaDecoderStateMachine::mMediaSeekable (Mirror)"),
mDuration(mTaskQueue, NullableTimeUnit(),
"MediaDecoderStateMachine::mDuration (Canonical"),
mIsShutdown(mTaskQueue, false,
@ -334,6 +336,7 @@ MediaDecoderStateMachine::InitializationTask()
mPlaybackBytesPerSecond.Connect(mDecoder->CanonicalPlaybackBytesPerSecond());
mPlaybackRateReliable.Connect(mDecoder->CanonicalPlaybackRateReliable());
mDecoderPosition.Connect(mDecoder->CanonicalDecoderPosition());
mMediaSeekable.Connect(mDecoder->CanonicalMediaSeekable());
// Initialize watchers.
mWatchManager.Watch(mBuffered, &MediaDecoderStateMachine::BufferedRangeUpdated);
@ -1483,7 +1486,7 @@ MediaDecoderStateMachine::Seek(SeekTarget aTarget)
// We need to be able to seek both at a transport level and at a media level
// to seek.
if (!mDecoder->IsMediaSeekable()) {
if (!mMediaSeekable) {
DECODER_WARN("Seek() function should not be called on a non-seekable state machine");
return MediaDecoder::SeekPromise::CreateAndReject(/* aIgnored = */ true, __func__);
}
@ -2067,7 +2070,7 @@ MediaDecoderStateMachine::FinishDecodeFirstFrame()
DECODER_LOG("Media duration %lld, "
"transportSeekable=%d, mediaSeekable=%d",
Duration().ToMicroseconds(), mResource->IsTransportSeekable(), mDecoder->IsMediaSeekable());
Duration().ToMicroseconds(), mResource->IsTransportSeekable(), mMediaSeekable.Ref());
if (HasAudio() && !HasVideo() && !mSentFirstFrameLoadedEvent) {
// We're playing audio only. We don't need to worry about slow video
@ -2236,6 +2239,7 @@ MediaDecoderStateMachine::FinishShutdown()
mPlaybackBytesPerSecond.DisconnectIfConnected();
mPlaybackRateReliable.DisconnectIfConnected();
mDecoderPosition.DisconnectIfConnected();
mMediaSeekable.DisconnectIfConnected();
mDuration.DisconnectAll();
mIsShutdown.DisconnectAll();

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

@ -1299,6 +1299,9 @@ private:
// Current decoding position in the stream.
Mirror<int64_t> mDecoderPosition;
// True if the media is seekable (i.e. supports random access).
Mirror<bool> mMediaSeekable;
// Duration of the media. This is guaranteed to be non-null after we finish
// decoding the first frame.
Canonical<media::NullableTimeUnit> mDuration;