From 646b842413481b9eae87513e8c50ff9850638d59 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Tue, 16 Dec 2014 23:08:42 +1300 Subject: [PATCH] Bug 1111413 - Part 2: Remove RequestSampleCallback. r=bholley --- dom/media/MediaDataDecodedListener.h | 47 --------------------- dom/media/MediaDecoderReader.cpp | 10 ----- dom/media/MediaDecoderReader.h | 24 ----------- dom/media/MediaDecoderStateMachine.cpp | 6 --- dom/media/MediaDecoderStateMachine.h | 3 -- dom/media/mediasource/MediaSourceReader.cpp | 8 ---- dom/media/moz.build | 1 - 7 files changed, 99 deletions(-) delete mode 100644 dom/media/MediaDataDecodedListener.h diff --git a/dom/media/MediaDataDecodedListener.h b/dom/media/MediaDataDecodedListener.h deleted file mode 100644 index e5bf1c190dcc..000000000000 --- a/dom/media/MediaDataDecodedListener.h +++ /dev/null @@ -1,47 +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 MediaDataDecodedListener_h_ -#define MediaDataDecodedListener_h_ - -#include "mozilla/Monitor.h" -#include "MediaDecoderReader.h" - -namespace mozilla { - -class MediaDecoderStateMachine; -class MediaData; - -// A RequestSampleCallback implementation that forwards samples onto the -// MediaDecoderStateMachine via tasks that run on the supplied task queue. -template -class MediaDataDecodedListener : public RequestSampleCallback { -public: - MediaDataDecodedListener(Target* aTarget, - MediaTaskQueue* aTaskQueue) - : mMonitor("MediaDataDecodedListener") - , mTaskQueue(aTaskQueue) - , mTarget(aTarget) - { - MOZ_ASSERT(aTarget); - MOZ_ASSERT(aTaskQueue); - } - - void BreakCycles() { - MonitorAutoLock lock(mMonitor); - mTarget = nullptr; - mTaskQueue = nullptr; - } - -private: - Monitor mMonitor; - RefPtr mTaskQueue; - RefPtr mTarget; -}; - -} /* namespace mozilla */ - -#endif // MediaDataDecodedListener_h_ diff --git a/dom/media/MediaDecoderReader.cpp b/dom/media/MediaDecoderReader.cpp index f5c8cf605e3d..e5e4b09a6bf0 100644 --- a/dom/media/MediaDecoderReader.cpp +++ b/dom/media/MediaDecoderReader.cpp @@ -263,12 +263,6 @@ MediaDecoderReader::RequestAudioData() return p; } -void -MediaDecoderReader::SetCallback(RequestSampleCallback* aCallback) -{ - mSampleDecodedCallback = aCallback; -} - MediaTaskQueue* MediaDecoderReader::EnsureTaskQueue() { @@ -286,10 +280,6 @@ MediaDecoderReader::EnsureTaskQueue() void MediaDecoderReader::BreakCycles() { - if (mSampleDecodedCallback) { - mSampleDecodedCallback->BreakCycles(); - mSampleDecodedCallback = nullptr; - } mTaskQueue = nullptr; } diff --git a/dom/media/MediaDecoderReader.h b/dom/media/MediaDecoderReader.h index b94a61f8f6e4..acb0f8328bab 100644 --- a/dom/media/MediaDecoderReader.h +++ b/dom/media/MediaDecoderReader.h @@ -19,7 +19,6 @@ namespace dom { class TimeRanges; } -class RequestSampleCallback; class MediaDecoderReader; class SharedDecoderManager; @@ -72,7 +71,6 @@ public: // thread. virtual nsRefPtr Shutdown(); - virtual void SetCallback(RequestSampleCallback* aDecodedSampleCallback); MediaTaskQueue* EnsureTaskQueue(); virtual bool OnDecodeThread() @@ -242,11 +240,6 @@ protected: return false; } - RequestSampleCallback* GetCallback() { - MOZ_ASSERT(mSampleDecodedCallback); - return mSampleDecodedCallback; - } - // Queue of audio frames. This queue is threadsafe, and is accessed from // the audio, decoder, state machine, and main threads. MediaQueue mAudioQueue; @@ -285,8 +278,6 @@ protected: bool mHitAudioDecodeError; private: - nsRefPtr mSampleDecodedCallback; - // Promises used only for the base-class (sync->async adapter) implementation // of Request{Audio,Video}Data. MediaPromiseHolder mBaseAudioPromise; @@ -302,21 +293,6 @@ private: bool mShutdown; }; -// Interface that callers to MediaDecoderReader::Request{Audio,Video}Data() -// must implement to receive the requested samples asynchronously. -// This object is refcounted, and cycles must be broken by calling -// BreakCycles() during shutdown. -class RequestSampleCallback { -public: - NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RequestSampleCallback) - - // Called during shutdown to break any reference cycles. - virtual void BreakCycles() = 0; - -protected: - virtual ~RequestSampleCallback() {} -}; - } // namespace mozilla #endif diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 7447faed2fcb..5b64c57ea619 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -1098,12 +1098,6 @@ nsresult MediaDecoderStateMachine::Init(MediaDecoderStateMachine* aCloneDonor) nsresult rv = mScheduler->Init(); NS_ENSURE_SUCCESS(rv, rv); - // Note: This creates a cycle, broken in shutdown. - mMediaDecodedListener = - new MediaDataDecodedListener(this, - DecodeTaskQueue()); - mReader->SetCallback(mMediaDecodedListener); - rv = mReader->Init(cloneReader); NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/media/MediaDecoderStateMachine.h b/dom/media/MediaDecoderStateMachine.h index f4f424e54107..06a842d43298 100644 --- a/dom/media/MediaDecoderStateMachine.h +++ b/dom/media/MediaDecoderStateMachine.h @@ -89,7 +89,6 @@ hardware (via AudioStream). #include "MediaDecoderReader.h" #include "MediaDecoderOwner.h" #include "MediaMetadataManager.h" -#include "MediaDataDecodedListener.h" class nsITimer; @@ -445,8 +444,6 @@ protected: nsresult FinishDecodeFirstFrame(); - RefPtr> mMediaDecodedListener; - nsAutoPtr mMetadataTags; // True if our buffers of decoded audio are not full, and we should diff --git a/dom/media/mediasource/MediaSourceReader.cpp b/dom/media/mediasource/MediaSourceReader.cpp index 85c4b0f4e14a..75cdcc2fdfe5 100644 --- a/dom/media/mediasource/MediaSourceReader.cpp +++ b/dom/media/mediasource/MediaSourceReader.cpp @@ -8,7 +8,6 @@ #include "prlog.h" #include "mozilla/dom/TimeRanges.h" #include "DecoderTraits.h" -#include "MediaDataDecodedListener.h" #include "MediaDecoderOwner.h" #include "MediaSourceDecoder.h" #include "MediaSourceUtils.h" @@ -455,13 +454,6 @@ MediaSourceReader::CreateSubDecoder(const nsACString& aType) // borrowing. reader->SetBorrowedTaskQueue(GetTaskQueue()); - // Set a callback on the subreader that forwards calls to this reader. - // This reader will then forward them onto the state machine via this - // reader's callback. - RefPtr> callback = - new MediaDataDecodedListener(this, reader->GetTaskQueue()); - reader->SetCallback(callback); - #ifdef MOZ_FMP4 reader->SetSharedDecoderManager(mSharedDecoderManager); #endif diff --git a/dom/media/moz.build b/dom/media/moz.build index 6b48e49dbfb9..1320a3e67d73 100644 --- a/dom/media/moz.build +++ b/dom/media/moz.build @@ -98,7 +98,6 @@ EXPORTS += [ 'Latency.h', 'MediaCache.h', 'MediaData.h', - 'MediaDataDecodedListener.h', 'MediaDecoder.h', 'MediaDecoderOwner.h', 'MediaDecoderReader.h',