]> code.delx.au - pulseaudio/commitdiff
resampler: Clean up ffmpeg resampler buffering
authorPeter Meerwald <p.meerwald@bct-electronic.com>
Fri, 29 Nov 2013 14:33:25 +0000 (15:33 +0100)
committerTanu Kaskinen <tanu.kaskinen@linux.intel.com>
Thu, 5 Dec 2013 08:46:47 +0000 (10:46 +0200)
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>
src/pulsecore/resampler.c

index 3ac8f5e5950ca75e33d1e6343bd5e2d286bf491b..b47557185c24cc09b26ba812b2ebb446a750bf55 100644 (file)
@@ -100,7 +100,6 @@ struct peaks_data { /* data specific to the peak finder pseudo resampler */
 
 struct ffmpeg_data { /* data specific to ffmpeg */
     struct AVResampleContext *state;
-    pa_memchunk buf[PA_CHANNELS_MAX];
 };
 
 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;
 
         /* 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);
 
         /* 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) {
-    unsigned c;
     struct ffmpeg_data *ffmpeg_data;
 
     pa_assert(r);
@@ -1825,14 +1823,9 @@ static void ffmpeg_free(pa_resampler *r) {
     ffmpeg_data = r->impl.data;
     if (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) {
-    unsigned c;
     struct ffmpeg_data *ffmpeg_data;
 
     pa_assert(r);
@@ -1851,9 +1844,6 @@ static int ffmpeg_init(pa_resampler *r) {
     r->impl.resample = ffmpeg_resample;
     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;
 }