Bug 1394591 - P5. Remove need for atomic members. r=mattwoodrow
☠☠ backed out by 9fcbd2fd6d0b ☠ ☠
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 01 Sep 2017 22:51:20 +0200
changeset 428177 ba1a3d16916b799175407eb500f198117b0b1024
parent 428176 b741cbca23bd442ac91e2ed0a5beb3815795f4bf
child 428178 de401d17868d6fb35b71dc77879331b530c80bd3
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1394591
milestone57.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 1394591 - P5. Remove need for atomic members. r=mattwoodrow Instead set members after initialising the child decoder, and only ever access the child decoder on the same thread. MozReview-Commit-ID: 4mfhVWbNLEu
dom/media/ipc/RemoteVideoDecoder.cpp
dom/media/ipc/RemoteVideoDecoder.h
dom/media/ipc/VideoDecoderChild.cpp
dom/media/ipc/VideoDecoderChild.h
--- a/dom/media/ipc/RemoteVideoDecoder.cpp
+++ b/dom/media/ipc/RemoteVideoDecoder.cpp
@@ -57,16 +57,19 @@ RemoteVideoDecoder::Init()
   return InvokeAsync(VideoDecoderManagerChild::GetManagerAbstractThread(),
                      __func__,
                      [self, this]() { return mActor->Init(); })
     ->Then(VideoDecoderManagerChild::GetManagerAbstractThread(),
            __func__,
            [self, this](TrackType aTrack) {
              mDescription =
                mActor->GetDescriptionName() + NS_LITERAL_CSTRING(" (remote)");
+             mIsHardwareAccelerated =
+               mActor->IsHardwareAccelerated(mHardwareAcceleratedReason);
+             mConversion = mActor->NeedsConversion();
              return InitPromise::CreateAndResolve(aTrack, __func__);
            },
            [self, this](const MediaResult& aError) {
              return InitPromise::CreateAndReject(aError, __func__);
            });
 }
 
 RefPtr<MediaDataDecoder::DecodePromise>
@@ -104,17 +107,18 @@ RemoteVideoDecoder::Shutdown()
                        mActor->Shutdown();
                        return ShutdownPromise::CreateAndResolve(true, __func__);
                      });
 }
 
 bool
 RemoteVideoDecoder::IsHardwareAccelerated(nsACString& aFailureReason) const
 {
-  return mActor->IsHardwareAccelerated(aFailureReason);
+  aFailureReason = mHardwareAcceleratedReason;
+  return mIsHardwareAccelerated;
 }
 
 void
 RemoteVideoDecoder::SetSeekThreshold(const media::TimeUnit& aTime)
 {
   RefPtr<RemoteVideoDecoder> self = this;
   media::TimeUnit time = aTime;
   VideoDecoderManagerChild::GetManagerThread()->Dispatch(
@@ -124,17 +128,17 @@ RemoteVideoDecoder::SetSeekThreshold(con
                              self->mActor->SetSeekThreshold(time);
                            }),
     NS_DISPATCH_NORMAL);
 }
 
 MediaDataDecoder::ConversionRequired
 RemoteVideoDecoder::NeedsConversion() const
 {
-  return mActor->NeedsConversion();
+  return mConversion;
 }
 
 nsresult
 RemoteDecoderModule::Startup()
 {
   if (!VideoDecoderManagerChild::GetManagerThread()) {
     return NS_ERROR_FAILURE;
   }
--- a/dom/media/ipc/RemoteVideoDecoder.h
+++ b/dom/media/ipc/RemoteVideoDecoder.h
@@ -43,16 +43,19 @@ private:
 
   // Only ever written to from the reader task queue (during the constructor and
   // destructor when we can guarantee no other threads are accessing it). Only
   // read from the manager thread.
   RefPtr<VideoDecoderChild> mActor;
   // Only ever written/modified during decoder initialisation.
   // As such can be accessed from any threads after that.
   nsCString mDescription;
+  bool mIsHardwareAccelerated;
+  nsCString mHardwareAcceleratedReason;
+  MediaDataDecoder::ConversionRequired mConversion;
 };
 
 // A PDM implementation that creates RemoteVideoDecoders.
 // We currently require a 'wrapped' PDM in order to be able to answer SupportsMimeType
 // and DecoderNeedsConversion. Ideally we'd check these over IPDL using the manager
 // protocol
 class RemoteDecoderModule : public PlatformDecoderModule
 {
--- a/dom/media/ipc/VideoDecoderChild.cpp
+++ b/dom/media/ipc/VideoDecoderChild.cpp
@@ -322,16 +322,17 @@ VideoDecoderChild::Shutdown()
     SendShutdown();
   }
   mInitialized = false;
 }
 
 bool
 VideoDecoderChild::IsHardwareAccelerated(nsACString& aFailureReason) const
 {
+  AssertOnManagerThread();
   aFailureReason = mHardwareAcceleratedReason;
   return mIsHardwareAccelerated;
 }
 
 nsCString
 VideoDecoderChild::GetDescriptionName() const
 {
   AssertOnManagerThread();
@@ -345,16 +346,17 @@ VideoDecoderChild::SetSeekThreshold(cons
   if (mCanSend) {
     SendSetSeekThreshold(aTime.ToMicroseconds());
   }
 }
 
 MediaDataDecoder::ConversionRequired
 VideoDecoderChild::NeedsConversion() const
 {
+  AssertOnManagerThread();
   return mConversion;
 }
 
 void
 VideoDecoderChild::AssertOnManagerThread() const
 {
   MOZ_ASSERT(NS_GetCurrentThread() == mThread);
 }
--- a/dom/media/ipc/VideoDecoderChild.h
+++ b/dom/media/ipc/VideoDecoderChild.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=99: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 #ifndef include_dom_ipc_VideoDecoderChild_h
 #define include_dom_ipc_VideoDecoderChild_h
 
 #include "PlatformDecoderModule.h"
-#include "mozilla/Atomics.h"
 #include "mozilla/dom/PVideoDecoderChild.h"
 
 namespace mozilla {
 namespace dom {
 
 class RemoteVideoDecoder;
 class RemoteDecoderModule;
 class VideoDecoderManagerChild;
@@ -70,18 +69,18 @@ private:
   MozPromiseHolder<MediaDataDecoder::DecodePromise> mDecodePromise;
   MozPromiseHolder<MediaDataDecoder::DecodePromise> mDrainPromise;
   MozPromiseHolder<MediaDataDecoder::FlushPromise> mFlushPromise;
 
   nsCString mHardwareAcceleratedReason;
   nsCString mDescription;
   bool mCanSend;
   bool mInitialized;
-  Atomic<bool> mIsHardwareAccelerated;
-  Atomic<MediaDataDecoder::ConversionRequired> mConversion;
+  bool mIsHardwareAccelerated;
+  MediaDataDecoder::ConversionRequired mConversion;
 
   // Set to true if the actor got destroyed and we haven't yet notified the
   // caller.
   bool mNeedNewDecoder;
   MediaDataDecoder::DecodedData mDecodedData;
 
   nsCString mBlacklistedD3D11Driver;
   nsCString mBlacklistedD3D9Driver;