From 197e95a345b364adc534aa8207158eb932852ad4 Mon Sep 17 00:00:00 2001 From: John Lin Date: Wed, 4 Nov 2020 21:57:40 +0000 Subject: [PATCH] Bug 1640416 - p5: run WebrtcMediaDataEncoder and the platform encoder in different thread pools/task queues. r=alwu Some WebrtcMediaDataEncoder methods are blocking and wait for platform encoder operations to complete. Running them in one thread pool/task queue will lead to dead lock. Differential Revision: https://phabricator.services.mozilla.com/D94464 --- .../webrtc/libwebrtcglue/WebrtcMediaDataEncoderCodec.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dom/media/webrtc/libwebrtcglue/WebrtcMediaDataEncoderCodec.cpp b/dom/media/webrtc/libwebrtcglue/WebrtcMediaDataEncoderCodec.cpp index 832f0597dd60..543804c04ee5 100644 --- a/dom/media/webrtc/libwebrtcglue/WebrtcMediaDataEncoderCodec.cpp +++ b/dom/media/webrtc/libwebrtcglue/WebrtcMediaDataEncoderCodec.cpp @@ -77,7 +77,7 @@ static MediaDataEncoder::H264Specific GetCodecSpecific( WebrtcMediaDataEncoder::WebrtcMediaDataEncoder() : mCallbackMutex("WebrtcMediaDataEncoderCodec encoded callback mutex"), - mThreadPool(GetMediaThreadPool(MediaThreadType::PLATFORM_ENCODER)), + mThreadPool(GetMediaThreadPool(MediaThreadType::SUPERVISOR)), mTaskQueue(new TaskQueue(do_AddRef(mThreadPool), "WebrtcMediaDataEncoder::mTaskQueue")), mFactory(new PEMFactory()), @@ -101,7 +101,7 @@ int32_t WebrtcMediaDataEncoder::InitEncode( if (!CreateEncoder(aCodecSettings)) { return WEBRTC_VIDEO_CODEC_ERROR; } - LOG("Init decode, mimeType %s, mode %s", mInfo.mMimeType.get(), + LOG("Init encode, mimeType %s, mode %s", mInfo.mMimeType.get(), GetModeName(mMode)); return InitEncoder() ? WEBRTC_VIDEO_CODEC_OK : WEBRTC_VIDEO_CODEC_ERROR; } @@ -140,7 +140,10 @@ bool WebrtcMediaDataEncoder::CreateEncoder( mInfo.mMimeType.get(), mBitrateAdjuster.GetTargetBitrateBps(), aCodecSettings->maxFramerate); mEncoder = mFactory->CreateEncoder(CreateEncoderParams( - mInfo, MediaDataEncoder::Usage::Realtime, mTaskQueue, + mInfo, MediaDataEncoder::Usage::Realtime, + MakeRefPtr( + GetMediaThreadPool(MediaThreadType::PLATFORM_ENCODER), + "WebrtcMediaDataEncoder::mEncoder"), MediaDataEncoder::PixelFormat::YUV420P, aCodecSettings->maxFramerate, mBitrateAdjuster.GetTargetBitrateBps(), GetCodecSpecific(aCodecSettings)));