Bug 1334061: P3. Make MediaDataDecoderProxy work with no taskqueue. r=cpearce
authorJean-Yves Avenard <jyavenard@mozilla.com>
Wed, 15 Feb 2017 20:12:19 +0100
changeset 343496 1f54c7ac6ce28017940c216398f903cd27fb3567
parent 343495 3d07a23d024fbcc5881015804f76eac5a7ec7a29
child 343497 a4b22fd48c583795b067bdade072e866d2183c15
push id31381
push userkwierso@gmail.com
push dateFri, 17 Feb 2017 20:45:51 +0000
treeherdermozilla-central@f302def88fe5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1334061
milestone54.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 1334061: P3. Make MediaDataDecoderProxy work with no taskqueue. r=cpearce MediaDataDecoderProxy can now be used to easily override methods of MediaDataDecoder. MozReview-Commit-ID: 5Uni9sFmi83
dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.cpp
dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.h
--- a/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.cpp
+++ b/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.cpp
@@ -8,64 +8,74 @@
 
 namespace mozilla {
 
 RefPtr<MediaDataDecoder::InitPromise>
 MediaDataDecoderProxy::Init()
 {
   MOZ_ASSERT(!mIsShutdown);
 
+  if (!mProxyThread) {
+    return mProxyDecoder->Init();
+  }
   RefPtr<MediaDataDecoderProxy> self = this;
   return InvokeAsync(mProxyThread, __func__,
                      [self, this]() { return mProxyDecoder->Init(); });
 }
 
 RefPtr<MediaDataDecoder::DecodePromise>
 MediaDataDecoderProxy::Decode(MediaRawData* aSample)
 {
-  MOZ_ASSERT(!IsOnProxyThread());
   MOZ_ASSERT(!mIsShutdown);
 
+  if (!mProxyThread) {
+    return mProxyDecoder->Decode(aSample);
+  }
   RefPtr<MediaDataDecoderProxy> self = this;
   RefPtr<MediaRawData> sample = aSample;
   return InvokeAsync(mProxyThread, __func__, [self, this, sample]() {
     return mProxyDecoder->Decode(sample);
   });
 }
 
 RefPtr<MediaDataDecoder::FlushPromise>
 MediaDataDecoderProxy::Flush()
 {
-  MOZ_ASSERT(!IsOnProxyThread());
   MOZ_ASSERT(!mIsShutdown);
 
+  if (!mProxyThread) {
+    return mProxyDecoder->Flush();
+  }
   RefPtr<MediaDataDecoderProxy> self = this;
   return InvokeAsync(mProxyThread, __func__,
                      [self, this]() { return mProxyDecoder->Flush(); });
 }
 
 RefPtr<MediaDataDecoder::DecodePromise>
 MediaDataDecoderProxy::Drain()
 {
-  MOZ_ASSERT(!IsOnProxyThread());
   MOZ_ASSERT(!mIsShutdown);
 
+  if (!mProxyThread) {
+    return mProxyDecoder->Drain();
+  }
   RefPtr<MediaDataDecoderProxy> self = this;
   return InvokeAsync(mProxyThread, __func__,
                      [self, this]() { return mProxyDecoder->Drain(); });
 }
 
 RefPtr<ShutdownPromise>
 MediaDataDecoderProxy::Shutdown()
 {
-  MOZ_ASSERT(!IsOnProxyThread());
-  // Note that this *may* be called from the proxy thread also.
   MOZ_ASSERT(!mIsShutdown);
 #if defined(DEBUG)
   mIsShutdown = true;
 #endif
 
+  if (!mProxyThread) {
+    return mProxyDecoder->Shutdown();
+  }
   RefPtr<MediaDataDecoderProxy> self = this;
   return InvokeAsync(mProxyThread, __func__,
                      [self, this]() { return mProxyDecoder->Shutdown(); });
 }
 
 } // namespace mozilla
--- a/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.h
+++ b/dom/media/platforms/agnostic/gmp/MediaDataDecoderProxy.h
@@ -35,28 +35,21 @@ public:
   RefPtr<InitPromise> Init() override;
   RefPtr<DecodePromise> Decode(MediaRawData* aSample) override;
   RefPtr<DecodePromise> Drain() override;
   RefPtr<FlushPromise> Flush() override;
   RefPtr<ShutdownPromise> Shutdown() override;
 
   const char* GetDescriptionName() const override
   {
-    return "GMP proxy data decoder";
+    return mProxyDecoder->GetDescriptionName();
   }
 
 private:
 
-#ifdef DEBUG
-  bool IsOnProxyThread()
-  {
-    return mProxyThread && mProxyThread->IsCurrentThreadIn();
-  }
-#endif
-
   RefPtr<MediaDataDecoder> mProxyDecoder;
   RefPtr<AbstractThread> mProxyThread;
 
 #if defined(DEBUG)
   Atomic<bool> mIsShutdown;
 #endif
 };