Bug 1378295. P3 - remove BufferDecoder. r=jya
authorJW Wang <jwwang@mozilla.com>
Thu, 13 Jul 2017 15:33:02 +0800
changeset 419196 5550726d24fb7bd5b769b978b02e47bb19d8efe9
parent 419195 ca52231d4002b4648c9fd600145beed7e078d85d
child 419197 28d20f28bacb3b45b7b89225bcae12e35ff0a967
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1378295
milestone56.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 1378295. P3 - remove BufferDecoder. r=jya Since now MFR doesn't need an AbstractMediaDecoder at all, we can now remove BufferDecoder which exists as an empty shell to implement AbstractMediaDecoder. MozReview-Commit-ID: HpEcK0mfpeh
dom/media/webaudio/BufferDecoder.cpp
dom/media/webaudio/BufferDecoder.h
dom/media/webaudio/MediaBufferDecoder.cpp
dom/media/webaudio/moz.build
deleted file mode 100644
--- a/dom/media/webaudio/BufferDecoder.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/. */
-
-#include "BufferDecoder.h"
-
-#include "nsISupports.h"
-#include "MediaResource.h"
-
-namespace mozilla {
-
-NS_IMPL_ISUPPORTS0(BufferDecoder)
-
-BufferDecoder::BufferDecoder(MediaResource* aResource,
-                             AbstractThread* aMainThread)
-  : mResource(aResource)
-  , mAbstractMainThread(aMainThread)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-}
-
-BufferDecoder::~BufferDecoder()
-{
-  // The dtor may run on any thread, we cannot be sure.
-}
-
-void
-BufferDecoder::BeginDecoding(TaskQueue* aTaskQueueIdentity)
-{
-  MOZ_ASSERT(!mTaskQueueIdentity && aTaskQueueIdentity);
-  mTaskQueueIdentity = aTaskQueueIdentity;
-}
-
-VideoFrameContainer*
-BufferDecoder::GetVideoFrameContainer()
-{
-  // no video frame
-  return nullptr;
-}
-
-layers::ImageContainer*
-BufferDecoder::GetImageContainer()
-{
-  // no image container
-  return nullptr;
-}
-
-MediaDecoderOwner*
-BufferDecoder::GetOwner() const
-{
-  // unknown
-  return nullptr;
-}
-
-AbstractThread*
-BufferDecoder::AbstractMainThread() const
-{
-  return mAbstractMainThread;
-}
-
-} // namespace mozilla
deleted file mode 100644
--- a/dom/media/webaudio/BufferDecoder.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 BUFFER_DECODER_H_
-#define BUFFER_DECODER_H_
-
-#include "mozilla/Attributes.h"
-#include "mozilla/ReentrantMonitor.h"
-#include "mozilla/TaskQueue.h"
-
-#include "AbstractMediaDecoder.h"
-
-namespace mozilla {
-
-/**
- * This class provides a decoder object which decodes a media file that lives in
- * a memory buffer.
- */
-class BufferDecoder final : public AbstractMediaDecoder
-{
-public:
-  // This class holds a weak pointer to MediaResource.  It's the responsibility
-  // of the caller to manage the memory of the MediaResource object.
-  explicit BufferDecoder(MediaResource* aResource,
-                         AbstractThread* aMainThread);
-
-  NS_DECL_THREADSAFE_ISUPPORTS
-
-  // This has to be called before decoding begins
-  void BeginDecoding(TaskQueue* aTaskQueueIdentity);
-
-  VideoFrameContainer* GetVideoFrameContainer() final override;
-  layers::ImageContainer* GetImageContainer() final override;
-
-  MediaDecoderOwner* GetOwner() const final override;
-
-  AbstractThread* AbstractMainThread() const final override;
-
-private:
-  virtual ~BufferDecoder();
-  RefPtr<TaskQueue> mTaskQueueIdentity;
-  RefPtr<MediaResource> mResource;
-  const RefPtr<AbstractThread> mAbstractMainThread;
-};
-
-} // namespace mozilla
-
-#endif /* BUFFER_DECODER_H_ */
--- a/dom/media/webaudio/MediaBufferDecoder.cpp
+++ b/dom/media/webaudio/MediaBufferDecoder.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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/. */
 
 #include "MediaBufferDecoder.h"
-#include "BufferDecoder.h"
 #include "mozilla/dom/AudioContextBinding.h"
 #include "mozilla/dom/BaseAudioContextBinding.h"
 #include "mozilla/dom/DOMException.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/AbstractThread.h"
 #include <speex/speex_resampler.h>
 #include "nsXPCOMCIDInternal.h"
 #include "nsComponentManagerUtils.h"
@@ -128,41 +127,36 @@ private:
   void SampleNotDecoded(const MediaResult& aError);
   void FinishDecode();
   void AllocateBuffer();
   void CallbackTheResult();
 
   void Cleanup()
   {
     MOZ_ASSERT(NS_IsMainThread());
-    // MediaFormatReader expects that BufferDecoder is alive.
-    // Destruct MediaFormatReader first.
     mDecoderReader = nullptr;
-    mBufferDecoder = nullptr;
     JS_free(nullptr, mBuffer);
   }
 
 private:
   MediaContainerType mContainerType;
   uint8_t* mBuffer;
   uint32_t mLength;
   WebAudioDecodeJob& mDecodeJob;
   PhaseEnum mPhase;
-  RefPtr<BufferDecoder> mBufferDecoder;
   RefPtr<MediaFormatReader> mDecoderReader;
   MediaInfo mMediaInfo;
   MediaQueue<AudioData> mAudioQueue;
   RefPtr<AbstractThread> mMainThread;
   bool mFirstFrameDecoded;
 };
 
 NS_IMETHODIMP
 MediaDecodeTask::Run()
 {
-  MOZ_ASSERT(mBufferDecoder);
   MOZ_ASSERT(mDecoderReader);
   switch (mPhase) {
   case PhaseEnum::Decode:
     Decode();
     break;
   case PhaseEnum::AllocateBuffer:
     AllocateBuffer();
     break;
@@ -185,20 +179,18 @@ MediaDecodeTask::CreateReader()
   nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(parent);
   if (sop) {
     principal = sop->GetPrincipal();
   }
 
   RefPtr<BufferMediaResource> resource =
     new BufferMediaResource(static_cast<uint8_t*>(mBuffer), mLength, principal);
 
-  MOZ_ASSERT(!mBufferDecoder);
   mMainThread =
     mDecodeJob.mContext->GetOwnerGlobal()->AbstractMainThreadFor(TaskCategory::Other);
-  mBufferDecoder = new BufferDecoder(resource, mMainThread);
 
   // If you change this list to add support for new decoders, please consider
   // updating HTMLMediaElement::CreateDecoder as well.
 
   MediaFormatReaderInit init;
   init.mResource = resource;
   mDecoderReader = DecoderTraits::CreateReader(mContainerType, init);
 
@@ -240,17 +232,16 @@ private:
   SpeexResamplerState* mResampler;
 };
 
 void
 MediaDecodeTask::Decode()
 {
   MOZ_ASSERT(!NS_IsMainThread());
 
-  mBufferDecoder->BeginDecoding(mDecoderReader->OwnerThread());
 
   mDecoderReader->AsyncReadMetadata()->Then(mDecoderReader->OwnerThread(), __func__, this,
                                        &MediaDecodeTask::OnMetadataRead,
                                        &MediaDecodeTask::OnMetadataNotRead);
 }
 
 void
 MediaDecodeTask::OnMetadataRead(MetadataHolder&& aMetadata)
--- a/dom/media/webaudio/moz.build
+++ b/dom/media/webaudio/moz.build
@@ -83,17 +83,16 @@ UNIFIED_SOURCES += [
     'AudioNode.cpp',
     'AudioNodeEngine.cpp',
     'AudioNodeExternalInputStream.cpp',
     'AudioNodeStream.cpp',
     'AudioParam.cpp',
     'AudioProcessingEvent.cpp',
     'AudioScheduledSourceNode.cpp',
     'BiquadFilterNode.cpp',
-    'BufferDecoder.cpp',
     'ChannelMergerNode.cpp',
     'ChannelSplitterNode.cpp',
     'ConstantSourceNode.cpp',
     'ConvolverNode.cpp',
     'DelayBuffer.cpp',
     'DelayNode.cpp',
     'DynamicsCompressorNode.cpp',
     'FFTBlock.cpp',