Bug 1235612 - part4 : modify check audible method. draft
authorAlastor Wu <alwu@mozilla.com>
Mon, 14 Mar 2016 17:48:54 +0800
changeset 339895 cf92b1f1927523c2ac434ab0d0a3c2e681ba24cd
parent 339894 c8e49685f2622ae67dc3234b9007f5928b9ab23b
child 516068 1a108f47f2f586d9ecfd859f336d4ea7a86959bc
push id12820
push useralwu@mozilla.com
push dateMon, 14 Mar 2016 09:55:06 +0000
bugs1235612
milestone47.0a1
Bug 1235612 - part4 : modify check audible method. MozReview-Commit-ID: EwzitxxTaeT
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -111,21 +111,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;
 
@@ -236,17 +231,16 @@ MediaDecoderStateMachine::MediaDecoderSt
   mCorruptFrames(60),
   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)"),
@@ -725,23 +719,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
@@ -1191,19 +1191,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: