[pulseaudio-discuss] [PATCH 2/3] resampler: Rename buf3 and buf4 to buf4 and buf5.

Tanu Kaskinen tanuk at iki.fi
Sun Apr 22 11:28:03 PDT 2012


Input leftover handling is going to use buf3.
---
 src/pulsecore/resampler.c |   54 ++++++++++++++++++++++-----------------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
index 185095b..5f791da 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -56,8 +56,8 @@ struct pa_resampler {
     size_t i_fz, o_fz, w_sz;
     pa_mempool *mempool;
 
-    pa_memchunk buf1, buf2, buf3, buf4;
-    unsigned buf1_samples, buf2_samples, buf3_samples, buf4_samples;
+    pa_memchunk buf1, buf2, buf4, buf5;
+    unsigned buf1_samples, buf2_samples, buf4_samples, buf5_samples;
 
     pa_sample_format_t work_format;
 
@@ -338,10 +338,10 @@ void pa_resampler_free(pa_resampler *r) {
         pa_memblock_unref(r->buf1.memblock);
     if (r->buf2.memblock)
         pa_memblock_unref(r->buf2.memblock);
-    if (r->buf3.memblock)
-        pa_memblock_unref(r->buf3.memblock);
     if (r->buf4.memblock)
         pa_memblock_unref(r->buf4.memblock);
+    if (r->buf5.memblock)
+        pa_memblock_unref(r->buf5.memblock);
 
     pa_xfree(r);
 }
@@ -1143,7 +1143,7 @@ static pa_memchunk *resample(pa_resampler *r, pa_memchunk *input) {
     pa_assert(r);
     pa_assert(input);
 
-    /* Resample the data and place the result in buf3 */
+    /* Resample the data and place the result in buf4 */
 
     if (!r->impl_resample || !input->length)
         return input;
@@ -1154,21 +1154,21 @@ static pa_memchunk *resample(pa_resampler *r, pa_memchunk *input) {
     out_n_frames = ((in_n_frames*r->o_ss.rate)/r->i_ss.rate)+EXTRA_FRAMES;
     out_n_samples = out_n_frames * r->o_ss.channels;
 
-    r->buf3.index = 0;
-    r->buf3.length = r->w_sz * out_n_samples;
+    r->buf4.index = 0;
+    r->buf4.length = r->w_sz * out_n_samples;
 
-    if (!r->buf3.memblock || r->buf3_samples < out_n_samples) {
-        if (r->buf3.memblock)
-            pa_memblock_unref(r->buf3.memblock);
+    if (!r->buf4.memblock || r->buf4_samples < out_n_samples) {
+        if (r->buf4.memblock)
+            pa_memblock_unref(r->buf4.memblock);
 
-        r->buf3_samples = out_n_samples;
-        r->buf3.memblock = pa_memblock_new(r->mempool, r->buf3.length);
+        r->buf4_samples = out_n_samples;
+        r->buf4.memblock = pa_memblock_new(r->mempool, r->buf4.length);
     }
 
-    r->impl_resample(r, input, in_n_frames, &r->buf3, &out_n_frames);
-    r->buf3.length = out_n_frames * r->w_sz * r->o_ss.channels;
+    r->impl_resample(r, input, in_n_frames, &r->buf4, &out_n_frames);
+    r->buf4.length = out_n_frames * r->w_sz * r->o_ss.channels;
 
-    return &r->buf3;
+    return &r->buf4;
 }
 
 static pa_memchunk *convert_from_work_format(pa_resampler *r, pa_memchunk *input) {
@@ -1178,7 +1178,7 @@ static pa_memchunk *convert_from_work_format(pa_resampler *r, pa_memchunk *input
     pa_assert(r);
     pa_assert(input);
 
-    /* Convert the data into the correct sample type and place the result in buf4 */
+    /* Convert the data into the correct sample type and place the result in buf5 */
 
     if (!r->from_work_format_func || !input->length)
         return input;
@@ -1186,26 +1186,26 @@ static pa_memchunk *convert_from_work_format(pa_resampler *r, pa_memchunk *input
     n_samples = (unsigned) (input->length / r->w_sz);
     n_frames = n_samples / r->o_ss.channels;
 
-    r->buf4.index = 0;
-    r->buf4.length = r->o_fz * n_frames;
+    r->buf5.index = 0;
+    r->buf5.length = r->o_fz * n_frames;
 
-    if (!r->buf4.memblock || r->buf4_samples < n_samples) {
-        if (r->buf4.memblock)
-            pa_memblock_unref(r->buf4.memblock);
+    if (!r->buf5.memblock || r->buf5_samples < n_samples) {
+        if (r->buf5.memblock)
+            pa_memblock_unref(r->buf5.memblock);
 
-        r->buf4_samples = n_samples;
-        r->buf4.memblock = pa_memblock_new(r->mempool, r->buf4.length);
+        r->buf5_samples = n_samples;
+        r->buf5.memblock = pa_memblock_new(r->mempool, r->buf5.length);
     }
 
     src = (uint8_t*) pa_memblock_acquire(input->memblock) + input->index;
-    dst = pa_memblock_acquire(r->buf4.memblock);
+    dst = pa_memblock_acquire(r->buf5.memblock);
     r->from_work_format_func(n_samples, src, dst);
     pa_memblock_release(input->memblock);
-    pa_memblock_release(r->buf4.memblock);
+    pa_memblock_release(r->buf5.memblock);
 
-    r->buf4.length = r->o_fz * n_frames;
+    r->buf5.length = r->o_fz * n_frames;
 
-    return &r->buf4;
+    return &r->buf5;
 }
 
 void pa_resampler_run(pa_resampler *r, const pa_memchunk *in, pa_memchunk *out) {
-- 
1.7.10



More information about the pulseaudio-discuss mailing list