From 16ac9e53705b2cc1e312f332c8dcd2b739a042a1 Mon Sep 17 00:00:00 2001 From: Dhananjay Kumar Date: Mon, 20 Jul 2015 16:56:45 +0530 Subject: [PATCH] post_proc: fix noise at start of multichannel playback in hw_acc mode BufferProvider in hw_accelerator module is intialized with Downmix bufferProvider instead of track inputBufferProvider if Downmix module is configured in AudioMixer, this results in improper mixbuffer data for first threadloop_mix. Hw_accelerator module is updated with track inputBufferProvider correctly in next threadloop cycle when setBufferProvider is called again, resulting in correct output for rest of the playback. Fix this issue by using track inputBufferProvider as bufferProvider of hw_accelerator module during initial configuration. CRs-Fixed: 868620 Change-Id: Ia8b8ef472ff881d2de3b8094a8a48ce63a1a40cb --- post_proc/EffectsHwAcc.cpp | 26 ++++++++++++++------------ post_proc/EffectsHwAcc.h | 8 +++++--- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/post_proc/EffectsHwAcc.cpp b/post_proc/EffectsHwAcc.cpp index 0e4c55a7..e11cfc78 100644 --- a/post_proc/EffectsHwAcc.cpp +++ b/post_proc/EffectsHwAcc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, The Linux Foundation. All rights reserved. + * Copyright (c) 2014-15, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -72,7 +72,7 @@ status_t EffectsHwAcc::EffectsBufferProvider::getNextBuffer( size_t reqOutputFrameCount = pBuffer->frameCount; int ret = 0; - if (mTrackBufferProvider != NULL) { + if (mTrackInputBufferProvider != NULL) { while (1) { reqInputFrameCount = ((reqOutputFrameCount * mEffectsConfig.inputCfg.samplingRate)/ @@ -89,7 +89,7 @@ status_t EffectsHwAcc::EffectsBufferProvider::getNextBuffer( popcount(mEffectsConfig.inputCfg.channels); while (frameCount) { pBuffer->frameCount = frameCount; - ret = mTrackBufferProvider->getNextBuffer(pBuffer, pts); + ret = mTrackInputBufferProvider->getNextBuffer(pBuffer, pts); if (ret == OK) { int bytesInBuffer = pBuffer->frameCount * FRAME_SIZE(mEffectsConfig.inputCfg.format) * @@ -98,7 +98,7 @@ status_t EffectsHwAcc::EffectsBufferProvider::getNextBuffer( frameCount -= pBuffer->frameCount; mInputBufferFrameCountOffset += pBuffer->frameCount; offset += bytesInBuffer; - mTrackBufferProvider->releaseBuffer(pBuffer); + mTrackInputBufferProvider->releaseBuffer(pBuffer); } else break; } @@ -133,7 +133,7 @@ void EffectsHwAcc::EffectsBufferProvider::releaseBuffer( AudioBufferProvider::Buffer *pBuffer) { ALOGV("EffBufferProvider::releaseBuffer()"); - if (this->mTrackBufferProvider != NULL) { + if (this->mTrackInputBufferProvider != NULL) { pBuffer->frameCount = 0; pBuffer->raw = NULL; } else { @@ -189,7 +189,8 @@ void EffectsHwAcc::unprepareEffects(AudioBufferProvider **bufferProvider) mEnabled = false; } -status_t EffectsHwAcc::prepareEffects(AudioBufferProvider **bufferProvider, +status_t EffectsHwAcc::prepareEffects(AudioBufferProvider **inputBufferProvider, + AudioBufferProvider **bufferProvider, int sessionId, audio_channel_mask_t channelMask, int frameCount) @@ -316,10 +317,11 @@ status_t EffectsHwAcc::prepareEffects(AudioBufferProvider **bufferProvider, goto noEffectsForActiveTrack; } // initialization successful: - // - keep track of the real buffer provider in case it was set before + // - keep backup of track's buffer provider pHwAccbp->mTrackBufferProvider = *bufferProvider; - // - we'll use the hw acc effect integrated inside this - // track's buffer provider, and we'll use it as the track's buffer provider + pHwAccbp->mTrackInputBufferProvider = *inputBufferProvider; + // - we'll use the hw acc effect integrated inside this track's buffer provider, + // and we'll use it as the track's buffer provider mBufferProvider = pHwAccbp; *bufferProvider = pHwAccbp; @@ -332,14 +334,14 @@ noEffectsForActiveTrack: return NO_INIT; } -void EffectsHwAcc::setBufferProvider(AudioBufferProvider **bufferProvider, +void EffectsHwAcc::setBufferProvider(AudioBufferProvider **trackInputBufferProvider, AudioBufferProvider **trackBufferProvider) { ALOGV("setBufferProvider"); if (mBufferProvider && - (mBufferProvider->mTrackBufferProvider != *bufferProvider)) { + (mBufferProvider->mTrackInputBufferProvider != *trackInputBufferProvider)) { *trackBufferProvider = mBufferProvider; - mBufferProvider->mTrackBufferProvider = *bufferProvider; + mBufferProvider->mTrackInputBufferProvider = *trackInputBufferProvider; } } diff --git a/post_proc/EffectsHwAcc.h b/post_proc/EffectsHwAcc.h index 6420a9bf..0452f577 100644 --- a/post_proc/EffectsHwAcc.h +++ b/post_proc/EffectsHwAcc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, The Linux Foundation. All rights reserved. + * Copyright (c) 2014-15, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -43,10 +43,11 @@ public: virtual void setSampleRate(uint32_t inpSR, uint32_t outSR); virtual void unprepareEffects(AudioBufferProvider **trackBufferProvider); - virtual status_t prepareEffects(AudioBufferProvider **trackBufferProvider, + virtual status_t prepareEffects(AudioBufferProvider **trackInputBufferProvider, + AudioBufferProvider **trackBufferProvider, int sessionId, audio_channel_mask_t channelMask, int frameCount); - virtual void setBufferProvider(AudioBufferProvider **bufferProvider, + virtual void setBufferProvider(AudioBufferProvider **trackInputbufferProvider, AudioBufferProvider **trackBufferProvider); #ifdef HW_ACC_HPX virtual void updateHPXState(uint32_t state); @@ -62,6 +63,7 @@ public: virtual status_t getNextBuffer(Buffer* buffer, int64_t pts); virtual void releaseBuffer(Buffer* buffer); + AudioBufferProvider* mTrackInputBufferProvider; AudioBufferProvider* mTrackBufferProvider; effect_handle_t mEffectsHandle; effect_config_t mEffectsConfig;