修复内存泄露

This commit is contained in:
jie 2024-02-23 10:32:08 +08:00
parent 4d82e2b0a5
commit 5e794cf825
2 changed files with 3 additions and 2 deletions

View File

@ -61,7 +61,8 @@ bool MediaQueue<T>::pop(T* item, bool block, bool quit) {
if (av_frame_ref(item, temp) < 0) {
return false;
}
av_frame_unref(temp);
av_frame_free(&temp);
delete temp;
}
queue.pop();
count--;

View File

@ -70,7 +70,6 @@ void RequestVideoFrame(MediaParam& param) {
const auto& fmtCtx = param.videoParam.fmtCtx;
const auto& codecCtx = param.videoParam.codecCtx;
const auto& videoStreamIndex = param.videoParam.videoStreamIndex;
AVPacket* packet = av_packet_alloc();
AVFrame* frame = av_frame_alloc();
while (true) {
@ -99,6 +98,7 @@ void RequestVideoFrame(MediaParam& param) {
}
param.videoParam.frameQueue.push(frame);
av_frame_unref(frame);
av_packet_unref(packet);
}
}