Skip to content

Commit ab1fe30

Browse files
author
Eric Laurent
committed
do not merge - Fix issue 3371096.
EffectModule::process() was copying effect chain input buffer to output buffer if no effect was active instead of accumulating it. Change-Id: If4ca75601ea69a088d0f71d88aec53e90a1dec89
1 parent 65d39ee commit ab1fe30

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

services/audioflinger/AudioFlinger.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5433,19 +5433,21 @@ void AudioFlinger::EffectModule::process()
54335433

54345434
// clear auxiliary effect input buffer for next accumulation
54355435
if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY) {
5436-
memset(mConfig.inputCfg.buffer.raw, 0, mConfig.inputCfg.buffer.frameCount*sizeof(int32_t));
5436+
memset(mConfig.inputCfg.buffer.raw, 0,
5437+
mConfig.inputCfg.buffer.frameCount*sizeof(int32_t));
54375438
}
54385439
} else if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_INSERT &&
5439-
mConfig.inputCfg.buffer.raw != mConfig.outputCfg.buffer.raw){
5440-
// If an insert effect is idle and input buffer is different from output buffer, copy input to
5441-
// output
5440+
mConfig.inputCfg.buffer.raw != mConfig.outputCfg.buffer.raw) {
5441+
// If an insert effect is idle and input buffer is different from output buffer,
5442+
// accumulate input onto output
54425443
sp<EffectChain> chain = mChain.promote();
54435444
if (chain != 0 && chain->activeTracks() != 0) {
5444-
size_t size = mConfig.inputCfg.buffer.frameCount * sizeof(int16_t);
5445-
if (mConfig.inputCfg.channels == CHANNEL_STEREO) {
5446-
size *= 2;
5445+
size_t frameCnt = mConfig.inputCfg.buffer.frameCount * 2; //always stereo here
5446+
int16_t *in = mConfig.inputCfg.buffer.s16;
5447+
int16_t *out = mConfig.outputCfg.buffer.s16;
5448+
for (size_t i = 0; i < frameCnt; i++) {
5449+
out[i] = clamp16((int32_t)out[i] + (int32_t)in[i]);
54475450
}
5448-
memcpy(mConfig.outputCfg.buffer.raw, mConfig.inputCfg.buffer.raw, size);
54495451
}
54505452
}
54515453
}

0 commit comments

Comments
 (0)