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 6a5aeadf46
commit 54a90d1df5
7 changed files with 15 additions and 16 deletions

View File

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

View File

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

View File

@ -197,9 +197,9 @@ IsValidVideoRegion(const nsIntSize& aFrame, const nsIntRect& aPicture,
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));
}
@ -301,7 +301,7 @@ class CreateTaskQueueTask : public nsRunnable {
public:
NS_IMETHOD Run() {
MOZ_ASSERT(NS_IsMainThread());
mTaskQueue = new MediaTaskQueue(GetMediaDecodeThreadPool());
mTaskQueue = new MediaTaskQueue(GetMediaThreadPool());
return NS_OK;
}
nsRefPtr<MediaTaskQueue> mTaskQueue;
@ -311,7 +311,7 @@ class CreateFlushableTaskQueueTask : public nsRunnable {
public:
NS_IMETHOD Run() {
MOZ_ASSERT(NS_IsMainThread());
mTaskQueue = new FlushableMediaTaskQueue(GetMediaDecodeThreadPool());
mTaskQueue = new FlushableMediaTaskQueue(GetMediaThreadPool());
return NS_OK;
}
nsRefPtr<FlushableMediaTaskQueue> mTaskQueue;

View File

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

View File

@ -250,10 +250,10 @@ MP4Reader::Init(MediaDecoderReader* aCloneDonor)
InitLayersBackendType();
mAudio.mTaskQueue = new FlushableMediaTaskQueue(GetMediaDecodeThreadPool());
mAudio.mTaskQueue = new FlushableMediaTaskQueue(GetMediaThreadPool());
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);
static bool sSetupPrefCache = false;

View File

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

View File

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