Bug 1142336 - Create one unified thread pool for media code and run the MDSM task queues on it. r=mattwoodrow

This allows for parallel MDSM execution. \o/
This commit is contained in:
Bobby Holley 2015-03-17 14:02:33 -07:00
parent 57e69d0f6b
commit 3d7cf9b65a
7 changed files with 15 additions and 16 deletions

View File

@ -356,10 +356,9 @@ MediaDecoderReader::EnsureTaskQueue()
{ {
if (!mTaskQueue) { if (!mTaskQueue) {
MOZ_ASSERT(!mTaskQueueIsBorrowed); MOZ_ASSERT(!mTaskQueueIsBorrowed);
RefPtr<SharedThreadPool> decodePool(GetMediaDecodeThreadPool()); RefPtr<SharedThreadPool> pool(GetMediaThreadPool());
NS_ENSURE_TRUE(decodePool, nullptr); MOZ_DIAGNOSTIC_ASSERT(pool);
mTaskQueue = new MediaTaskQueue(pool.forget());
mTaskQueue = new MediaTaskQueue(decodePool.forget());
} }
return mTaskQueue; return mTaskQueue;

View File

@ -249,9 +249,9 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread."); NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
// Set up our task queue. // Set up our task queue.
RefPtr<SharedThreadPool> threadPool( RefPtr<SharedThreadPool> pool(GetMediaThreadPool());
SharedThreadPool::Get(NS_LITERAL_CSTRING("Media State Machine"), 1)); MOZ_DIAGNOSTIC_ASSERT(pool);
mTaskQueue = new MediaTaskQueue(threadPool.forget()); mTaskQueue = new MediaTaskQueue(pool.forget());
static bool sPrefCacheInit = false; static bool sPrefCacheInit = false;
if (!sPrefCacheInit) { if (!sPrefCacheInit) {

View File

@ -197,9 +197,9 @@ IsValidVideoRegion(const nsIntSize& aFrame, const nsIntRect& aPicture,
aDisplay.width * aDisplay.height != 0; aDisplay.width * aDisplay.height != 0;
} }
TemporaryRef<SharedThreadPool> GetMediaDecodeThreadPool() TemporaryRef<SharedThreadPool> GetMediaThreadPool()
{ {
return SharedThreadPool::Get(NS_LITERAL_CSTRING("Media Decode"), return SharedThreadPool::Get(NS_LITERAL_CSTRING("Media Playback"),
Preferences::GetUint("media.num-decode-threads", 25)); Preferences::GetUint("media.num-decode-threads", 25));
} }
@ -301,7 +301,7 @@ class CreateTaskQueueTask : public nsRunnable {
public: public:
NS_IMETHOD Run() { NS_IMETHOD Run() {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
mTaskQueue = new MediaTaskQueue(GetMediaDecodeThreadPool()); mTaskQueue = new MediaTaskQueue(GetMediaThreadPool());
return NS_OK; return NS_OK;
} }
nsRefPtr<MediaTaskQueue> mTaskQueue; nsRefPtr<MediaTaskQueue> mTaskQueue;
@ -311,7 +311,7 @@ class CreateFlushableTaskQueueTask : public nsRunnable {
public: public:
NS_IMETHOD Run() { NS_IMETHOD Run() {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
mTaskQueue = new FlushableMediaTaskQueue(GetMediaDecodeThreadPool()); mTaskQueue = new FlushableMediaTaskQueue(GetMediaThreadPool());
return NS_OK; return NS_OK;
} }
nsRefPtr<FlushableMediaTaskQueue> mTaskQueue; nsRefPtr<FlushableMediaTaskQueue> mTaskQueue;

View File

@ -219,7 +219,7 @@ class SharedThreadPool;
// Returns the thread pool that is shared amongst all decoder state machines // Returns the thread pool that is shared amongst all decoder state machines
// for decoding streams. // for decoding streams.
TemporaryRef<SharedThreadPool> GetMediaDecodeThreadPool(); TemporaryRef<SharedThreadPool> GetMediaThreadPool();
enum H264_PROFILE { enum H264_PROFILE {
H264_PROFILE_UNKNOWN = 0, H264_PROFILE_UNKNOWN = 0,

View File

@ -248,10 +248,10 @@ MP4Reader::Init(MediaDecoderReader* aCloneDonor)
InitLayersBackendType(); InitLayersBackendType();
mAudio.mTaskQueue = new FlushableMediaTaskQueue(GetMediaDecodeThreadPool()); mAudio.mTaskQueue = new FlushableMediaTaskQueue(GetMediaThreadPool());
NS_ENSURE_TRUE(mAudio.mTaskQueue, NS_ERROR_FAILURE); NS_ENSURE_TRUE(mAudio.mTaskQueue, NS_ERROR_FAILURE);
mVideo.mTaskQueue = new FlushableMediaTaskQueue(GetMediaDecodeThreadPool()); mVideo.mTaskQueue = new FlushableMediaTaskQueue(GetMediaThreadPool());
NS_ENSURE_TRUE(mVideo.mTaskQueue, NS_ERROR_FAILURE); NS_ENSURE_TRUE(mVideo.mTaskQueue, NS_ERROR_FAILURE);
static bool sSetupPrefCache = false; static bool sSetupPrefCache = false;

View File

@ -58,7 +58,7 @@ public:
}; };
SharedDecoderManager::SharedDecoderManager() SharedDecoderManager::SharedDecoderManager()
: mTaskQueue(new FlushableMediaTaskQueue(GetMediaDecodeThreadPool())) : mTaskQueue(new FlushableMediaTaskQueue(GetMediaThreadPool()))
, mActiveProxy(nullptr) , mActiveProxy(nullptr)
, mActiveCallback(nullptr) , mActiveCallback(nullptr)
, mWaitForInternalDrain(false) , mWaitForInternalDrain(false)

View File

@ -52,7 +52,7 @@ TrackBuffer::TrackBuffer(MediaSourceDecoder* aParentDecoder, const nsACString& a
{ {
MOZ_COUNT_CTOR(TrackBuffer); MOZ_COUNT_CTOR(TrackBuffer);
mParser = ContainerParser::CreateForMIMEType(aType); mParser = ContainerParser::CreateForMIMEType(aType);
mTaskQueue = new MediaTaskQueue(GetMediaDecodeThreadPool()); mTaskQueue = new MediaTaskQueue(GetMediaThreadPool());
aParentDecoder->AddTrackBuffer(this); aParentDecoder->AddTrackBuffer(this);
mDecoderPerSegment = Preferences::GetBool("media.mediasource.decoder-per-segment", false); mDecoderPerSegment = Preferences::GetBool("media.mediasource.decoder-per-segment", false);
MSE_DEBUG("TrackBuffer created for parent decoder %p", aParentDecoder); MSE_DEBUG("TrackBuffer created for parent decoder %p", aParentDecoder);