diff data/fileio/CodedAudioFileReader.cpp @ 1320:983667969a82 3.0-integration

Update to reflect bqresample API change
author Chris Cannam
date Fri, 09 Dec 2016 10:24:40 +0000
parents f830a10bfbd6
children 4dbb7a7c9c28
line wrap: on
line diff
--- a/data/fileio/CodedAudioFileReader.cpp	Wed Dec 07 13:56:22 2016 +0000
+++ b/data/fileio/CodedAudioFileReader.cpp	Fri Dec 09 10:24:40 2016 +0000
@@ -42,9 +42,10 @@
     m_cacheFileReader(0),
     m_cacheWriteBuffer(0),
     m_cacheWriteBufferIndex(0),
-    m_cacheWriteBufferSize(65536),
+    m_cacheWriteBufferFrames(65536),
     m_resampler(0),
     m_resampleBuffer(0),
+    m_resampleBufferFrames(0),
     m_fileFrameCount(0),
     m_normalised(normalised),
     m_max(0.f),
@@ -146,13 +147,14 @@
         m_resampler = new breakfastquay::Resampler
             (breakfastquay::Resampler::FastestTolerable,
              m_channelCount,
-             m_cacheWriteBufferSize);
+             int(m_cacheWriteBufferFrames));
         double ratio = m_sampleRate / m_fileRate;
-        m_resampleBuffer = new float
-            [lrint(ceil(double(m_cacheWriteBufferSize) * m_channelCount * ratio + 1))];
+        m_resampleBufferFrames = int(ceil(double(m_cacheWriteBufferFrames) *
+                                          ratio + 1));
+        m_resampleBuffer = new float[m_resampleBufferFrames * m_channelCount];
     }
 
-    m_cacheWriteBuffer = new float[m_cacheWriteBufferSize * m_channelCount];
+    m_cacheWriteBuffer = new float[m_cacheWriteBufferFrames * m_channelCount];
     m_cacheWriteBufferIndex = 0;
 
     if (m_cacheMode == CacheInTemporaryFile) {
@@ -228,8 +230,8 @@
         m_data.clear();
     }
 
-    if (m_trimFromEnd >= (m_cacheWriteBufferSize * m_channelCount)) {
-        SVCERR << "WARNING: CodedAudioFileReader::setSamplesToTrim: Can't handle trimming more frames from end (" << m_trimFromEnd << ") than can be stored in cache-write buffer (" << (m_cacheWriteBufferSize * m_channelCount) << "), won't trim anything from the end after all";
+    if (m_trimFromEnd >= (m_cacheWriteBufferFrames * m_channelCount)) {
+        SVCERR << "WARNING: CodedAudioFileReader::setSamplesToTrim: Can't handle trimming more frames from end (" << m_trimFromEnd << ") than can be stored in cache-write buffer (" << (m_cacheWriteBufferFrames * m_channelCount) << "), won't trim anything from the end after all";
         m_trimFromEnd = 0;
     }
 
@@ -362,7 +364,7 @@
 {
     if (final ||
         (m_cacheWriteBufferIndex ==
-         m_cacheWriteBufferSize * m_channelCount)) {
+         m_cacheWriteBufferFrames * m_channelCount)) {
 
         if (m_trimFromEnd > 0) {
         
@@ -483,8 +485,9 @@
     if (sz > 0) {
 
         sv_frame_t out = m_resampler->resampleInterleaved
-            (buffer,
-             m_resampleBuffer,
+            (m_resampleBuffer,
+             m_resampleBufferFrames,
+             buffer,
              sz,
              ratio,
              false);
@@ -507,8 +510,9 @@
         for (sv_frame_t i = 0; i < padSamples; ++i) padding[i] = 0.f;
 
         sv_frame_t out = m_resampler->resampleInterleaved
-            (padding,
-             m_resampleBuffer,
+            (m_resampleBuffer,
+             m_resampleBufferFrames,
+             padding,
              padFrames,
              ratio,
              true);