Bug 1307022. Part 3 - Use raw pointers to avoid unnecessary ref-counting. draft
authorJW Wang <jwwang@mozilla.com>
Fri, 30 Sep 2016 16:51:12 +0800
changeset 420434 efefc27e8c9364fa67c6f7acfe31ca1e3f7c311a
parent 420433 5ffb641f917a37c3972149dd34162991f54246e8
child 420435 224fb13bb7bf07afeb7fae473e474cd09b6951ce
push id31197
push userjwwang@mozilla.com
push dateTue, 04 Oct 2016 06:29:16 +0000
bugs1307022
milestone52.0a1
Bug 1307022. Part 3 - Use raw pointers to avoid unnecessary ref-counting. MozReview-Commit-ID: 4PsJjpvWAZW
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1191,47 +1191,45 @@ MediaDecoderStateMachine::MaybeFinishDec
   if (mQueuedSeek.Exists()) {
     InitiateSeek(Move(mQueuedSeek));
   } else {
     SetState(DECODER_STATE_DECODING);
   }
 }
 
 void
-MediaDecoderStateMachine::OnVideoDecoded(MediaData* aVideoSample,
+MediaDecoderStateMachine::OnVideoDecoded(MediaData* aVideo,
                                          TimeStamp aDecodeStartTime)
 {
   MOZ_ASSERT(OnTaskQueue());
   MOZ_ASSERT(mState != DECODER_STATE_SEEKING);
-
-  RefPtr<MediaData> video(aVideoSample);
-  MOZ_ASSERT(video);
+  MOZ_ASSERT(aVideo);
 
   // Handle abnormal or negative timestamps.
-  mDecodedVideoEndTime = std::max(mDecodedVideoEndTime, video->GetEndTime());
-
-  SAMPLE_LOG("OnVideoDecoded [%lld,%lld]", video->mTime, video->GetEndTime());
+  mDecodedVideoEndTime = std::max(mDecodedVideoEndTime, aVideo->GetEndTime());
+
+  SAMPLE_LOG("OnVideoDecoded [%lld,%lld]", aVideo->mTime, aVideo->GetEndTime());
 
   switch (mState) {
     case DECODER_STATE_BUFFERING: {
       // If we're buffering, this may be the sample we need to stop buffering.
       // Save it and schedule the state machine.
-      Push(video, MediaData::VIDEO_DATA);
+      Push(aVideo, MediaData::VIDEO_DATA);
       ScheduleStateMachine();
       return;
     }
 
     case DECODER_STATE_DECODING_FIRSTFRAME: {
-      Push(video, MediaData::VIDEO_DATA);
+      Push(aVideo, MediaData::VIDEO_DATA);
       MaybeFinishDecodeFirstFrame();
       return;
     }
 
     case DECODER_STATE_DECODING: {
-      Push(video, MediaData::VIDEO_DATA);
+      Push(aVideo, MediaData::VIDEO_DATA);
       MaybeStopPrerolling();
 
       // For non async readers, if the requested video sample was slow to
       // arrive, increase the amount of audio we buffer to ensure that we
       // don't run out of audio. This is unnecessary for async readers,
       // since they decode audio and video on different threads so they
       // are unlikely to run out of decoded audio.
       if (mReader->IsAsync()) {
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -341,17 +341,17 @@ private:
 
   // Returns true if we're currently playing. The decoder monitor must
   // be held.
   bool IsPlaying() const;
 
   // TODO: Those callback function may receive demuxed-only data.
   // Need to figure out a suitable API name for this case.
   void OnAudioDecoded(MediaData* aAudio);
-  void OnVideoDecoded(MediaData* aVideoSample, TimeStamp aDecodeStartTime);
+  void OnVideoDecoded(MediaData* aVideo, TimeStamp aDecodeStartTime);
   void OnNotDecoded(MediaData::Type aType, const MediaResult& aError);
 
   // Resets all state related to decoding and playback, emptying all buffers
   // and aborting all pending operations on the decode task queue.
   void Reset(TrackSet aTracks = TrackSet(TrackInfo::kAudioTrack,
                                          TrackInfo::kVideoTrack));
 
 protected: