Skip to content

Commit

Permalink
Fixed a memory leak in video encoder, due to improper shutdown of IMF…
Browse files Browse the repository at this point in the history
…SinkWriter.
  • Loading branch information
sskodje committed Feb 4, 2023
1 parent 945be22 commit 4423c27
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ScreenRecorderLibNative/OutputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ HRESULT OutputManager::FinalizeRecording()
//Dispose of MPEG4MediaSink
IMFMediaSink *pSink;
if (SUCCEEDED(m_SinkWriter->GetServiceForStream(MF_SINK_WRITER_MEDIASINK, GUID_NULL, IID_PPV_ARGS(&pSink)))) {
//Release the sink writer before calling Shutdown on the media sink.
//https://learn.microsoft.com/en-us/windows/win32/api/mfreadwrite/nf-mfreadwrite-mfcreatesinkwriterfrommediasink
m_SinkWriter.Release();
finalizeResult = pSink->Shutdown();
SafeRelease(&pSink);
if (FAILED(finalizeResult)) {
LOG_ERROR("Failed to shut down IMFMediaSink");
}
Expand Down

0 comments on commit 4423c27

Please sign in to comment.