Bug 1307022. Part 1 - Use raw pointers to avoid unnecessary ref-counting. draft
authorJW Wang <jwwang@mozilla.com>
Fri, 30 Sep 2016 16:34:54 +0800
changeset 420432 24eeaa9d41ca54d6b03ea9b5289d1cd2b25c095a
parent 420431 976de857f15408cf48079c2b4b3f49a42ac44dc5
child 420433 5ffb641f917a37c3972149dd34162991f54246e8
push id31197
push userjwwang@mozilla.com
push dateTue, 04 Oct 2016 06:29:16 +0000
bugs1307022
milestone52.0a1
Bug 1307022. Part 1 - Use raw pointers to avoid unnecessary ref-counting. MozReview-Commit-ID: 5qLfiTv5o95
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -1010,46 +1010,44 @@ MediaDecoderStateMachine::NeedToDecodeAu
 
   return IsAudioDecoding() &&
          mState != DECODER_STATE_SEEKING &&
          ((!mSentFirstFrameLoadedEvent && AudioQueue().GetSize() == 0) ||
           (!mMinimizePreroll && !HaveEnoughDecodedAudio()));
 }
 
 void
-MediaDecoderStateMachine::OnAudioDecoded(MediaData* aAudioSample)
+MediaDecoderStateMachine::OnAudioDecoded(MediaData* aAudio)
 {
   MOZ_ASSERT(OnTaskQueue());
   MOZ_ASSERT(mState != DECODER_STATE_SEEKING);
-
-  RefPtr<MediaData> audio(aAudioSample);
-  MOZ_ASSERT(audio);
+  MOZ_ASSERT(aAudio);
 
   // audio->GetEndTime() is not always mono-increasing in chained ogg.
-  mDecodedAudioEndTime = std::max(audio->GetEndTime(), mDecodedAudioEndTime);
-
-  SAMPLE_LOG("OnAudioDecoded [%lld,%lld]", audio->mTime, audio->GetEndTime());
+  mDecodedAudioEndTime = std::max(aAudio->GetEndTime(), mDecodedAudioEndTime);
+
+  SAMPLE_LOG("OnAudioDecoded [%lld,%lld]", aAudio->mTime, aAudio->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(audio, MediaData::AUDIO_DATA);
+      Push(aAudio, MediaData::AUDIO_DATA);
       ScheduleStateMachine();
       return;
     }
 
     case DECODER_STATE_DECODING_FIRSTFRAME: {
-      Push(audio, MediaData::AUDIO_DATA);
+      Push(aAudio, MediaData::AUDIO_DATA);
       MaybeFinishDecodeFirstFrame();
       return;
     }
 
     case DECODER_STATE_DECODING: {
-      Push(audio, MediaData::AUDIO_DATA);
+      Push(aAudio, MediaData::AUDIO_DATA);
       MaybeStopPrerolling();
       return;
     }
 
     default: {
       // Ignore other cases.
       return;
     }
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -340,17 +340,17 @@ private:
   bool IsShutdown() const;
 
   // 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* aAudioSample);
+  void OnAudioDecoded(MediaData* aAudio);
   void OnVideoDecoded(MediaData* aVideoSample, 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));