Bug 1125970 - Make flushing an opt-in mechanism, and use it only for the PDM task queues. v1 r=cpearce

This commit is contained in:
Bobby Holley 2015-02-14 19:08:15 -08:00
parent 1eb56f7355
commit aca11575be
48 changed files with 162 additions and 135 deletions

View File

@ -147,8 +147,17 @@ MediaTaskQueue::BeginShutdown()
return p;
}
void
FlushableMediaTaskQueue::Flush()
{
MonitorAutoLock mon(mQueueMonitor);
AutoSetFlushing autoFlush(this);
FlushLocked();
AwaitIdleLocked();
}
nsresult
MediaTaskQueue::FlushAndDispatch(TemporaryRef<nsIRunnable> aRunnable)
FlushableMediaTaskQueue::FlushAndDispatch(TemporaryRef<nsIRunnable> aRunnable)
{
MonitorAutoLock mon(mQueueMonitor);
AutoSetFlushing autoFlush(this);
@ -160,16 +169,7 @@ MediaTaskQueue::FlushAndDispatch(TemporaryRef<nsIRunnable> aRunnable)
}
void
MediaTaskQueue::Flush()
{
MonitorAutoLock mon(mQueueMonitor);
AutoSetFlushing autoFlush(this);
FlushLocked();
AwaitIdleLocked();
}
void
MediaTaskQueue::FlushLocked()
FlushableMediaTaskQueue::FlushLocked()
{
mQueueMonitor.AssertCurrentThreadOwns();
MOZ_ASSERT(mIsFlushing);

View File

@ -27,9 +27,7 @@ typedef MediaPromise<bool, bool, false> ShutdownPromise;
// they're received, and are guaranteed to not be executed concurrently.
// They may be executed on different threads, and a memory barrier is used
// to make this threadsafe for objects that aren't already threadsafe.
class MediaTaskQueue MOZ_FINAL {
~MediaTaskQueue();
class MediaTaskQueue {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaTaskQueue)
@ -43,12 +41,6 @@ public:
nsresult SyncDispatch(TemporaryRef<nsIRunnable> aRunnable);
nsresult FlushAndDispatch(TemporaryRef<nsIRunnable> aRunnable);
// Removes all pending tasks from the task queue, and blocks until
// the currently running task (if any) finishes.
void Flush();
// Puts the queue in a shutdown state and returns immediately. The queue will
// remain alive at least until all the events are drained, because the Runners
// hold a strong reference to the task queue, and one of them is always held
@ -70,7 +62,9 @@ public:
// the task queue. This is for debugging/validation purposes only.
bool IsCurrentThreadIn();
private:
protected:
virtual ~MediaTaskQueue();
// Blocks until all task finish executing. Called internally by methods
// that need to wait until the task queue is idle.
@ -81,7 +75,6 @@ private:
nsresult DispatchLocked(TemporaryRef<nsIRunnable> aRunnable,
DispatchMode aMode);
void FlushLocked();
RefPtr<SharedThreadPool> mPool;
@ -113,24 +106,6 @@ private:
bool mIsShutdown;
MediaPromiseHolder<ShutdownPromise> mShutdownPromise;
class MOZ_STACK_CLASS AutoSetFlushing
{
public:
explicit AutoSetFlushing(MediaTaskQueue* aTaskQueue) : mTaskQueue(aTaskQueue)
{
mTaskQueue->mQueueMonitor.AssertCurrentThreadOwns();
mTaskQueue->mIsFlushing = true;
}
~AutoSetFlushing()
{
mTaskQueue->mQueueMonitor.AssertCurrentThreadOwns();
mTaskQueue->mIsFlushing = false;
}
private:
MediaTaskQueue* mTaskQueue;
};
// True if we're flushing; we reject new tasks if we're flushing.
bool mIsFlushing;
@ -146,6 +121,37 @@ private:
};
};
class FlushableMediaTaskQueue : public MediaTaskQueue
{
public:
explicit FlushableMediaTaskQueue(TemporaryRef<SharedThreadPool> aPool) : MediaTaskQueue(aPool) {}
nsresult FlushAndDispatch(TemporaryRef<nsIRunnable> aRunnable);
void Flush();
private:
class MOZ_STACK_CLASS AutoSetFlushing
{
public:
explicit AutoSetFlushing(FlushableMediaTaskQueue* aTaskQueue) : mTaskQueue(aTaskQueue)
{
mTaskQueue->mQueueMonitor.AssertCurrentThreadOwns();
mTaskQueue->mIsFlushing = true;
}
~AutoSetFlushing()
{
mTaskQueue->mQueueMonitor.AssertCurrentThreadOwns();
mTaskQueue->mIsFlushing = false;
}
private:
FlushableMediaTaskQueue* mTaskQueue;
};
void FlushLocked();
};
} // namespace mozilla
#endif // MediaTaskQueue_h_

View File

@ -294,6 +294,16 @@ public:
nsRefPtr<MediaTaskQueue> mTaskQueue;
};
class CreateFlushableTaskQueueTask : public nsRunnable {
public:
NS_IMETHOD Run() {
MOZ_ASSERT(NS_IsMainThread());
mTaskQueue = new FlushableMediaTaskQueue(GetMediaDecodeThreadPool());
return NS_OK;
}
nsRefPtr<FlushableMediaTaskQueue> mTaskQueue;
};
already_AddRefed<MediaTaskQueue>
CreateMediaDecodeTaskQueue()
{
@ -304,4 +314,14 @@ CreateMediaDecodeTaskQueue()
return t->mTaskQueue.forget();
}
already_AddRefed<FlushableMediaTaskQueue>
CreateFlushableMediaDecodeTaskQueue()
{
// We must create the MediaTaskQueue/SharedThreadPool on the main thread.
nsRefPtr<CreateFlushableTaskQueueTask> t(new CreateFlushableTaskQueueTask());
nsresult rv = NS_DispatchToMainThread(t, NS_DISPATCH_SYNC);
NS_ENSURE_SUCCESS(rv, nullptr);
return t->mTaskQueue.forget();
}
} // end namespace mozilla

View File

@ -264,10 +264,14 @@ nsresult
GenerateRandomPathName(nsCString& aOutSalt, uint32_t aLength);
class MediaTaskQueue;
class FlushableMediaTaskQueue;
already_AddRefed<MediaTaskQueue>
CreateMediaDecodeTaskQueue();
already_AddRefed<FlushableMediaTaskQueue>
CreateFlushableMediaDecodeTaskQueue();
} // end namespace mozilla
#endif

View File

@ -20,7 +20,7 @@ public:
const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback);
virtual ~AVCCMediaDataDecoder();
@ -47,7 +47,7 @@ private:
mp4_demuxer::VideoDecoderConfig mCurrentConfig;
layers::LayersBackend mLayersBackend;
nsRefPtr<layers::ImageContainer> mImageContainer;
nsRefPtr<MediaTaskQueue> mVideoTaskQueue;
nsRefPtr<FlushableMediaTaskQueue> mVideoTaskQueue;
MediaDataDecoderCallback* mCallback;
nsRefPtr<MediaDataDecoder> mDecoder;
nsresult mLastError;
@ -57,7 +57,7 @@ AVCCMediaDataDecoder::AVCCMediaDataDecoder(PlatformDecoderModule* aPDM,
const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback)
: mPDM(aPDM)
, mCurrentConfig(aConfig)
@ -239,7 +239,7 @@ already_AddRefed<MediaDataDecoder>
AVCCDecoderModule::CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback)
{
nsRefPtr<MediaDataDecoder> decoder;
@ -265,7 +265,7 @@ AVCCDecoderModule::CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aCo
already_AddRefed<MediaDataDecoder>
AVCCDecoderModule::CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback)
{
return mPDM->CreateAudioDecoder(aConfig,

View File

@ -34,12 +34,12 @@ public:
CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
virtual already_AddRefed<MediaDataDecoder>
CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
virtual bool SupportsAudioMimeType(const char* aMimeType) MOZ_OVERRIDE;

View File

@ -23,7 +23,7 @@ class BlankMediaDataDecoder : public MediaDataDecoder {
public:
BlankMediaDataDecoder(BlankMediaDataCreator* aCreator,
MediaTaskQueue* aTaskQueue,
FlushableMediaTaskQueue* aTaskQueue,
MediaDataDecoderCallback* aCallback)
: mCreator(aCreator)
, mTaskQueue(aTaskQueue)
@ -85,7 +85,7 @@ public:
private:
nsAutoPtr<BlankMediaDataCreator> mCreator;
RefPtr<MediaTaskQueue> mTaskQueue;
RefPtr<FlushableMediaTaskQueue> mTaskQueue;
MediaDataDecoderCallback* mCallback;
};
@ -216,7 +216,7 @@ public:
CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE {
BlankVideoDataCreator* creator = new BlankVideoDataCreator(
aConfig.display_width, aConfig.display_height, aImageContainer);
@ -230,7 +230,7 @@ public:
// Decode thread.
virtual already_AddRefed<MediaDataDecoder>
CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE {
BlankAudioDataCreator* creator = new BlankAudioDataCreator(
aConfig.channel_count, aConfig.samples_per_second);

View File

@ -235,10 +235,10 @@ MP4Reader::Init(MediaDecoderReader* aCloneDonor)
InitLayersBackendType();
mAudio.mTaskQueue = new MediaTaskQueue(GetMediaDecodeThreadPool());
mAudio.mTaskQueue = new FlushableMediaTaskQueue(GetMediaDecodeThreadPool());
NS_ENSURE_TRUE(mAudio.mTaskQueue, NS_ERROR_FAILURE);
mVideo.mTaskQueue = new MediaTaskQueue(GetMediaDecodeThreadPool());
mVideo.mTaskQueue = new FlushableMediaTaskQueue(GetMediaDecodeThreadPool());
NS_ENSURE_TRUE(mVideo.mTaskQueue, NS_ERROR_FAILURE);
static bool sSetupPrefCache = false;
@ -434,8 +434,7 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo,
mPlatform = PlatformDecoderModule::CreateCDMWrapper(proxy,
HasAudio(),
HasVideo(),
GetTaskQueue());
HasVideo());
NS_ENSURE_TRUE(mPlatform, NS_ERROR_FAILURE);
#else
// EME not supported.

View File

@ -185,7 +185,7 @@ private:
nsRefPtr<MediaDataDecoder> mDecoder;
// TaskQueue on which decoder can choose to decode.
// Only non-null up until the decoder is created.
nsRefPtr<MediaTaskQueue> mTaskQueue;
nsRefPtr<FlushableMediaTaskQueue> mTaskQueue;
// Callback that receives output and error notifications from the decoder.
nsAutoPtr<DecoderCallback> mCallback;
// Decoded samples returned my mDecoder awaiting being returned to

View File

@ -86,8 +86,7 @@ PlatformDecoderModule::Init()
already_AddRefed<PlatformDecoderModule>
PlatformDecoderModule::CreateCDMWrapper(CDMProxy* aProxy,
bool aHasAudio,
bool aHasVideo,
MediaTaskQueue* aTaskQueue)
bool aHasVideo)
{
bool cdmDecodesAudio;
bool cdmDecodesVideo;

View File

@ -30,7 +30,7 @@ class ImageContainer;
class MediaDataDecoder;
class MediaDataDecoderCallback;
class MediaInputQueue;
class MediaTaskQueue;
class FlushableMediaTaskQueue;
class CDMProxy;
typedef int64_t Microseconds;
@ -83,8 +83,7 @@ public:
static already_AddRefed<PlatformDecoderModule>
CreateCDMWrapper(CDMProxy* aProxy,
bool aHasAudio,
bool aHasVideo,
MediaTaskQueue* aTaskQueue);
bool aHasVideo);
#endif
// Called to shutdown the decoder module and cleanup state. The PDM
@ -109,7 +108,7 @@ public:
CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback) = 0;
// Creates an Audio decoder with the specified properties.
@ -124,7 +123,7 @@ public:
// This is called on the decode task queue.
virtual already_AddRefed<MediaDataDecoder>
CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback) = 0;
// An audio decoder module must support AAC by default.

View File

@ -55,7 +55,7 @@ public:
};
SharedDecoderManager::SharedDecoderManager()
: mTaskQueue(new MediaTaskQueue(GetMediaDecodeThreadPool()))
: mTaskQueue(new FlushableMediaTaskQueue(GetMediaDecodeThreadPool()))
, mActiveProxy(nullptr)
, mActiveCallback(nullptr)
, mWaitForInternalDrain(false)
@ -73,7 +73,7 @@ SharedDecoderManager::CreateVideoDecoder(
PlatformDecoderModule* aPDM,
const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend, layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue, MediaDataDecoderCallback* aCallback)
FlushableMediaTaskQueue* aVideoTaskQueue, MediaDataDecoderCallback* aCallback)
{
if (!mDecoder) {
// We use the manager's task queue for the decoder, rather than the one

View File

@ -28,7 +28,7 @@ public:
PlatformDecoderModule* aPDM,
const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer, MediaTaskQueue* aVideoTaskQueue,
layers::ImageContainer* aImageContainer, FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback);
void SetReader(MediaDecoderReader* aReader);
@ -45,7 +45,7 @@ private:
void DrainComplete();
nsRefPtr<MediaDataDecoder> mDecoder;
nsRefPtr<MediaTaskQueue> mTaskQueue;
nsRefPtr<FlushableMediaTaskQueue> mTaskQueue;
SharedDecoderProxy* mActiveProxy;
MediaDataDecoderCallback* mActiveCallback;
nsAutoPtr<MediaDataDecoderCallback> mCallback;

View File

@ -260,7 +260,7 @@ AndroidDecoderModule::CreateVideoDecoder(
const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback)
{
MediaFormat::LocalRef format;
@ -279,7 +279,7 @@ AndroidDecoderModule::CreateVideoDecoder(
already_AddRefed<MediaDataDecoder>
AndroidDecoderModule::CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback)
{
MOZ_ASSERT(aConfig.bits_per_sample == 16, "We only handle 16-bit audio!");

View File

@ -25,12 +25,12 @@ public:
CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
virtual already_AddRefed<MediaDataDecoder>
CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;

View File

@ -23,7 +23,7 @@ PRLogModuleInfo* GetAppleMediaLog();
namespace mozilla {
AppleATDecoder::AppleATDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback)
: mConfig(aConfig)
, mFileStreamError(false)

View File

@ -15,13 +15,13 @@
namespace mozilla {
class MediaTaskQueue;
class FlushableMediaTaskQueue;
class MediaDataDecoderCallback;
class AppleATDecoder : public MediaDataDecoder {
public:
AppleATDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback);
virtual ~AppleATDecoder();
@ -41,7 +41,7 @@ public:
bool mFileStreamError;
private:
nsRefPtr<MediaTaskQueue> mTaskQueue;
nsRefPtr<FlushableMediaTaskQueue> mTaskQueue;
MediaDataDecoderCallback* mCallback;
AudioConverterRef mConverter;
AudioStreamBasicDescription mOutputFormat;

View File

@ -158,7 +158,7 @@ already_AddRefed<MediaDataDecoder>
AppleDecoderModule::CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback)
{
nsRefPtr<MediaDataDecoder> decoder;
@ -184,7 +184,7 @@ AppleDecoderModule::CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aC
already_AddRefed<MediaDataDecoder>
AppleDecoderModule::CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback)
{
nsRefPtr<MediaDataDecoder> decoder =

View File

@ -27,13 +27,13 @@ public:
CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
// Decode thread.
virtual already_AddRefed<MediaDataDecoder>
CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
virtual bool SupportsAudioMimeType(const char* aMimeType) MOZ_OVERRIDE;

View File

@ -32,7 +32,7 @@ PRLogModuleInfo* GetAppleMediaLog();
namespace mozilla {
AppleVDADecoder::AppleVDADecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback,
layers::ImageContainer* aImageContainer)
: mConfig(aConfig)
@ -495,7 +495,7 @@ AppleVDADecoder::CreateOutputConfiguration()
already_AddRefed<AppleVDADecoder>
AppleVDADecoder::CreateVDADecoder(
const mp4_demuxer::VideoDecoderConfig& aConfig,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback,
layers::ImageContainer* aImageContainer)
{

View File

@ -18,7 +18,7 @@
namespace mozilla {
class MediaTaskQueue;
class FlushableMediaTaskQueue;
class MediaDataDecoderCallback;
namespace layers {
class ImageContainer;
@ -61,12 +61,12 @@ public:
// not supported by current configuration.
static already_AddRefed<AppleVDADecoder> CreateVDADecoder(
const mp4_demuxer::VideoDecoderConfig& aConfig,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback,
layers::ImageContainer* aImageContainer);
AppleVDADecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback,
layers::ImageContainer* aImageContainer);
virtual ~AppleVDADecoder();
@ -86,7 +86,7 @@ public:
CFDictionaryRef CreateOutputConfiguration();
const mp4_demuxer::VideoDecoderConfig& mConfig;
nsRefPtr<MediaTaskQueue> mTaskQueue;
nsRefPtr<FlushableMediaTaskQueue> mTaskQueue;
MediaDataDecoderCallback* mCallback;
nsRefPtr<layers::ImageContainer> mImageContainer;
ReorderQueue mReorderQueue;

View File

@ -35,7 +35,7 @@ PRLogModuleInfo* GetAppleMediaLog();
namespace mozilla {
AppleVTDecoder::AppleVTDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback,
layers::ImageContainer* aImageContainer)
: AppleVDADecoder(aConfig, aVideoTaskQueue, aCallback, aImageContainer)

View File

@ -16,7 +16,7 @@ namespace mozilla {
class AppleVTDecoder : public AppleVDADecoder {
public:
AppleVTDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback,
layers::ImageContainer* aImageContainer);
virtual ~AppleVTDecoder();

View File

@ -25,7 +25,7 @@ public:
CDMProxy* aProxy)
: mDecoder(aDecoder)
, mCallback(aCallback)
, mTaskQueue(CreateMediaDecodeTaskQueue())
, mTaskQueue(CreateFlushableMediaDecodeTaskQueue())
, mProxy(aProxy)
, mSamplesWaitingForKey(new SamplesWaitingForKey(this, mTaskQueue, mProxy))
#ifdef DEBUG
@ -44,7 +44,7 @@ public:
class DeliverDecrypted : public DecryptionClient {
public:
DeliverDecrypted(EMEDecryptor* aDecryptor, MediaTaskQueue* aTaskQueue)
DeliverDecrypted(EMEDecryptor* aDecryptor, FlushableMediaTaskQueue* aTaskQueue)
: mDecryptor(aDecryptor)
, mTaskQueue(aTaskQueue)
{}
@ -73,7 +73,7 @@ public:
}
private:
nsRefPtr<EMEDecryptor> mDecryptor;
nsRefPtr<MediaTaskQueue> mTaskQueue;
nsRefPtr<FlushableMediaTaskQueue> mTaskQueue;
};
virtual nsresult Input(MP4Sample* aSample) MOZ_OVERRIDE {
@ -149,7 +149,7 @@ private:
nsRefPtr<MediaDataDecoder> mDecoder;
MediaDataDecoderCallback* mCallback;
nsRefPtr<MediaTaskQueue> mTaskQueue;
nsRefPtr<FlushableMediaTaskQueue> mTaskQueue;
nsRefPtr<CDMProxy> mProxy;
nsRefPtr<SamplesWaitingForKey> mSamplesWaitingForKey;
#ifdef DEBUG
@ -159,7 +159,7 @@ private:
class EMEMediaDataDecoderProxy : public MediaDataDecoderProxy {
public:
EMEMediaDataDecoderProxy(nsIThread* aProxyThread, MediaDataDecoderCallback* aCallback, CDMProxy* aProxy, MediaTaskQueue* aTaskQueue)
EMEMediaDataDecoderProxy(nsIThread* aProxyThread, MediaDataDecoderCallback* aCallback, CDMProxy* aProxy, FlushableMediaTaskQueue* aTaskQueue)
: MediaDataDecoderProxy(aProxyThread, aCallback)
, mSamplesWaitingForKey(new SamplesWaitingForKey(this, aTaskQueue, aProxy))
{
@ -218,7 +218,7 @@ EMEDecoderModule::Shutdown()
}
static already_AddRefed<MediaDataDecoderProxy>
CreateDecoderWrapper(MediaDataDecoderCallback* aCallback, CDMProxy* aProxy, MediaTaskQueue* aTaskQueue)
CreateDecoderWrapper(MediaDataDecoderCallback* aCallback, CDMProxy* aProxy, FlushableMediaTaskQueue* aTaskQueue)
{
nsCOMPtr<mozIGeckoMediaPluginService> gmpService = do_GetService("@mozilla.org/gecko-media-plugin-service;1");
if (!gmpService) {
@ -239,7 +239,7 @@ already_AddRefed<MediaDataDecoder>
EMEDecoderModule::CreateVideoDecoder(const VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback)
{
if (mCDMDecodesVideo && aConfig.crypto.valid) {
@ -274,7 +274,7 @@ EMEDecoderModule::CreateVideoDecoder(const VideoDecoderConfig& aConfig,
already_AddRefed<MediaDataDecoder>
EMEDecoderModule::CreateAudioDecoder(const AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback)
{
if (mCDMDecodesAudio && aConfig.crypto.valid) {

View File

@ -13,7 +13,7 @@
namespace mozilla {
class CDMProxy;
class MediaTaskQueue;
class FlushableMediaTaskQueue;
class EMEDecoderModule : public PlatformDecoderModule {
private:
@ -36,13 +36,13 @@ public:
CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
// Decode thread.
virtual already_AddRefed<MediaDataDecoder>
CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
virtual bool
@ -53,7 +53,7 @@ private:
// Will be null if CDM has decoding capability.
nsRefPtr<PlatformDecoderModule> mPDM;
// We run the PDM on its own task queue.
nsRefPtr<MediaTaskQueue> mTaskQueue;
nsRefPtr<FlushableMediaTaskQueue> mTaskQueue;
bool mCDMDecodesAudio;
bool mCDMDecodesVideo;

View File

@ -18,7 +18,7 @@ namespace mozilla
{
FFmpegAudioDecoder<LIBAV_VER>::FFmpegAudioDecoder(
MediaTaskQueue* aTaskQueue, MediaDataDecoderCallback* aCallback,
FlushableMediaTaskQueue* aTaskQueue, MediaDataDecoderCallback* aCallback,
const mp4_demuxer::AudioDecoderConfig& aConfig)
: FFmpegDataDecoder(aTaskQueue, GetCodecId(aConfig.mime_type))
, mCallback(aCallback)

View File

@ -21,7 +21,7 @@ template <>
class FFmpegAudioDecoder<LIBAV_VER> : public FFmpegDataDecoder<LIBAV_VER>
{
public:
FFmpegAudioDecoder(MediaTaskQueue* aTaskQueue,
FFmpegAudioDecoder(FlushableMediaTaskQueue* aTaskQueue,
MediaDataDecoderCallback* aCallback,
const mp4_demuxer::AudioDecoderConfig& aConfig);
virtual ~FFmpegAudioDecoder();

View File

@ -19,7 +19,7 @@ namespace mozilla
bool FFmpegDataDecoder<LIBAV_VER>::sFFmpegInitDone = false;
StaticMutex FFmpegDataDecoder<LIBAV_VER>::sMonitor;
FFmpegDataDecoder<LIBAV_VER>::FFmpegDataDecoder(MediaTaskQueue* aTaskQueue,
FFmpegDataDecoder<LIBAV_VER>::FFmpegDataDecoder(FlushableMediaTaskQueue* aTaskQueue,
AVCodecID aCodecID)
: mTaskQueue(aTaskQueue)
, mCodecContext(nullptr)

View File

@ -24,7 +24,7 @@ template <>
class FFmpegDataDecoder<LIBAV_VER> : public MediaDataDecoder
{
public:
FFmpegDataDecoder(MediaTaskQueue* aTaskQueue, AVCodecID aCodecID);
FFmpegDataDecoder(FlushableMediaTaskQueue* aTaskQueue, AVCodecID aCodecID);
virtual ~FFmpegDataDecoder();
static bool Link();
@ -38,7 +38,7 @@ public:
protected:
AVFrame* PrepareFrame();
MediaTaskQueue* mTaskQueue;
FlushableMediaTaskQueue* mTaskQueue;
AVCodecContext* mCodecContext;
AVFrame* mFrame;
nsRefPtr<mp4_demuxer::ByteBuffer> mExtraData;

View File

@ -34,7 +34,7 @@ public:
CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE
{
nsRefPtr<MediaDataDecoder> decoder =
@ -45,7 +45,7 @@ public:
virtual already_AddRefed<MediaDataDecoder>
CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE
{
nsRefPtr<MediaDataDecoder> decoder =

View File

@ -25,7 +25,7 @@ namespace mozilla
{
FFmpegH264Decoder<LIBAV_VER>::FFmpegH264Decoder(
MediaTaskQueue* aTaskQueue, MediaDataDecoderCallback* aCallback,
FlushableMediaTaskQueue* aTaskQueue, MediaDataDecoderCallback* aCallback,
const mp4_demuxer::VideoDecoderConfig& aConfig,
ImageContainer* aImageContainer)
: FFmpegDataDecoder(aTaskQueue, GetCodecId(aConfig.mime_type))

View File

@ -30,7 +30,7 @@ class FFmpegH264Decoder<LIBAV_VER> : public FFmpegDataDecoder<LIBAV_VER>
};
public:
FFmpegH264Decoder(MediaTaskQueue* aTaskQueue,
FFmpegH264Decoder(FlushableMediaTaskQueue* aTaskQueue,
MediaDataDecoderCallback* aCallback,
const mp4_demuxer::VideoDecoderConfig& aConfig,
ImageContainer* aImageContainer);

View File

@ -49,7 +49,7 @@ already_AddRefed<MediaDataDecoder>
GMPDecoderModule::CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback)
{
if (strcmp(aConfig.mime_type, "video/avc") != 0) {
@ -67,7 +67,7 @@ GMPDecoderModule::CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aCon
already_AddRefed<MediaDataDecoder>
GMPDecoderModule::CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback)
{
if (strcmp(aConfig.mime_type, "audio/mp4a-latm") != 0) {

View File

@ -25,13 +25,13 @@ public:
CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
// Decode thread.
virtual already_AddRefed<MediaDataDecoder>
CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
virtual bool DecoderNeedsAVCC(const mp4_demuxer::VideoDecoderConfig& aConfig) MOZ_OVERRIDE;

View File

@ -36,7 +36,7 @@ already_AddRefed<MediaDataDecoder>
GonkDecoderModule::CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
mozilla::layers::LayersBackend aLayersBackend,
mozilla::layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback)
{
nsRefPtr<MediaDataDecoder> decoder =
@ -48,7 +48,7 @@ GonkDecoderModule::CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aCo
already_AddRefed<MediaDataDecoder>
GonkDecoderModule::CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback)
{
nsRefPtr<MediaDataDecoder> decoder =

View File

@ -24,13 +24,13 @@ public:
CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
mozilla::layers::LayersBackend aLayersBackend,
mozilla::layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
// Decode thread.
virtual already_AddRefed<MediaDataDecoder>
CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
static void Init();

View File

@ -117,7 +117,7 @@ GonkDecoderManager::Flush()
}
GonkMediaDataDecoder::GonkMediaDataDecoder(GonkDecoderManager* aManager,
MediaTaskQueue* aTaskQueue,
FlushableMediaTaskQueue* aTaskQueue,
MediaDataDecoderCallback* aCallback)
: mTaskQueue(aTaskQueue)
, mCallback(aCallback)

View File

@ -83,7 +83,7 @@ protected:
class GonkMediaDataDecoder : public MediaDataDecoder {
public:
GonkMediaDataDecoder(GonkDecoderManager* aDecoderManager,
MediaTaskQueue* aTaskQueue,
FlushableMediaTaskQueue* aTaskQueue,
MediaDataDecoderCallback* aCallback);
~GonkMediaDataDecoder();
@ -122,7 +122,7 @@ private:
// all available output.
void ProcessDrain();
RefPtr<MediaTaskQueue> mTaskQueue;
RefPtr<FlushableMediaTaskQueue> mTaskQueue;
MediaDataDecoderCallback* mCallback;
android::sp<android::MediaCodecProxy> mDecoder;

View File

@ -68,7 +68,7 @@ already_AddRefed<MediaDataDecoder>
WMFDecoderModule::CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback)
{
nsRefPtr<MediaDataDecoder> decoder =
@ -83,7 +83,7 @@ WMFDecoderModule::CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aCon
already_AddRefed<MediaDataDecoder>
WMFDecoderModule::CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback)
{
nsRefPtr<MediaDataDecoder> decoder =

View File

@ -26,12 +26,12 @@ public:
CreateVideoDecoder(const mp4_demuxer::VideoDecoderConfig& aConfig,
layers::LayersBackend aLayersBackend,
layers::ImageContainer* aImageContainer,
MediaTaskQueue* aVideoTaskQueue,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
virtual already_AddRefed<MediaDataDecoder>
CreateAudioDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE;
bool SupportsVideoMimeType(const char* aMimeType) MOZ_OVERRIDE;

View File

@ -22,7 +22,7 @@ PRLogModuleInfo* GetDemuxerLog();
namespace mozilla {
WMFMediaDataDecoder::WMFMediaDataDecoder(MFTManager* aMFTManager,
MediaTaskQueue* aTaskQueue,
FlushableMediaTaskQueue* aTaskQueue,
MediaDataDecoderCallback* aCallback)
: mTaskQueue(aTaskQueue)
, mCallback(aCallback)

View File

@ -59,7 +59,7 @@ public:
class WMFMediaDataDecoder : public MediaDataDecoder {
public:
WMFMediaDataDecoder(MFTManager* aOutputSource,
MediaTaskQueue* aAudioTaskQueue,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback);
~WMFMediaDataDecoder();
@ -97,7 +97,7 @@ private:
void ProcessShutdown();
void ProcessReleaseDecoder();
RefPtr<MediaTaskQueue> mTaskQueue;
RefPtr<FlushableMediaTaskQueue> mTaskQueue;
MediaDataDecoderCallback* mCallback;
RefPtr<MFTDecoder> mDecoder;

View File

@ -61,7 +61,7 @@ private:
RefPtr<MFTDecoder> mDecoder;
RefPtr<layers::ImageContainer> mImageContainer;
nsAutoPtr<DXVA2Manager> mDXVA2Manager;
RefPtr<MediaTaskQueue> mTaskQueue;
RefPtr<FlushableMediaTaskQueue> mTaskQueue;
MediaDataDecoderCallback* mCallback;
const bool mDXVAEnabled;

View File

@ -1306,12 +1306,12 @@ MediaCodecReader::CreateTaskQueues()
{
if (mAudioTrack.mSource != nullptr && mAudioTrack.mCodec != nullptr &&
!mAudioTrack.mTaskQueue) {
mAudioTrack.mTaskQueue = CreateMediaDecodeTaskQueue();
mAudioTrack.mTaskQueue = CreateFlushableMediaDecodeTaskQueue();
NS_ENSURE_TRUE(mAudioTrack.mTaskQueue, false);
}
if (mVideoTrack.mSource != nullptr && mVideoTrack.mCodec != nullptr &&
!mVideoTrack.mTaskQueue) {
mVideoTrack.mTaskQueue = CreateMediaDecodeTaskQueue();
mVideoTrack.mTaskQueue = CreateFlushableMediaDecodeTaskQueue();
NS_ENSURE_TRUE(mVideoTrack.mTaskQueue, false);
mVideoTrack.mReleaseBufferTaskQueue = CreateMediaDecodeTaskQueue();
NS_ENSURE_TRUE(mVideoTrack.mReleaseBufferTaskQueue, false);

View File

@ -41,7 +41,7 @@ class GonkNativeWindow;
namespace mozilla {
class MediaTaskQueue;
class FlushableMediaTaskQueue;
class MP3FrameParser;
namespace layers {
@ -164,7 +164,7 @@ protected:
int64_t mSeekTimeUs;
bool mFlushed; // meaningless when mSeekTimeUs is invalid.
bool mDiscontinuity;
nsRefPtr<MediaTaskQueue> mTaskQueue;
nsRefPtr<FlushableMediaTaskQueue> mTaskQueue;
Monitor mTrackMonitor;
private:

View File

@ -64,7 +64,7 @@ private:
// TaskQueue on which decoder can choose to decode.
// Only non-null up until the decoder is created.
nsRefPtr<MediaTaskQueue> mTaskQueue;
nsRefPtr<FlushableMediaTaskQueue> mTaskQueue;
// Monitor that protects all non-threadsafe state; the primitives
// that follow.

View File

@ -249,7 +249,7 @@ nsresult WebMReader::Init(MediaDecoderReader* aCloneDonor)
InitLayersBackendType();
mVideoTaskQueue = new MediaTaskQueue(
mVideoTaskQueue = new FlushableMediaTaskQueue(
SharedThreadPool::Get(NS_LITERAL_CSTRING("IntelVP8 Video Decode")));
NS_ENSURE_TRUE(mVideoTaskQueue, NS_ERROR_FAILURE);
}

View File

@ -186,7 +186,7 @@ public:
uint64_t GetLastVideoFrameTime();
void SetLastVideoFrameTime(uint64_t aFrameTime);
layers::LayersBackend GetLayersBackendType() { return mLayersBackendType; }
MediaTaskQueue* GetVideoTaskQueue() { return mVideoTaskQueue; }
FlushableMediaTaskQueue* GetVideoTaskQueue() { return mVideoTaskQueue; }
protected:
// Setup opus decoder
@ -277,7 +277,7 @@ private:
layers::LayersBackend mLayersBackendType;
// For hardware video decoding.
nsRefPtr<MediaTaskQueue> mVideoTaskQueue;
nsRefPtr<FlushableMediaTaskQueue> mVideoTaskQueue;
// Booleans to indicate if we have audio and/or video data
bool mHasVideo;