Fixed some memory leaks in MP42AC3AudioEncoder

This commit is contained in:
Damiano Galassi committed 2017-05-11 12:33:00 +02:00
1 parent 88f4f94e1c
commit c0182dc78b
2 files changed
+23 -26

No files matched your search

+23 -9
View File
@@ -23,12 +23,9 @@ typedef struct AudioFileIO
float *inBuffer;
UInt32 inBufferSize;
UInt32 outputMaxSize;
UInt32 inSizePerPacket;
UInt32 inSamples;
UInt32 channelsPerFrame;
UInt32 numPacketsPerRead;
AVFrame *frame;
float *samples;
@@ -144,17 +141,14 @@ typedef struct AudioFileIO
_afio = malloc(sizeof(AudioFileIO));
bzero(_afio, sizeof(AudioFileIO));
_afio->inBufferSize = 1024 * 64;
_afio->inBuffer = malloc(_afio->inBufferSize);
_afio->outputMaxSize = _afio->inBufferSize;
_afio->inSizePerPacket = _inputFormat.mBytesPerPacket;
_afio->inSamples = _outputFormat.mFramesPerPacket;
_afio->channelsPerFrame = _inputFormat.mChannelsPerFrame;
_afio->numPacketsPerRead = _afio->inBufferSize / _afio->inSizePerPacket;
_afio->ringBuffer = _ringBuffer;
_afio->frame = av_frame_alloc();
@@ -197,12 +191,32 @@ typedef struct AudioFileIO
{
av_frame_free(&_afio->frame);
}
free(_afio->inBuffer);
free(_afio);
_afio = NULL;
}
if (_avctx)
{
avcodec_close(_avctx);
av_free(_avctx);
}
if (_ringBuffer) {
sfifo_close(_ringBuffer);
free(_ringBuffer);
_ringBuffer = NULL;
}
if (_outputLayout) {
free(_outputLayout);
_outputLayout = NULL;
}
if (_inputLayout) {
free(_inputLayout);
_inputLayout = NULL;
}
}
- (BOOL)createMagicCookie