summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/Effects.cpp
diff options
context:
space:
mode:
authorRicardo Garcia <rago@google.com>2014-08-11 12:04:54 -0700
committerRicardo Garcia <rago@google.com>2014-08-11 14:28:45 -0700
commit726b6a7540ac997928df1a14dfede872a82f6210 (patch)
treedeb87bb07b384d104a3e1661a6ef320fa10d34f3 /services/audioflinger/Effects.cpp
parent2dfe8ea7c131a045067c123efc934ef6ccdb8821 (diff)
downloadframeworks_av-726b6a7540ac997928df1a14dfede872a82f6210.zip
frameworks_av-726b6a7540ac997928df1a14dfede872a82f6210.tar.gz
frameworks_av-726b6a7540ac997928df1a14dfede872a82f6210.tar.bz2
Fix to support mono in effect buffer allocation.
Since effects are now enabled for recording, mono cases are possible and needed to be correctly allocated. Bug: 16917961 Change-Id: I760fc421f9f90fabb3f0deadd5f9dc61cd284371
Diffstat (limited to 'services/audioflinger/Effects.cpp')
-rw-r--r--services/audioflinger/Effects.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp
index ec3d731..365f271 100644
--- a/services/audioflinger/Effects.cpp
+++ b/services/audioflinger/Effects.cpp
@@ -44,6 +44,8 @@
#define ALOGVV(a...) do { } while(0)
#endif
+#define min(a, b) ((a) < (b) ? (a) : (b))
+
namespace android {
// ----------------------------------------------------------------------------
@@ -1391,7 +1393,8 @@ void AudioFlinger::EffectChain::clearInputBuffer_l(sp<ThreadBase> thread)
// and sample format changes for effects.
// Currently effects processing is only available for stereo, AUDIO_FORMAT_PCM_16_BIT
// (4 bytes frame size)
- const size_t frameSize = audio_bytes_per_sample(AUDIO_FORMAT_PCM_16_BIT) * FCC_2;
+ const size_t frameSize =
+ audio_bytes_per_sample(AUDIO_FORMAT_PCM_16_BIT) * min(FCC_2, thread->channelCount());
memset(mInBuffer, 0, thread->frameCount() * frameSize);
}