mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-06-09 01:48:55 +00:00
4b50ae13c8
The DrainComplete() caught with mWaitForInternalDrain still won't necessarily be from the internal Drain(), but all we need is that one DrainComplete() is caught for the internal Drain() because one more will be generated if there is a Drain() in progress. What protecting mWaitForInternalDrain access with the monitor provides here is that the compiler won't use its address for storage of other data meaningless in the context of mWaitForInternalDrain and so, for example, two DrainComplete() calls won't unintentionally think that they are both for one internal drain.
89 lines
2.5 KiB
C++
89 lines
2.5 KiB
C++
/* -*- 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/. */
|
|
|
|
#ifndef SHARED_DECODER_MANAGER_H_
|
|
#define SHARED_DECODER_MANAGER_H_
|
|
|
|
#include "PlatformDecoderModule.h"
|
|
#include "mozilla/Monitor.h"
|
|
|
|
namespace mozilla
|
|
{
|
|
|
|
class MediaDataDecoder;
|
|
class SharedDecoderProxy;
|
|
class SharedDecoderCallback;
|
|
|
|
class SharedDecoderManager
|
|
{
|
|
public:
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SharedDecoderManager)
|
|
|
|
SharedDecoderManager();
|
|
|
|
already_AddRefed<MediaDataDecoder> CreateVideoDecoder(
|
|
PlatformDecoderModule* aPDM,
|
|
const VideoInfo& aConfig,
|
|
layers::LayersBackend aLayersBackend,
|
|
layers::ImageContainer* aImageContainer,
|
|
FlushableMediaTaskQueue* aVideoTaskQueue,
|
|
MediaDataDecoderCallback* aCallback);
|
|
|
|
void SetReader(MediaDecoderReader* aReader);
|
|
void Select(SharedDecoderProxy* aProxy);
|
|
void SetIdle(MediaDataDecoder* aProxy);
|
|
void ReleaseMediaResources();
|
|
void Shutdown();
|
|
|
|
friend class SharedDecoderProxy;
|
|
friend class SharedDecoderCallback;
|
|
|
|
void DisableHardwareAcceleration();
|
|
bool Recreate(const VideoInfo& aConfig);
|
|
|
|
private:
|
|
virtual ~SharedDecoderManager();
|
|
void DrainComplete();
|
|
|
|
nsRefPtr<PlatformDecoderModule> mPDM;
|
|
nsRefPtr<MediaDataDecoder> mDecoder;
|
|
layers::LayersBackend mLayersBackend;
|
|
nsRefPtr<layers::ImageContainer> mImageContainer;
|
|
nsRefPtr<FlushableMediaTaskQueue> mTaskQueue;
|
|
SharedDecoderProxy* mActiveProxy;
|
|
MediaDataDecoderCallback* mActiveCallback;
|
|
nsAutoPtr<MediaDataDecoderCallback> mCallback;
|
|
// access protected by mMonitor
|
|
bool mWaitForInternalDrain;
|
|
Monitor mMonitor;
|
|
bool mDecoderReleasedResources;
|
|
};
|
|
|
|
class SharedDecoderProxy : public MediaDataDecoder
|
|
{
|
|
public:
|
|
SharedDecoderProxy(SharedDecoderManager* aManager,
|
|
MediaDataDecoderCallback* aCallback);
|
|
virtual ~SharedDecoderProxy();
|
|
|
|
virtual nsresult Init() override;
|
|
virtual nsresult Input(MediaRawData* aSample) override;
|
|
virtual nsresult Flush() override;
|
|
virtual nsresult Drain() override;
|
|
virtual nsresult Shutdown() override;
|
|
virtual bool IsWaitingMediaResources() override;
|
|
virtual bool IsHardwareAccelerated() const override;
|
|
|
|
friend class SharedDecoderManager;
|
|
|
|
private:
|
|
nsRefPtr<SharedDecoderManager> mManager;
|
|
MediaDataDecoderCallback* mCallback;
|
|
};
|
|
}
|
|
|
|
#endif
|