resampler: Clean up ffmpeg resampler buffering

buf in struct ffmpeg_data is reset() initially and freed, but never
actually used

when a new block is allocated ffmpeg_data->buf[c].length is used
(which is always 0) to compute the new block size

so, drop buf

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
This commit is contained in:
Peter Meerwald 2013-11-29 15:33:25 +01:00 committed by Tanu Kaskinen
parent ce304d6208
commit 742b93d32c

View file

@ -100,7 +100,6 @@ struct peaks_data { /* data specific to the peak finder pseudo resampler */
struct ffmpeg_data { /* data specific to ffmpeg */ struct ffmpeg_data { /* data specific to ffmpeg */
struct AVResampleContext *state; struct AVResampleContext *state;
pa_memchunk buf[PA_CHANNELS_MAX];
}; };
static int copy_init(pa_resampler *r); static int copy_init(pa_resampler *r);
@ -1768,7 +1767,7 @@ static unsigned ffmpeg_resample(pa_resampler *r, const pa_memchunk *input, unsig
int consumed_frames; int consumed_frames;
/* Allocate a new block */ /* Allocate a new block */
b = pa_memblock_new(r->mempool, ffmpeg_data->buf[c].length + in_n_frames * sizeof(int16_t)); b = pa_memblock_new(r->mempool, in_n_frames * sizeof(int16_t));
p = pa_memblock_acquire(b); p = pa_memblock_acquire(b);
/* Now copy the input data, splitting up channels */ /* Now copy the input data, splitting up channels */
@ -1817,7 +1816,6 @@ static unsigned ffmpeg_resample(pa_resampler *r, const pa_memchunk *input, unsig
} }
static void ffmpeg_free(pa_resampler *r) { static void ffmpeg_free(pa_resampler *r) {
unsigned c;
struct ffmpeg_data *ffmpeg_data; struct ffmpeg_data *ffmpeg_data;
pa_assert(r); pa_assert(r);
@ -1825,14 +1823,9 @@ static void ffmpeg_free(pa_resampler *r) {
ffmpeg_data = r->impl.data; ffmpeg_data = r->impl.data;
if (ffmpeg_data->state) if (ffmpeg_data->state)
av_resample_close(ffmpeg_data->state); av_resample_close(ffmpeg_data->state);
for (c = 0; c < PA_ELEMENTSOF(ffmpeg_data->buf); c++)
if (ffmpeg_data->buf[c].memblock)
pa_memblock_unref(ffmpeg_data->buf[c].memblock);
} }
static int ffmpeg_init(pa_resampler *r) { static int ffmpeg_init(pa_resampler *r) {
unsigned c;
struct ffmpeg_data *ffmpeg_data; struct ffmpeg_data *ffmpeg_data;
pa_assert(r); pa_assert(r);
@ -1851,9 +1844,6 @@ static int ffmpeg_init(pa_resampler *r) {
r->impl.resample = ffmpeg_resample; r->impl.resample = ffmpeg_resample;
r->impl.data = (void *) ffmpeg_data; r->impl.data = (void *) ffmpeg_data;
for (c = 0; c < PA_ELEMENTSOF(ffmpeg_data->buf); c++)
pa_memchunk_reset(&ffmpeg_data->buf[c]);
return 0; return 0;
} }