summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/FastMixer.cpp
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2013-07-16 17:18:58 -0700
committerGlenn Kasten <gkasten@google.com>2013-07-25 12:22:18 -0700
commit7fc97ba08e2850f3f16db704b78ce78e3dbe1ff0 (patch)
treeada9fda1321150cc75295eece5f7f82e35f0c9f3 /services/audioflinger/FastMixer.cpp
parentfc5ea08326b510c6f82f71845d95a8758a6ab698 (diff)
downloadframeworks_av-7fc97ba08e2850f3f16db704b78ce78e3dbe1ff0.zip
frameworks_av-7fc97ba08e2850f3f16db704b78ce78e3dbe1ff0.tar.gz
frameworks_av-7fc97ba08e2850f3f16db704b78ce78e3dbe1ff0.tar.bz2
HAL stream format for mixer output threads must be stereo 16-bit PCM
Direct and tunnel output threads can support various HAL stream formats, included encoded. But currently there are stereo 16-bit PCM assumptions in several places for mixer and duplicating output threads: - mMixBuffer and mixBuffer() - AudioMixer including resampler - FastMixer's mixBuffer - effects - NBAIO_Format - anywhere FCC_2 is used - possibly other places Until those assumptions are removed, this CL enforces stereo 16-bit PCM in mixer and duplicating threads at the place where the HAL format is read. It was already being checked in checkForNewParameters_l(), but not in readOutputParameters(). Change-Id: Ibe344cc922743da234299097aa1bb1f54795cc9b
Diffstat (limited to 'services/audioflinger/FastMixer.cpp')
-rw-r--r--services/audioflinger/FastMixer.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/services/audioflinger/FastMixer.cpp b/services/audioflinger/FastMixer.cpp
index 5350e2c..ad9f4f2 100644
--- a/services/audioflinger/FastMixer.cpp
+++ b/services/audioflinger/FastMixer.cpp
@@ -45,6 +45,8 @@
#define MIN_WARMUP_CYCLES 2 // minimum number of loop cycles to wait for warmup
#define MAX_WARMUP_CYCLES 10 // maximum number of loop cycles to wait for warmup
+#define FCC_2 2 // fixed channel count assumption
+
namespace android {
// Fast mixer thread
@@ -225,7 +227,7 @@ bool FastMixer::threadLoop()
} else {
format = outputSink->format();
sampleRate = Format_sampleRate(format);
- ALOG_ASSERT(Format_channelCount(format) == 2);
+ ALOG_ASSERT(Format_channelCount(format) == FCC_2);
}
dumpState->mSampleRate = sampleRate;
}
@@ -241,7 +243,7 @@ bool FastMixer::threadLoop()
// implementation; it would be better to have normal mixer allocate for us
// to avoid blocking here and to prevent possible priority inversion
mixer = new AudioMixer(frameCount, sampleRate, FastMixerState::kMaxFastTracks);
- mixBuffer = new short[frameCount * 2];
+ mixBuffer = new short[frameCount * FCC_2];
periodNs = (frameCount * 1000000000LL) / sampleRate; // 1.00
underrunNs = (frameCount * 1750000000LL) / sampleRate; // 1.75
overrunNs = (frameCount * 500000000LL) / sampleRate; // 0.50
@@ -438,7 +440,7 @@ bool FastMixer::threadLoop()
//bool didFullWrite = false; // dumpsys could display a count of partial writes
if ((command & FastMixerState::WRITE) && (outputSink != NULL) && (mixBuffer != NULL)) {
if (mixBufferState == UNDEFINED) {
- memset(mixBuffer, 0, frameCount * 2 * sizeof(short));
+ memset(mixBuffer, 0, frameCount * FCC_2 * sizeof(short));
mixBufferState = ZEROED;
}
if (teeSink != NULL) {