Delegate between resampling functions for SRC case, to slightly simplify code
1 files changed, 17 insertions(+), 36 deletions(-)

M src/Resampler.cpp
M src/Resampler.cpp +17 -36
@@ 677,45 677,26 @@
 double ratio,
                 bool final)
 {
-    SRC_DATA data;
-
     if (m_channels == 1) {
-        data.data_in = const_cast<float *>(*in); //!!!???
-        data.data_out = *out;
-    } else {
-        if (incount * m_channels > m_iinsize) {
-            m_iin = reallocate<float>(m_iin, m_iinsize, incount * m_channels);
-            m_iinsize = incount * m_channels;
-        }
-        if (outcount * m_channels > m_ioutsize) {
-            m_iout = reallocate<float>(m_iout, m_ioutsize, outcount * m_channels);
-            m_ioutsize = outcount * m_channels;
-        }
-        v_interleave(m_iin, in, m_channels, incount);
-        data.data_in = m_iin;
-        data.data_out = m_iout;
+        return resampleInterleaved(*out, outcount, *in, incount, ratio, final);
     }
 
-    data.input_frames = incount;
-    data.output_frames = outcount;
-    data.src_ratio = ratio;
-    data.end_of_input = (final ? 1 : 0);
-
-    int err = src_process(m_src, &data);
+    if (incount * m_channels > m_iinsize) {
+        m_iin = reallocate<float>(m_iin, m_iinsize, incount * m_channels);
+        m_iinsize = incount * m_channels;
+    }
+    if (outcount * m_channels > m_ioutsize) {
+        m_iout = reallocate<float>(m_iout, m_ioutsize, outcount * m_channels);
+        m_ioutsize = outcount * m_channels;
+    }
+    
+    v_interleave(m_iin, in, m_channels, incount);
 
-    if (err) {
-        cerr << "Resampler::process: libsamplerate error: "
-                  << src_strerror(err) << endl;
-#ifndef NO_EXCEPTIONS
-        throw Resampler::ImplementationError;
-#endif
-    }
+    int n = resampleInterleaved(m_iout, outcount, m_iin, incount, ratio, final);
 
-    if (m_channels > 1) {
-        v_deinterleave(out, m_iout, m_channels, (int)data.output_frames_gen);
-    }
+    v_deinterleave(out, m_iout, m_channels, n);
 
-    return (int)data.output_frames_gen;
+    return n;
 }
 
 int

          
@@ 740,7 721,7 @@
      if (err) {
         cerr << "Resampler::process: libsamplerate error: "
-                  << src_strerror(err) << endl;
+             << src_strerror(err) << endl;
 #ifndef NO_EXCEPTIONS
         throw Resampler::ImplementationError;
 #endif

          
@@ 788,7 769,7 @@
 void *m_src;
     float *m_iin;
     float *m_iout;
-    float m_lastRatio;
+    double m_lastRatio;
     int m_channels;
     int m_iinsize;
     int m_ioutsize;

          
@@ 979,7 960,7 @@
 int m_channels;
     int m_iinsize;
     int m_ioutsize;
-    float m_lastratio;
+    double m_lastratio;
     bool m_initial;
     int m_debugLevel;