Bug 1305353. Part 2 - remove DecodedStreamData::GetPosition() and its friends. r=pehrsons
authorJW Wang <jwwang@mozilla.com>
Mon, 26 Sep 2016 15:12:20 +0800
changeset 315811 1929112d6a82f5d950abc63f289570baade1db26
parent 315810 a3ac424edcd3bb4a6ea319692e941f5cefbdd8ef
child 315812 8305ce9fcda4d74ecc4dfab1dfd13129e3fea629
push id20634
push usercbook@mozilla.com
push dateFri, 30 Sep 2016 10:10:13 +0000
treeherderfx-team@afe79b010d13 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspehrsons
bugs1305353
milestone52.0a1
Bug 1305353. Part 2 - remove DecodedStreamData::GetPosition() and its friends. r=pehrsons MozReview-Commit-ID: FJvBDO0x6b0
dom/media/mediasink/DecodedStream.cpp
--- a/dom/media/mediasink/DecodedStream.cpp
+++ b/dom/media/mediasink/DecodedStream.cpp
@@ -31,28 +31,27 @@ struct PlaybackInfoInit {
 };
 
 class DecodedStreamGraphListener : public MediaStreamListener {
 public:
   DecodedStreamGraphListener(MediaStream* aStream,
                              MozPromiseHolder<GenericPromise>&& aPromise)
     : mMutex("DecodedStreamGraphListener::mMutex")
     , mStream(aStream)
-    , mLastOutputTime(aStream->StreamTimeToMicroseconds(aStream->GetCurrentTime()))
   {
     mFinishPromise = Move(aPromise);
   }
 
   void NotifyOutput(MediaStreamGraph* aGraph, GraphTime aCurrentTime) override
   {
     MutexAutoLock lock(mMutex);
     if (mStream) {
-      mLastOutputTime = mStream->StreamTimeToMicroseconds(
-          mStream->GraphTimeToStreamTime(aCurrentTime));
-      mOnOutput.Notify(mLastOutputTime);
+      int64_t t = mStream->StreamTimeToMicroseconds(
+        mStream->GraphTimeToStreamTime(aCurrentTime));
+      mOnOutput.Notify(t);
     }
   }
 
   void NotifyEvent(MediaStreamGraph* aGraph, MediaStreamGraphEvent event) override
   {
     if (event == MediaStreamGraphEvent::EVENT_FINISHED) {
       nsCOMPtr<nsIRunnable> event =
         NewRunnableMethod(this, &DecodedStreamGraphListener::DoNotifyFinished);
@@ -60,22 +59,16 @@ public:
     }
   }
 
   void DoNotifyFinished()
   {
     mFinishPromise.ResolveIfExists(true, __func__);
   }
 
-  int64_t GetLastOutputTime()
-  {
-    MutexAutoLock lock(mMutex);
-    return mLastOutputTime;
-  }
-
   void Forget()
   {
     MOZ_ASSERT(NS_IsMainThread());
     mFinishPromise.ResolveIfExists(true, __func__);
     MutexAutoLock lock(mMutex);
     mStream = nullptr;
   }
 
@@ -85,17 +78,16 @@ public:
   }
 
 private:
   MediaEventProducer<int64_t> mOnOutput;
 
   Mutex mMutex;
   // Members below are protected by mMutex.
   RefPtr<MediaStream> mStream;
-  int64_t mLastOutputTime; // microseconds
   // Main thread only.
   MozPromiseHolder<GenericPromise> mFinishPromise;
 };
 
 static void
 UpdateStreamSuspended(MediaStream* aStream, bool aBlocking)
 {
   if (NS_IsMainThread()) {
@@ -124,17 +116,16 @@ UpdateStreamSuspended(MediaStream* aStre
  * not connected to streams created by captureStreamUntilEnded.
  */
 class DecodedStreamData {
 public:
   DecodedStreamData(OutputStreamManager* aOutputStreamManager,
                     PlaybackInfoInit&& aInit,
                     MozPromiseHolder<GenericPromise>&& aPromise);
   ~DecodedStreamData();
-  int64_t GetPosition() const;
   void SetPlaying(bool aPlaying);
   MediaEventSource<int64_t>& OnOutput();
 
   /* The following group of fields are protected by the decoder's monitor
    * and can be read or written on any thread.
    */
   // Count of audio frames written to the stream
   int64_t mAudioFramesWritten;
@@ -196,22 +187,16 @@ DecodedStreamData::DecodedStreamData(Out
 
 DecodedStreamData::~DecodedStreamData()
 {
   mOutputStreamManager->Disconnect();
   mListener->Forget();
   mStream->Destroy();
 }
 
-int64_t
-DecodedStreamData::GetPosition() const
-{
-  return mListener->GetLastOutputTime();
-}
-
 MediaEventSource<int64_t>&
 DecodedStreamData::OnOutput()
 {
   return mListener->OnOutput();
 }
 
 void
 DecodedStreamData::SetPlaying(bool aPlaying)
@@ -706,17 +691,17 @@ DecodedStream::GetPosition(TimeStamp* aT
 {
   AssertOwnerThread();
   // This is only called after MDSM starts playback. So mStartTime is
   // guaranteed to be something.
   MOZ_ASSERT(mStartTime.isSome());
   if (aTimeStamp) {
     *aTimeStamp = TimeStamp::Now();
   }
-  return mStartTime.ref() + (mData ? mData->GetPosition() : 0);
+  return mStartTime.ref() + mLastOutputTime;
 }
 
 void
 DecodedStream::NotifyOutput(int64_t aTime)
 {
   AssertOwnerThread();
   mLastOutputTime = aTime;
 }