Skip to content

Commit f274ff1

Browse files
taste1981jianjunz
authored andcommitted
Fix Windows client crash on shared application window resizing. (open-webrtc-toolkit#235)
1 parent 77b613b commit f274ff1

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

talk/owt/sdk/base/win/msdkvideoencoder.cc

+22-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ int MSDKVideoEncoder::InitEncodeOnEncoderThread(
145145
}
146146

147147
// Create frame allocator, let the allocator create the param of its own
148-
m_pMFXAllocator = m_pMFXAllocator = MSDKFactory::CreateFrameAllocator();
148+
m_pMFXAllocator = MSDKFactory::CreateFrameAllocator();
149149
if (nullptr == m_pMFXAllocator) {
150150
return WEBRTC_VIDEO_CODEC_ERROR;
151151
}
@@ -163,6 +163,7 @@ int MSDKVideoEncoder::InitEncodeOnEncoderThread(
163163

164164
// Init the encoding params:
165165
MSDK_ZERO_MEMORY(m_mfxEncParams);
166+
m_EncExtParams.clear();
166167
m_mfxEncParams.mfx.CodecId = codec_id;
167168
m_mfxEncParams.mfx.TargetUsage = MFX_TARGETUSAGE_BALANCED;
168169
m_mfxEncParams.mfx.TargetKbps = codec_settings->maxBitrate; // in-kbps
@@ -631,7 +632,26 @@ webrtc::VideoEncoder::EncoderInfo MSDKVideoEncoder::GetEncoderInfo() const {
631632
}
632633

633634
int MSDKVideoEncoder::Release() {
634-
callback_ = nullptr;
635+
if (m_pmfxENC != nullptr) {
636+
m_pmfxENC->Close();
637+
delete m_pmfxENC;
638+
m_pmfxENC = nullptr;
639+
}
640+
MSDK_SAFE_DELETE_ARRAY(m_pEncSurfaces);
641+
m_pEncSurfaces = nullptr;
642+
643+
if (m_mfxSession) {
644+
MSDKFactory* factory = MSDKFactory::Get();
645+
if (factory) {
646+
factory->UnloadMSDKPlugin(m_mfxSession, &m_pluginID);
647+
factory->DestroySession(m_mfxSession);
648+
}
649+
m_mfxSession = nullptr;
650+
}
651+
if (m_pMFXAllocator)
652+
m_pMFXAllocator->Close();
653+
m_pMFXAllocator.reset();
654+
635655
inited_ = false;
636656
// Need to reset to that the session is invalidated and won't use the
637657
// callback anymore.

0 commit comments

Comments
 (0)