0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00

win-mf: Drain events before releasing encoder

After I made it so that the encoder internal data gets destroyed when
all outputs stop using it (fa7286f8), the media foundation h264 encoder
started having crashes on shutdown.  After a lot of testing, I realized
that the reason it started happening is almost assuredly because active
encoding events had not yet been completed.

After making it wait on those events by calling DrainEvents(true), the
crashes stopped.  So asynchronous actions were clearly still occurring
and it was shutting down while data was still being processed, thus
leading to a crash.
This commit is contained in:
jp9000 2015-09-16 19:20:32 -07:00
parent 7788ccdd86
commit 672378d202

View File

@ -70,7 +70,12 @@ H264Encoder::H264Encoder(const obs_encoder_t *encoder,
{}
H264Encoder::~H264Encoder()
{}
{
// Make sure all events have finished before releasing.
// If you do not do this, you risk it releasing while there's still
// encoder activity, which can cause a crash with certain interfaces.
DrainEvent(true);
}
HRESULT H264Encoder::CreateMediaTypes(ComPtr<IMFMediaType> &i,
ComPtr<IMFMediaType> &o)