mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 1161892 use separate thread pool for platform decoder task queues r=bholley
so that platform decoder tasks will run when their readers wait and block their thread pool.
This commit is contained in:
parent
3b4861b3b4
commit
afba938cae
@ -344,7 +344,7 @@ MediaDecoderReader::EnsureTaskQueue()
|
||||
{
|
||||
if (!mTaskQueue) {
|
||||
MOZ_ASSERT(!mTaskQueueIsBorrowed);
|
||||
RefPtr<SharedThreadPool> pool(GetMediaThreadPool());
|
||||
RefPtr<SharedThreadPool> pool(GetMediaThreadPool(MediaThreadType::PLAYBACK));
|
||||
MOZ_DIAGNOSTIC_ASSERT(pool);
|
||||
mTaskQueue = new MediaTaskQueue(pool.forget());
|
||||
}
|
||||
|
@ -202,7 +202,8 @@ MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
|
||||
MediaDecoderReader* aReader,
|
||||
bool aRealTime) :
|
||||
mDecoder(aDecoder),
|
||||
mTaskQueue(new MediaTaskQueue(GetMediaThreadPool(), /* aAssertTailDispatch = */ true)),
|
||||
mTaskQueue(new MediaTaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK),
|
||||
/* aAssertTailDispatch = */ true)),
|
||||
mWatchManager(this, mTaskQueue),
|
||||
mRealTime(aRealTime),
|
||||
mDispatchedStateMachine(false),
|
||||
|
@ -197,10 +197,22 @@ IsValidVideoRegion(const nsIntSize& aFrame, const nsIntRect& aPicture,
|
||||
aDisplay.width * aDisplay.height != 0;
|
||||
}
|
||||
|
||||
TemporaryRef<SharedThreadPool> GetMediaThreadPool()
|
||||
TemporaryRef<SharedThreadPool> GetMediaThreadPool(MediaThreadType aType)
|
||||
{
|
||||
return SharedThreadPool::Get(NS_LITERAL_CSTRING("Media Playback"),
|
||||
Preferences::GetUint("media.num-decode-threads", 25));
|
||||
const char *name;
|
||||
switch (aType) {
|
||||
case MediaThreadType::PLATFORM_DECODER:
|
||||
name = "MediaPDecoder";
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT(false);
|
||||
case MediaThreadType::PLAYBACK:
|
||||
name = "MediaPlayback";
|
||||
break;
|
||||
}
|
||||
return SharedThreadPool::
|
||||
Get(nsDependentCString(name),
|
||||
Preferences::GetUint("media.num-decode-threads", 12));
|
||||
}
|
||||
|
||||
bool
|
||||
@ -304,7 +316,8 @@ class CreateTaskQueueTask : public nsRunnable {
|
||||
public:
|
||||
NS_IMETHOD Run() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mTaskQueue = new MediaTaskQueue(GetMediaThreadPool());
|
||||
mTaskQueue =
|
||||
new MediaTaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER));
|
||||
return NS_OK;
|
||||
}
|
||||
nsRefPtr<MediaTaskQueue> mTaskQueue;
|
||||
@ -314,7 +327,8 @@ class CreateFlushableTaskQueueTask : public nsRunnable {
|
||||
public:
|
||||
NS_IMETHOD Run() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mTaskQueue = new FlushableMediaTaskQueue(GetMediaThreadPool());
|
||||
mTaskQueue =
|
||||
new FlushableMediaTaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER));
|
||||
return NS_OK;
|
||||
}
|
||||
nsRefPtr<FlushableMediaTaskQueue> mTaskQueue;
|
||||
|
@ -216,9 +216,22 @@ private:
|
||||
|
||||
class SharedThreadPool;
|
||||
|
||||
// The MediaDataDecoder API blocks, with implementations waiting on platform
|
||||
// decoder tasks. These platform decoder tasks are queued on a separate
|
||||
// thread pool to ensure they can run when the MediaDataDecoder clients'
|
||||
// thread pool is blocked. Tasks on the PLATFORM_DECODER thread pool must not
|
||||
// wait on tasks in the PLAYBACK thread pool.
|
||||
//
|
||||
// No new dependencies on this mechanism should be added, as methods are being
|
||||
// made async supported by MediaPromise, making this unnecessary and
|
||||
// permitting unifying the pool.
|
||||
enum class MediaThreadType {
|
||||
PLAYBACK, // MediaDecoderStateMachine and MediaDecoderReader
|
||||
PLATFORM_DECODER
|
||||
};
|
||||
// Returns the thread pool that is shared amongst all decoder state machines
|
||||
// for decoding streams.
|
||||
TemporaryRef<SharedThreadPool> GetMediaThreadPool();
|
||||
TemporaryRef<SharedThreadPool> GetMediaThreadPool(MediaThreadType aType);
|
||||
|
||||
enum H264_PROFILE {
|
||||
H264_PROFILE_UNKNOWN = 0,
|
||||
|
@ -289,10 +289,12 @@ MP4Reader::Init(MediaDecoderReader* aCloneDonor)
|
||||
|
||||
InitLayersBackendType();
|
||||
|
||||
mAudio.mTaskQueue = new FlushableMediaTaskQueue(GetMediaThreadPool());
|
||||
mAudio.mTaskQueue =
|
||||
new FlushableMediaTaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER));
|
||||
NS_ENSURE_TRUE(mAudio.mTaskQueue, NS_ERROR_FAILURE);
|
||||
|
||||
mVideo.mTaskQueue = new FlushableMediaTaskQueue(GetMediaThreadPool());
|
||||
mVideo.mTaskQueue =
|
||||
new FlushableMediaTaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER));
|
||||
NS_ENSURE_TRUE(mVideo.mTaskQueue, NS_ERROR_FAILURE);
|
||||
|
||||
static bool sSetupPrefCache = false;
|
||||
|
@ -77,7 +77,7 @@ private:
|
||||
};
|
||||
|
||||
SharedDecoderManager::SharedDecoderManager()
|
||||
: mTaskQueue(new FlushableMediaTaskQueue(GetMediaThreadPool()))
|
||||
: mTaskQueue(new FlushableMediaTaskQueue(GetMediaThreadPool(MediaThreadType::PLATFORM_DECODER)))
|
||||
, mActiveProxy(nullptr)
|
||||
, mActiveCallback(nullptr)
|
||||
, mWaitForInternalDrain(false)
|
||||
|
@ -53,7 +53,8 @@ TrackBuffer::TrackBuffer(MediaSourceDecoder* aParentDecoder, const nsACString& a
|
||||
{
|
||||
MOZ_COUNT_CTOR(TrackBuffer);
|
||||
mParser = ContainerParser::CreateForMIMEType(aType);
|
||||
mTaskQueue = new MediaTaskQueue(GetMediaThreadPool());
|
||||
mTaskQueue =
|
||||
new MediaTaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK));
|
||||
aParentDecoder->AddTrackBuffer(this);
|
||||
mDecoderPerSegment = Preferences::GetBool("media.mediasource.decoder-per-segment", false);
|
||||
MSE_DEBUG("TrackBuffer created for parent decoder %p", aParentDecoder);
|
||||
|
Loading…
Reference in New Issue
Block a user