summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/AudioResamplerCubic.cpp
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2015-03-29 00:49:22 -0700
committerAndy Hung <hunga@google.com>2015-04-08 14:31:58 -0700
commit6b3b7e304e0f8f167241b2c75f1eb04a9ef192ec (patch)
tree1cec011ad26676dc9dc3eea778e18136c083e04f /services/audioflinger/AudioResamplerCubic.cpp
parent25f82752942b1c78aec8ee303d61afff85cff9d1 (diff)
downloadframeworks_av-6b3b7e304e0f8f167241b2c75f1eb04a9ef192ec.zip
frameworks_av-6b3b7e304e0f8f167241b2c75f1eb04a9ef192ec.tar.gz
frameworks_av-6b3b7e304e0f8f167241b2c75f1eb04a9ef192ec.tar.bz2
Return number of frames output from resample method
Change-Id: Ic297e2ed59839f1788c83e099ef1a9e4af29591f
Diffstat (limited to 'services/audioflinger/AudioResamplerCubic.cpp')
-rw-r--r--services/audioflinger/AudioResamplerCubic.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/services/audioflinger/AudioResamplerCubic.cpp b/services/audioflinger/AudioResamplerCubic.cpp
index d3cbd1c..172c2a5 100644
--- a/services/audioflinger/AudioResamplerCubic.cpp
+++ b/services/audioflinger/AudioResamplerCubic.cpp
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#define LOG_TAG "AudioSRC"
+#define LOG_TAG "AudioResamplerCubic"
#include <stdint.h>
#include <string.h>
@@ -32,7 +32,7 @@ void AudioResamplerCubic::init() {
memset(&right, 0, sizeof(state));
}
-void AudioResamplerCubic::resample(int32_t* out, size_t outFrameCount,
+size_t AudioResamplerCubic::resample(int32_t* out, size_t outFrameCount,
AudioBufferProvider* provider) {
// should never happen, but we overflow if it does
@@ -41,15 +41,16 @@ void AudioResamplerCubic::resample(int32_t* out, size_t outFrameCount,
// select the appropriate resampler
switch (mChannelCount) {
case 1:
- resampleMono16(out, outFrameCount, provider);
- break;
+ return resampleMono16(out, outFrameCount, provider);
case 2:
- resampleStereo16(out, outFrameCount, provider);
- break;
+ return resampleStereo16(out, outFrameCount, provider);
+ default:
+ LOG_ALWAYS_FATAL("invalid channel count: %d", mChannelCount);
+ return 0;
}
}
-void AudioResamplerCubic::resampleStereo16(int32_t* out, size_t outFrameCount,
+size_t AudioResamplerCubic::resampleStereo16(int32_t* out, size_t outFrameCount,
AudioBufferProvider* provider) {
int32_t vl = mVolume[0];
@@ -67,7 +68,7 @@ void AudioResamplerCubic::resampleStereo16(int32_t* out, size_t outFrameCount,
mBuffer.frameCount = inFrameCount;
provider->getNextBuffer(&mBuffer, mPTS);
if (mBuffer.raw == NULL) {
- return;
+ return 0;
}
// ALOGW("New buffer: offset=%p, frames=%dn", mBuffer.raw, mBuffer.frameCount);
}
@@ -115,9 +116,10 @@ save_state:
// ALOGW("Done: index=%d, fraction=%u", inputIndex, phaseFraction);
mInputIndex = inputIndex;
mPhaseFraction = phaseFraction;
+ return outputIndex / 2 /* channels for stereo */;
}
-void AudioResamplerCubic::resampleMono16(int32_t* out, size_t outFrameCount,
+size_t AudioResamplerCubic::resampleMono16(int32_t* out, size_t outFrameCount,
AudioBufferProvider* provider) {
int32_t vl = mVolume[0];
@@ -135,7 +137,7 @@ void AudioResamplerCubic::resampleMono16(int32_t* out, size_t outFrameCount,
mBuffer.frameCount = inFrameCount;
provider->getNextBuffer(&mBuffer, mPTS);
if (mBuffer.raw == NULL) {
- return;
+ return 0;
}
// ALOGW("New buffer: offset=%p, frames=%d", mBuffer.raw, mBuffer.frameCount);
}
@@ -182,6 +184,7 @@ save_state:
// ALOGW("Done: index=%d, fraction=%u", inputIndex, phaseFraction);
mInputIndex = inputIndex;
mPhaseFraction = phaseFraction;
+ return outputIndex;
}
// ----------------------------------------------------------------------------