summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2014-08-07 11:04:34 -0700
committerAndy Hung <hunga@google.com>2014-08-11 10:17:18 -0700
commitcd04484f4837b8ca0041d118286ab6a98e84fc75 (patch)
tree4b9e501bb71969c0ca5049201aeae42284ac9b80 /services
parent53a1e46e559b00653eadf6f4bb5572679b0ee734 (diff)
downloadframeworks_av-cd04484f4837b8ca0041d118286ab6a98e84fc75.zip
frameworks_av-cd04484f4837b8ca0041d118286ab6a98e84fc75.tar.gz
frameworks_av-cd04484f4837b8ca0041d118286ab6a98e84fc75.tar.bz2
Extend downsampling ratios greater than 2:1
Also improve robustness to choice of sampling rate or buffer size such that increasing either by 10x does not cause overflow. Bug: 12979141 Bug: 15933066 Change-Id: If7989bd745d1bee3bdf811b8b7c978543ccafb65
Diffstat (limited to 'services')
-rw-r--r--services/audioflinger/AudioResamplerDyn.cpp2
-rw-r--r--services/audioflinger/Threads.cpp6
2 files changed, 4 insertions, 4 deletions
diff --git a/services/audioflinger/AudioResamplerDyn.cpp b/services/audioflinger/AudioResamplerDyn.cpp
index 159ab70..0eeb201 100644
--- a/services/audioflinger/AudioResamplerDyn.cpp
+++ b/services/audioflinger/AudioResamplerDyn.cpp
@@ -393,7 +393,7 @@ void AudioResamplerDyn<TC, TI, TO>::setSampleRate(int32_t inSampleRate)
mPhaseFraction = static_cast<unsigned long long>(mPhaseFraction)
* phaseWrapLimit / oldPhaseWrapLimit;
mPhaseFraction %= phaseWrapLimit; // should not do anything, but just in case.
- mPhaseIncrement = static_cast<uint32_t>(static_cast<double>(phaseWrapLimit)
+ mPhaseIncrement = static_cast<uint32_t>(static_cast<uint64_t>(phaseWrapLimit)
* inSampleRate / mSampleRate);
// determine which resampler to use
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 7d583bb..30cebf4 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -26,6 +26,7 @@
#include <sys/stat.h>
#include <cutils/properties.h>
#include <media/AudioParameter.h>
+#include <media/AudioResamplerPublic.h>
#include <utils/Log.h>
#include <utils/Trace.h>
@@ -1479,8 +1480,7 @@ sp<AudioFlinger::PlaybackThread::Track> AudioFlinger::PlaybackThread::createTrac
lStatus = BAD_VALUE;
goto Exit;
}
- // Resampler implementation limits input sampling rate to 2 x output sampling rate.
- if (sampleRate > mSampleRate*2) {
+ if (sampleRate > mSampleRate * AUDIO_RESAMPLER_DOWN_RATIO_MAX) {
ALOGE("Sample rate out of range: %u mSampleRate %u", sampleRate, mSampleRate);
lStatus = BAD_VALUE;
goto Exit;
@@ -3500,7 +3500,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac
AudioMixer::TRACK,
AudioMixer::MIXER_CHANNEL_MASK, (void *)(uintptr_t)mChannelMask);
// limit track sample rate to 2 x output sample rate, which changes at re-configuration
- uint32_t maxSampleRate = mSampleRate * 2;
+ uint32_t maxSampleRate = mSampleRate * AUDIO_RESAMPLER_DOWN_RATIO_MAX;
uint32_t reqSampleRate = track->mAudioTrackServerProxy->getSampleRate();
if (reqSampleRate == 0) {
reqSampleRate = mSampleRate;