Bug 1309516 part 6 - remove unused MediaDecoderReaderWrapper::mStartTimeRendezvous;r=jwwang
☠☠ backed out by fb72036436f9 ☠ ☠
authorKaku Kuo <kaku@mozilla.com>
Fri, 14 Oct 2016 19:22:41 +0800
changeset 320049 a876261d2d38eae83fad1f84f49734ec200341ef
parent 320048 a154fa107dd382275c79602102a278523c0987c2
child 320050 9ddc65900391f0bdf1c42cde846cce304dd44fef
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang
bugs1309516
milestone52.0a1
Bug 1309516 part 6 - remove unused MediaDecoderReaderWrapper::mStartTimeRendezvous;r=jwwang MozReview-Commit-ID: 6ukwUWpIJFF
dom/media/MediaDecoderReaderWrapper.cpp
dom/media/MediaDecoderReaderWrapper.h
--- a/dom/media/MediaDecoderReaderWrapper.cpp
+++ b/dom/media/MediaDecoderReaderWrapper.cpp
@@ -4,145 +4,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/MozPromise.h"
 #include "MediaDecoderReaderWrapper.h"
 
 namespace mozilla {
 
-extern LazyLogModule gMediaDecoderLog;
-
-#undef LOG
-#define LOG(...) \
-  MOZ_LOG(gMediaDecoderLog, mozilla::LogLevel::Debug, (__VA_ARGS__))
-
-// StartTimeRendezvous is a helper class that quarantines the first sample
-// until it gets a sample from both channels, such that we can be guaranteed
-// to know the start time by the time On{Audio,Video}Decoded is called on MDSM.
-class StartTimeRendezvous {
-  typedef MediaDecoderReader::MediaDataPromise MediaDataPromise;
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(StartTimeRendezvous);
-
-public:
-  StartTimeRendezvous(AbstractThread* aOwnerThread,
-                      bool aHasAudio,
-                      bool aHasVideo,
-                      bool aForceZeroStartTime)
-    : mOwnerThread(aOwnerThread)
-  {
-    if (aForceZeroStartTime) {
-      mAudioStartTime.emplace(0);
-      mVideoStartTime.emplace(0);
-      return;
-    }
-    if (!aHasAudio) {
-      mAudioStartTime.emplace(INT64_MAX);
-    }
-    if (!aHasVideo) {
-      mVideoStartTime.emplace(INT64_MAX);
-    }
-  }
-
-  void Destroy()
-  {
-    mAudioStartTime = Some(mAudioStartTime.refOr(INT64_MAX));
-    mVideoStartTime = Some(mVideoStartTime.refOr(INT64_MAX));
-    mHaveStartTimePromise.RejectIfExists(false, __func__);
-  }
-
-  RefPtr<HaveStartTimePromise> AwaitStartTime()
-  {
-    if (HaveStartTime()) {
-      return HaveStartTimePromise::CreateAndResolve(true, __func__);
-    }
-    return mHaveStartTimePromise.Ensure(__func__);
-  }
-
-  template<MediaData::Type SampleType>
-  RefPtr<MediaDataPromise>
-  ProcessFirstSample(MediaData* aData)
-  {
-    typedef typename MediaDataPromise::Private PromisePrivate;
-    MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
-
-    MaybeSetChannelStartTime<SampleType>(aData->mTime);
-
-    RefPtr<PromisePrivate> p = new PromisePrivate(__func__);
-    RefPtr<MediaData> data = aData;
-    RefPtr<StartTimeRendezvous> self = this;
-    AwaitStartTime()->Then(
-      mOwnerThread, __func__,
-      [p, data, self] () {
-        MOZ_ASSERT(self->mOwnerThread->IsCurrentThreadIn());
-        p->Resolve(data, __func__);
-      },
-      [p] () {
-        p->Reject(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
-      });
-
-    return p.forget();
-  }
-
-  template<MediaData::Type SampleType>
-  void FirstSampleRejected(const MediaResult& aError)
-  {
-    MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
-    if (aError == NS_ERROR_DOM_MEDIA_END_OF_STREAM) {
-      LOG("StartTimeRendezvous=%p SampleType(%d) Has no samples.",
-           this, SampleType);
-      MaybeSetChannelStartTime<SampleType>(INT64_MAX);
-    } else if (aError != NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA) {
-      mHaveStartTimePromise.RejectIfExists(false, __func__);
-    }
-  }
-
-  bool HaveStartTime() const
-  {
-    return mAudioStartTime.isSome() && mVideoStartTime.isSome();
-  }
-
-  int64_t StartTime() const
-  {
-    int64_t time = std::min(mAudioStartTime.ref(), mVideoStartTime.ref());
-    return time == INT64_MAX ? 0 : time;
-  }
-
-private:
-  ~StartTimeRendezvous() {}
-
-  template<MediaData::Type SampleType>
-  void MaybeSetChannelStartTime(int64_t aStartTime)
-  {
-    if (ChannelStartTime(SampleType).isSome()) {
-      // If we're initialized with aForceZeroStartTime=true, the channel start
-      // times are already set.
-      return;
-    }
-
-    LOG("StartTimeRendezvous=%p Setting SampleType(%d) start time to %lld",
-        this, SampleType, aStartTime);
-
-    ChannelStartTime(SampleType).emplace(aStartTime);
-    if (HaveStartTime()) {
-      mHaveStartTimePromise.ResolveIfExists(true, __func__);
-    }
-  }
-
-  Maybe<int64_t>& ChannelStartTime(MediaData::Type aType)
-  {
-    return aType == MediaData::AUDIO_DATA ? mAudioStartTime : mVideoStartTime;
-  }
-
-  MozPromiseHolder<HaveStartTimePromise> mHaveStartTimePromise;
-  RefPtr<AbstractThread> mOwnerThread;
-  Maybe<int64_t> mAudioStartTime;
-  Maybe<int64_t> mVideoStartTime;
-};
-
 MediaDecoderReaderWrapper::MediaDecoderReaderWrapper(AbstractThread* aOwnerThread,
                                                      MediaDecoderReader* aReader)
   : mForceZeroStartTime(aReader->ForceZeroStartTime())
   , mOwnerThread(aOwnerThread)
   , mReader(aReader)
 {}
 
 MediaDecoderReaderWrapper::~MediaDecoderReaderWrapper()
@@ -346,20 +217,16 @@ MediaDecoderReaderWrapper::ResetDecode(T
 RefPtr<ShutdownPromise>
 MediaDecoderReaderWrapper::Shutdown()
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   MOZ_ASSERT(!mAudioDataRequest.Exists());
   MOZ_ASSERT(!mVideoDataRequest.Exists());
 
   mShutdown = true;
-  if (mStartTimeRendezvous) {
-    mStartTimeRendezvous->Destroy();
-    mStartTimeRendezvous = nullptr;
-  }
   return InvokeAsync(mReader->OwnerThread(), mReader.get(), __func__,
                      &MediaDecoderReader::Shutdown);
 }
 
 void
 MediaDecoderReaderWrapper::OnMetadataRead(MetadataHolder* aMetadata)
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
--- a/dom/media/MediaDecoderReaderWrapper.h
+++ b/dom/media/MediaDecoderReaderWrapper.h
@@ -12,18 +12,16 @@
 #include "mozilla/Variant.h"
 #include "nsISupportsImpl.h"
 
 #include "MediaDecoderReader.h"
 #include "MediaEventSource.h"
 
 namespace mozilla {
 
-class StartTimeRendezvous;
-
 typedef MozPromise<bool, bool, /* isExclusive = */ false> HaveStartTimePromise;
 
 typedef Variant<MediaData*, MediaResult> AudioCallbackData;
 typedef Variant<Tuple<MediaData*, TimeStamp>, MediaResult> VideoCallbackData;
 typedef Variant<MediaData::Type, WaitForDataRejectValue> WaitCallbackData;
 
 /**
  * A wrapper around MediaDecoderReader to offset the timestamps of Audio/Video
@@ -127,17 +125,16 @@ private:
   MediaCallbackExc<WaitCallbackData>& WaitCallbackRef(MediaData::Type aType);
   MozPromiseRequestHolder<WaitForDataPromise>& WaitRequestRef(MediaData::Type aType);
 
   const bool mForceZeroStartTime;
   const RefPtr<AbstractThread> mOwnerThread;
   const RefPtr<MediaDecoderReader> mReader;
 
   bool mShutdown = false;
-  RefPtr<StartTimeRendezvous> mStartTimeRendezvous;
   Maybe<media::TimeUnit> mStartTime;
 
   MozPromiseRequestHolder<MediaDataPromise> mAudioDataRequest;
   MozPromiseRequestHolder<MediaDataPromise> mVideoDataRequest;
   MozPromiseRequestHolder<WaitForDataPromise> mAudioWaitRequest;
   MozPromiseRequestHolder<WaitForDataPromise> mVideoWaitRequest;
 };