Fix effect and mono sink handling.
Do not permit mixing to mono sink in AudioFlinger.
Allow effects on mono sink if not Mixer thread (e.g. Record).
Bug: 16863095
Change-Id: I8b232fc1fb3f07bf017020c5d4f9ace644dec6d8
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 31c5a1a..83e4ae1 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -340,7 +340,8 @@
uint32_t channelCount = FCC_2; // stereo is default
if (kEnableExtendedChannels) {
channelCount = audio_channel_count_from_out_mask(channelMask);
- if (channelCount > AudioMixer::MAX_NUM_CHANNELS) {
+ if (channelCount < FCC_2 // mono is not supported at this time
+ || channelCount > AudioMixer::MAX_NUM_CHANNELS) {
return false;
}
}
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 2f65370..7d583bb5 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -910,11 +910,11 @@
goto Exit;
}
- // Reject any effect on multichannel sinks.
+ // Reject any effect on mixer or duplicating multichannel sinks.
// TODO: fix both format and multichannel issues with effects.
- if (mChannelCount != FCC_2) {
- ALOGW("createEffect_l() Cannot add effect %s for multichannel(%d) thread",
- desc->name, mChannelCount);
+ if ((mType == MIXER || mType == DUPLICATING) && mChannelCount != FCC_2) {
+ ALOGW("createEffect_l() Cannot add effect %s for multichannel(%d) %s threads",
+ desc->name, mChannelCount, mType == MIXER ? "MIXER" : "DUPLICATING");
lStatus = BAD_VALUE;
goto Exit;
}