Skip to content

Commit e61e667

Browse files
gkastenAndroid (Google) Code Review
authored andcommitted
Merge "Replace hard-coded 3 by FCC_2 to simplify searches"
2 parents 6df8876 + d8f32c2 commit e61e667

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

services/audioflinger/AudioFlinger.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5192,8 +5192,8 @@ bool AudioFlinger::RecordThread::checkForNewParameters_l()
51925192
reqFormat == mInput->stream->common.get_format(&mInput->stream->common) &&
51935193
reqFormat == AUDIO_FORMAT_PCM_16_BIT &&
51945194
((int)mInput->stream->common.get_sample_rate(&mInput->stream->common) <= (2 * reqSamplingRate)) &&
5195-
(popcount(mInput->stream->common.get_channels(&mInput->stream->common)) < 3) &&
5196-
(reqChannelCount < 3)) {
5195+
popcount(mInput->stream->common.get_channels(&mInput->stream->common)) <= FCC_2 &&
5196+
(reqChannelCount <= FCC_2)) {
51975197
status = NO_ERROR;
51985198
}
51995199
if (status == NO_ERROR) {
@@ -5270,7 +5270,7 @@ void AudioFlinger::RecordThread::readInputParameters()
52705270
mFrameCount = mInputBytes / mFrameSize;
52715271
mRsmpInBuffer = new int16_t[mFrameCount * mChannelCount];
52725272

5273-
if (mSampleRate != mReqSampleRate && mChannelCount < 3 && mReqChannelCount < 3)
5273+
if (mSampleRate != mReqSampleRate && mChannelCount <= FCC_2 && mReqChannelCount <= FCC_2)
52745274
{
52755275
int channelCount;
52765276
// optmization: if mono to mono, use the resampler in stereo to stereo mode to avoid
@@ -5559,7 +5559,7 @@ audio_io_handle_t AudioFlinger::openInput(uint32_t *pDevices,
55595559
if (inStream == NULL && status == BAD_VALUE &&
55605560
reqFormat == format && format == AUDIO_FORMAT_PCM_16_BIT &&
55615561
(samplingRate <= 2 * reqSamplingRate) &&
5562-
(popcount(channels) < 3) && (popcount(reqChannels) < 3)) {
5562+
(popcount(channels) <= FCC_2) && (popcount(reqChannels) <= FCC_2)) {
55635563
ALOGV("openInput() reopening with proposed sampling rate and channels");
55645564
status = inHwDev->open_input_stream(inHwDev, *pDevices, &format,
55655565
&channels, &samplingRate,

services/audioflinger/AudioFlinger.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ class AudioResampler;
5858

5959
// ----------------------------------------------------------------------------
6060

61+
// AudioFlinger has a hard-coded upper limit of 2 channels for capture and playback.
62+
// There is support for > 2 channel tracks down-mixed to 2 channel output via a down-mix effect.
63+
// Adding full support for > 2 channel capture or playback would require more than simply changing
64+
// this #define. There is an independent hard-coded upper limit in AudioMixer;
65+
// removing that AudioMixer limit would be necessary but insufficient to support > 2 channels.
66+
// The macro FCC_2 highlights some (but not all) places where there is are 2-channel assumptions.
67+
// Search also for "2", "left", "right", "[0]", "[1]", ">> 16", "<< 16", etc.
68+
#define FCC_2 2 // FCC_2 = Fixed Channel Count 2
69+
6170
static const nsecs_t kDefaultStandbyTimeInNsecs = seconds(3);
6271

6372
class AudioFlinger :

0 commit comments

Comments
 (0)