[PATCHv2] resampler: Clean up ffmpeg resampler buffering

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Peter Meerwald <p.meerwald@xxxxxxxxxxxxxxxxxx>

buf in struct ffmpeg 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 at bct-electronic.com>
---
follow-up from http://thread.gmane.org/gmane.comp.audio.pulseaudio.general/17632

 src/pulsecore/resampler.c |   12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
index 3ac8f5e..b475571 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -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;
 }
 
-- 
1.7.9.5



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux