Bug 1234424. Part 1 - share the underlying value of MDSM::mSameOriginMedia with DecodedStream. r=roc.
authorJW Wang <jwwang@mozilla.com>
Tue, 05 Jan 2016 21:15:37 +0800
changeset 278896 53cf113966ff8fe9ae1aa839bd0203a5afb95886
parent 278895 200aa49f81d22a35861a04d4171b3792cca3b9ce
child 278897 f5e68d14fe28237dfa6fa254be61979f3455e661
push id29860
push usercbook@mozilla.com
push dateThu, 07 Jan 2016 10:51:20 +0000
treeherdermozilla-central@e0bcd16e1d4b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1234424
milestone46.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 1234424. Part 1 - share the underlying value of MDSM::mSameOriginMedia with DecodedStream. r=roc.
dom/media/MediaDecoderStateMachine.cpp
dom/media/mediasink/DecodedStream.cpp
dom/media/mediasink/DecodedStream.h
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -236,18 +236,16 @@ MediaDecoderStateMachine::MediaDecoderSt
   mDecodeToSeekTarget(false),
   mCurrentTimeBeforeSeek(0),
   mCorruptFrames(60),
   mDecodingFirstFrame(true),
   mSentLoadedMetadataEvent(false),
   mSentFirstFrameLoadedEvent(false, "MediaDecoderStateMachine::mSentFirstFrameLoadedEvent"),
   mSentPlaybackEndedEvent(false),
   mOutputStreamManager(new OutputStreamManager()),
-  mStreamSink(new DecodedStream(
-    mTaskQueue, mAudioQueue, mVideoQueue, mOutputStreamManager)),
   mResource(aDecoder->GetResource()),
   mAudioOffloading(false),
   mBuffered(mTaskQueue, TimeIntervals(),
             "MediaDecoderStateMachine::mBuffered (Mirror)"),
   mEstimatedDuration(mTaskQueue, NullableTimeUnit(),
                     "MediaDecoderStateMachine::mEstimatedDuration (Mirror)"),
   mExplicitDuration(mTaskQueue, Maybe<double>(),
                     "MediaDecoderStateMachine::mExplicitDuration (Mirror)"),
@@ -334,16 +332,19 @@ MediaDecoderStateMachine::~MediaDecoderS
 #endif
 }
 
 void
 MediaDecoderStateMachine::InitializationTask(MediaDecoder* aDecoder)
 {
   MOZ_ASSERT(OnTaskQueue());
 
+  mStreamSink = new DecodedStream(mTaskQueue, mAudioQueue, mVideoQueue,
+                                  mOutputStreamManager, mSameOriginMedia.Ref());
+
   // Connect mirrors.
   mBuffered.Connect(mReader->CanonicalBuffered());
   mEstimatedDuration.Connect(aDecoder->CanonicalEstimatedDuration());
   mExplicitDuration.Connect(aDecoder->CanonicalExplicitDuration());
   mPlayState.Connect(aDecoder->CanonicalPlayState());
   mNextPlayState.Connect(aDecoder->CanonicalNextPlayState());
   mLogicallySeeking.Connect(aDecoder->CanonicalLogicallySeeking());
   mVolume.Connect(aDecoder->CanonicalVolume());
--- a/dom/media/mediasink/DecodedStream.cpp
+++ b/dom/media/mediasink/DecodedStream.cpp
@@ -183,21 +183,22 @@ DecodedStreamData::SetPlaying(bool aPlay
     mPlaying = aPlaying;
     UpdateStreamSuspended(mStream, !mPlaying);
   }
 }
 
 DecodedStream::DecodedStream(AbstractThread* aOwnerThread,
                              MediaQueue<MediaData>& aAudioQueue,
                              MediaQueue<MediaData>& aVideoQueue,
-                             OutputStreamManager* aOutputStreamManager)
+                             OutputStreamManager* aOutputStreamManager,
+                             const bool& aSameOrigin)
   : mOwnerThread(aOwnerThread)
   , mOutputStreamManager(aOutputStreamManager)
   , mPlaying(false)
-  , mSameOrigin(false)
+  , mSameOrigin(aSameOrigin)
   , mAudioQueue(aAudioQueue)
   , mVideoQueue(aVideoQueue)
 {
 }
 
 DecodedStream::~DecodedStream()
 {
   MOZ_ASSERT(mStartTime.isNothing(), "playback should've ended.");
--- a/dom/media/mediasink/DecodedStream.h
+++ b/dom/media/mediasink/DecodedStream.h
@@ -30,17 +30,18 @@ template <class T> class MediaQueue;
 
 class DecodedStream : public media::MediaSink {
   using media::MediaSink::PlaybackParams;
 
 public:
   DecodedStream(AbstractThread* aOwnerThread,
                 MediaQueue<MediaData>& aAudioQueue,
                 MediaQueue<MediaData>& aVideoQueue,
-                OutputStreamManager* aOutputStreamManager);
+                OutputStreamManager* aOutputStreamManager,
+                const bool& aSameOrigin);
 
   // MediaSink functions.
   const PlaybackParams& GetPlaybackParams() const override;
   void SetPlaybackParams(const PlaybackParams& aParams) override;
 
   RefPtr<GenericPromise> OnEnded(TrackType aType) override;
   int64_t GetEndTime(TrackType aType) const override;
   int64_t GetPosition(TimeStamp* aTimeStamp = nullptr) const override;
@@ -93,17 +94,17 @@ private:
 
   /*
    * Worker thread only members.
    */
   UniquePtr<DecodedStreamData> mData;
   RefPtr<GenericPromise> mFinishPromise;
 
   bool mPlaying;
-  bool mSameOrigin;
+  const bool& mSameOrigin; // valid until Shutdown() is called.
   PlaybackParams mParams;
 
   Maybe<int64_t> mStartTime;
   MediaInfo mInfo;
 
   MediaQueue<MediaData>& mAudioQueue;
   MediaQueue<MediaData>& mVideoQueue;