mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-16 09:31:14 +01:00
Fix resource leaks in the usage of the FFMPEG library with RAII objects...
... This includes failure paths in the initialization if import. Those resources would have been reclaimed before program exit, but not as soon as they should have been. ... This also includes certain leaks that would happen every time a file is successfully imported or exported. We never used avformat_free_context or av_dict_free as we should have! ... There were also AVPacket objects repeatedly reinitialized without proper cleanups in between. That might have leaked memory too.
This commit is contained in:
@@ -372,7 +372,7 @@ int ODFFmpegDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCo
|
||||
// for some formats
|
||||
// The only other case for inserting silence is for initial offset and ImportFFmpeg.cpp does this for us
|
||||
if (seeking) {
|
||||
actualDecodeStart = 0.52 + (sc->m_stream->codec->sample_rate * sc->m_pkt.dts
|
||||
actualDecodeStart = 0.52 + (sc->m_stream->codec->sample_rate * sc->m_pkt->dts
|
||||
* ((double)sc->m_stream->time_base.num / sc->m_stream->time_base.den));
|
||||
//this is mostly safe because den is usually 1 or low number but check for high values.
|
||||
|
||||
@@ -421,11 +421,7 @@ int ODFFmpegDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCo
|
||||
break;
|
||||
|
||||
// Cleanup after frame decoding
|
||||
if (sc->m_pktValid)
|
||||
{
|
||||
av_free_packet(&sc->m_pkt);
|
||||
sc->m_pktValid = 0;
|
||||
}
|
||||
sc->m_pkt.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,14 +430,11 @@ int ODFFmpegDecoder::Decode(SampleBuffer & data, sampleFormat & format, sampleCo
|
||||
{
|
||||
for (int i = 0; i < mChannels.size(); i++)
|
||||
{
|
||||
sc->m_pkt.create();
|
||||
sc = scs[i].get();
|
||||
if (DecodeFrame(sc, true) == 0)
|
||||
{
|
||||
if (sc->m_pktValid)
|
||||
{
|
||||
av_free_packet(&sc->m_pkt);
|
||||
sc->m_pktValid = 0;
|
||||
}
|
||||
sc->m_pkt.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user