Mpeg: Close codecs from new streams.

These were actually leaking.
This commit is contained in:
Unknown W. Brackets committed 2023-01-07 06:44:02 -08:00
1 parent 3cd882f21b
commit 94bab4506f
2 files changed
+12

No files matched your search

+7
View File
@@ -380,6 +380,11 @@ void MediaEngine::closeContext()
#endif
}
m_pCodecCtxs.clear();
// These are streams allocated from avformat_new_stream.
for (auto it : m_codecsToClose) {
avcodec_close(it);
}
m_codecsToClose.clear();
if (m_pFormatCtx)
avformat_close_input(&m_pFormatCtx);
sws_freeContext(m_sws_ctx);
@@ -439,6 +444,8 @@ bool MediaEngine::addVideoStream(int streamNum, int streamId) {
if (streamNum >= m_expectedVideoStreams) {
++m_expectedVideoStreams;
}
m_codecsToClose.push_back(stream->codec);
return true;
}
}
+5
View File
@@ -144,4 +144,9 @@ public: // TODO: Very little of this below should be public.
// used for audio type
int m_audioType;
private:
#ifdef USE_FFMPEG
std::vector<AVCodecContext *> m_codecsToClose;
#endif
};