Commit ec2badbe authored by Max Kellermann's avatar Max Kellermann

filter/ffmpeg: call av_frame_unref() before av_frame_get_buffer()

av_frame_get_buffer() leaks memory if buffers were already allocated. Fixes one of the memory leaks of https://github.com/MusicPlayerDaemon/MPD/issues/514
parent 054a7557
......@@ -37,12 +37,12 @@ FfmpegFilter::FfmpegFilter(const AudioFormat &in_audio_format,
graph(std::move(_graph)),
buffer_src(std::move(_buffer_src)),
buffer_sink(std::move(_buffer_sink)),
in_format(Ffmpeg::ToFfmpegSampleFormat(in_audio_format.format)),
in_sample_rate(in_audio_format.sample_rate),
in_channels(in_audio_format.channels),
in_audio_frame_size(in_audio_format.GetFrameSize()),
out_audio_frame_size(_out_audio_format.GetFrameSize())
{
in_frame->format = Ffmpeg::ToFfmpegSampleFormat(in_audio_format.format);
in_frame->sample_rate = in_audio_format.sample_rate;
in_frame->channels = in_audio_format.channels;
}
ConstBuffer<void>
......@@ -50,6 +50,10 @@ FfmpegFilter::FilterPCM(ConstBuffer<void> src)
{
/* submit source data into the FFmpeg audio buffer source */
in_frame.Unref();
in_frame->format = in_format;
in_frame->sample_rate = in_sample_rate;
in_frame->channels = in_channels;
in_frame->nb_samples = src.size / in_audio_frame_size;
in_frame.GetBuffer();
......
......@@ -32,6 +32,8 @@ class FfmpegFilter final : public Filter {
Ffmpeg::FilterContext buffer_src, buffer_sink;
Ffmpeg::Frame in_frame, out_frame;
const int in_format, in_sample_rate, in_channels;
const size_t in_audio_frame_size;
const size_t out_audio_frame_size;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment