Skip to content

Commit

Permalink
fix avpacket memory leak wang-bin#774 wang-bin#672 wang-bin#441
Browse files Browse the repository at this point in the history
patch is from https://github.com/fmoyaarnao/QtAV/commit/
158a023#diff-
d70d26eb6c75b9a043dcb8e8419fad0a
  • Loading branch information
wang-bin committed Mar 9, 2017
1 parent a56dd03 commit b670eff
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/AVDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 425,7 @@ bool AVDemuxer::readFrame()
d->pkt = Packet();
// no lock required because in AVDemuxThread read and seek are in the same thread
AVPacket packet;
av_init_packet(&packet);
d->interrupt_hanlder->begin(InterruptHandler::Read);
int ret = av_read_frame(d->format_ctx, &packet); //0: ok, <0: error/end
d->interrupt_hanlder->end();
Expand All @@ -450,16 451,19 @@ bool AVDemuxer::readFrame()
qDebug("End of file. erreof=%d feof=%d", ret == AVERROR_EOF, avio_feof(d->format_ctx->pb));
}
}
av_packet_unref(&packet); //important!
return false;
}
if (ret == AVERROR(EAGAIN)) {
qWarning("demuxer EAGAIN :%s", av_err2str(ret));
av_packet_unref(&packet); //important!
return false;
}
AVError::ErrorCode ec(AVError::ReadError);
QString msg(tr("error reading stream data"));
handleError(ret, &ec, msg);
qWarning("[AVDemuxer] error: %s", av_err2str(ret));
av_packet_unref(&packet); //important!
return false;
}
d->stream = packet.stream_index;
Expand All @@ -470,6 474,7 @@ bool AVDemuxer::readFrame()
}
if (d->stream != videoStream() && d->stream != audioStream() && d->stream != subtitleStream()) {
//qWarning("[AVDemuxer] unknown stream index: %d", stream);
av_packet_unref(&packet); //important!
return false;
}
// TODO: v4l2 copy
Expand Down

0 comments on commit b670eff

Please sign in to comment.