diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 245be46b4de2..b1390ece876a 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -2805,6 +2805,11 @@ bool MediaDecoderStateMachine::IsPlaying() const return mMediaSink->IsPlaying(); } +void MediaDecoderStateMachine::SetMediaNotSeekable() +{ + mMediaSeekable = false; +} + nsresult MediaDecoderStateMachine::Init(MediaDecoder* aDecoder) { MOZ_ASSERT(NS_IsMainThread()); @@ -2821,11 +2826,8 @@ nsresult MediaDecoderStateMachine::Init(MediaDecoder* aDecoder) mMetadataManager.Connect(mReader->TimedMetadataEvent(), OwnerThread()); - RefPtr self = this; mOnMediaNotSeekable = mReader->OnMediaNotSeekable().Connect( - OwnerThread(), [self] () { - self->mMediaSeekable = false; - }); + OwnerThread(), this, &MediaDecoderStateMachine::SetMediaNotSeekable); mMediaSink = CreateMediaSink(mAudioCaptured); @@ -2838,6 +2840,7 @@ nsresult MediaDecoderStateMachine::Init(MediaDecoder* aDecoder) nsresult rv = mReader->Init(); NS_ENSURE_SUCCESS(rv, rv); + RefPtr self = this; OwnerThread()->Dispatch(NS_NewRunnableFunction([self] () { MOZ_ASSERT(!self->mStateObj); auto s = new DecodeMetadataState(self); diff --git a/dom/media/MediaDecoderStateMachine.h b/dom/media/MediaDecoderStateMachine.h index 46b4d2a1af14..57abc3a2b62a 100644 --- a/dom/media/MediaDecoderStateMachine.h +++ b/dom/media/MediaDecoderStateMachine.h @@ -297,6 +297,9 @@ private: // be held. bool IsPlaying() const; + // Sets mMediaSeekable to false. + void SetMediaNotSeekable(); + // Resets all states related to decoding and aborts all pending requests // to the decoders. void ResetDecode(TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack,