Bug 1139256 - remove the assertion in AudioStream::GetPositionInFramesUnlocked(). See bug 1139256 comment 4 for the detail. r=kinetik.
authorJW Wang <jwwang@mozilla.com>
Mon, 02 Nov 2015 21:26:12 +0800
changeset 306763 7811d9b3e7db2d7a8c09e460c49c3a96684fc540
parent 306762 ad57ca8421315256984e7e1eaad3e205beb17460
child 306764 8a5d34242ce6adfc1c32495423ce3f1be14f082b
push id1040
push userraliiev@mozilla.com
push dateMon, 29 Feb 2016 17:11:22 +0000
treeherdermozilla-release@8c3167321162 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1139256
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1139256 - remove the assertion in AudioStream::GetPositionInFramesUnlocked(). See bug 1139256 comment 4 for the detail. r=kinetik.
dom/media/AudioStream.cpp
dom/media/AudioStream.h
dom/media/mediasink/DecodedAudioDataSink.cpp
--- a/dom/media/AudioStream.cpp
+++ b/dom/media/AudioStream.cpp
@@ -125,17 +125,16 @@ AudioStream::AudioStream()
   , mChannels(0)
   , mOutChannels(0)
   , mWritten(0)
   , mAudioClock(this)
   , mTimeStretcher(nullptr)
   , mDumpFile(nullptr)
   , mBytesPerFrame(0)
   , mState(INITIALIZED)
-  , mLastGoodPosition(0)
   , mIsMonoAudioEnabled(gfxPrefs::MonoAudio())
 {
 }
 
 AudioStream::~AudioStream()
 {
   LOG(("AudioStream: delete %p, state %d", this, mState));
   MOZ_ASSERT(mState == SHUTDOWN && !mCubebStream,
@@ -617,22 +616,17 @@ AudioStream::GetPositionInFramesUnlocked
   uint64_t position = 0;
   {
     MonitorAutoUnlock mon(mMonitor);
     if (cubeb_stream_get_position(mCubebStream.get(), &position) != CUBEB_OK) {
       return -1;
     }
   }
 
-  MOZ_ASSERT(position >= mLastGoodPosition, "cubeb position shouldn't go backward");
-  // This error handling/recovery keeps us in good shape in release build.
-  if (position >= mLastGoodPosition) {
-    mLastGoodPosition = position;
-  }
-  return std::min<uint64_t>(mLastGoodPosition, INT64_MAX);
+  return std::min<uint64_t>(position, INT64_MAX);
 }
 
 bool
 AudioStream::IsPaused()
 {
   MonitorAutoLock mon(mMonitor);
   return mState == STOPPED;
 }
--- a/dom/media/AudioStream.h
+++ b/dom/media/AudioStream.h
@@ -317,18 +317,15 @@ private:
                  // completion.
     DRAINED,     // StateCallback has indicated that the drain is complete.
     ERRORED,     // Stream disabled due to an internal error.
     SHUTDOWN     // Shutdown has been called
   };
 
   StreamState mState;
   bool mIsFirst;
-  // The last good position returned by cubeb_stream_get_position(). Used to
-  // check if the cubeb position is going backward.
-  uint64_t mLastGoodPosition;
   // Get this value from the preferece, if true, we would downmix the stereo.
   bool mIsMonoAudioEnabled;
 };
 
 } // namespace mozilla
 
 #endif
--- a/dom/media/mediasink/DecodedAudioDataSink.cpp
+++ b/dom/media/mediasink/DecodedAudioDataSink.cpp
@@ -138,18 +138,22 @@ DecodedAudioDataSink::Init()
 int64_t
 DecodedAudioDataSink::GetPosition()
 {
   ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
 
   int64_t pos;
   if (mAudioStream &&
       (pos = mAudioStream->GetPosition()) >= 0) {
+    NS_ASSERTION(pos >= mLastGoodPosition,
+                 "AudioStream position shouldn't go backward");
     // Update the last good position when we got a good one.
-    mLastGoodPosition = pos;
+    if (pos >= mLastGoodPosition) {
+      mLastGoodPosition = pos;
+    }
   }
 
   return mStartTime + mLastGoodPosition;
 }
 
 bool
 DecodedAudioDataSink::HasUnplayedFrames()
 {