Bug 1235612 - part4 : modify check audible method. draft
authorAlastor Wu <alwu@mozilla.com>
Tue, 03 May 2016 17:59:38 +0800
changeset 362840 be9b7ee55e9394bdf7817eb9a2ee5e077f2a0922
parent 362839 5e4eedcaa8ea286f5730e18f778ed3ac502fd1da
child 362841 fd0acc5b5ba0494b7e97f5f30bc79c49f55040a8
push id17043
push useralwu@mozilla.com
push dateTue, 03 May 2016 10:00:34 +0000
bugs1235612
milestone49.0a1
Bug 1235612 - part4 : modify check audible method. MozReview-Commit-ID: FvCrbdkNSll
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -117,21 +117,16 @@ static const int32_t LOW_VIDEO_THRESHOLD
 static const int AUDIO_DURATION_USECS = 40000;
 
 // If we increase our "low audio threshold" (see LOW_AUDIO_USECS above), we
 // use this as a factor in all our calculations. Increasing this will cause
 // us to be more likely to increase our low audio threshold, and to
 // increase it by more.
 static const int THRESHOLD_FACTOR = 2;
 
-// When the continuous silent data is over this threshold, means the a/v does
-// not produce any sound. This time is decided by UX suggestion, see
-// https://bugzilla.mozilla.org/show_bug.cgi?id=1235612#c18
-static const uint32_t SILENT_DATA_THRESHOLD_USECS = 10000000;
-
 namespace detail {
 
 // If we have less than this much undecoded data available, we'll consider
 // ourselves to be running low on undecoded data. We determine how much
 // undecoded data we have remaining using the reader's GetBuffered()
 // implementation.
 static const int64_t LOW_DATA_THRESHOLD_USECS = 5000000;
 
@@ -242,17 +237,16 @@ MediaDecoderStateMachine::MediaDecoderSt
   mDecodeThreadWaiting(false),
   mDecodingFirstFrame(true),
   mSentLoadedMetadataEvent(false),
   mSentFirstFrameLoadedEvent(false),
   mSentPlaybackEndedEvent(false),
   mOutputStreamManager(new OutputStreamManager()),
   mResource(aDecoder->GetResource()),
   mAudioOffloading(false),
-  mSilentDataDuration(0),
   mBuffered(mTaskQueue, TimeIntervals(),
             "MediaDecoderStateMachine::mBuffered (Mirror)"),
   mEstimatedDuration(mTaskQueue, NullableTimeUnit(),
                     "MediaDecoderStateMachine::mEstimatedDuration (Mirror)"),
   mExplicitDuration(mTaskQueue, Maybe<double>(),
                     "MediaDecoderStateMachine::mExplicitDuration (Mirror)"),
   mPlayState(mTaskQueue, MediaDecoder::PLAY_STATE_LOADING,
              "MediaDecoderStateMachine::mPlayState (Mirror)"),
@@ -626,23 +620,18 @@ MediaDecoderStateMachine::CheckIsAudible
 {
   MOZ_ASSERT(OnTaskQueue());
   MOZ_ASSERT(aSample->mType == MediaData::AUDIO_DATA);
 
   const AudioData* data = aSample->As<AudioData>();
   bool isAudible = data->IsAudible();
   if (isAudible && !mIsAudioDataAudible) {
     mIsAudioDataAudible = true;
-    mSilentDataDuration = 0;
-  } else if (isAudible && mIsAudioDataAudible) {
-    mSilentDataDuration += data->mDuration;
-    if (mSilentDataDuration > SILENT_DATA_THRESHOLD_USECS) {
-      mIsAudioDataAudible = false;
-      mSilentDataDuration = 0;
-    }
+  } else if (!isAudible && mIsAudioDataAudible) {
+    mIsAudioDataAudible = false;
   }
 }
 
 void
 MediaDecoderStateMachine::OnAudioPopped(const RefPtr<MediaData>& aSample)
 {
   MOZ_ASSERT(OnTaskQueue());
 
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -949,19 +949,16 @@ private:
 
   MediaEventProducer<MediaEventType> mOnPlaybackEvent;
   MediaEventProducer<MediaDecoderEventVisibility> mOnSeekingStart;
 
   // True if audio is offloading.
   // Playback will not start when audio is offloading.
   bool mAudioOffloading;
 
-  // Duration of the continuous silent data.
-  uint32_t mSilentDataDuration;
-
 #ifdef MOZ_EME
   void OnCDMProxyReady(RefPtr<CDMProxy> aProxy);
   void OnCDMProxyNotReady();
   RefPtr<CDMProxy> mCDMProxy;
   MozPromiseRequestHolder<MediaDecoder::CDMProxyPromise> mCDMProxyPromise;
 #endif
 
 private: