80,351
社区成员
发帖
与我相关
我的任务
分享
void AudioFlinger::EffectChain::process_l()
{
LOGD("##AudioFlinger::EffectChain::process_l---------------------------\n");
sp<ThreadBase> thread = mThread.promote();
if (thread == 0) {
LOGW("process_l(): cannot promote mixer thread");
return;
}
bool isGlobalSession = (mSessionId == AUDIO_SESSION_OUTPUT_MIX) ||
(mSessionId == AUDIO_SESSION_OUTPUT_STAGE);
// always process effects unless no more tracks are on the session and the effect tail
// has been rendered
LOGD("mSessionId=%d,isGlobalSession=%d, mTailBufferCount=%d, trackCont()=%d,", mSessionId, isGlobalSession, mTailBufferCount, trackCnt());
bool doProcess = true;
if (!isGlobalSession) {
bool tracksOnSession = (trackCnt() != 0);
if (!tracksOnSession && mTailBufferCount == 0) {
doProcess = false;
}
LOGD("tracksOnSession=%d, mTailBufferCount=%d,", tracksOnSession, mTailBufferCount);
if (activeTrackCnt() == 0) {
// if no track is active and the effect tail has not been rendered,
// the input buffer must be cleared here as the mixer process will not do it
if (tracksOnSession || mTailBufferCount > 0) {
size_t numSamples = thread->frameCount() * thread->channelCount();
memset(mInBuffer, 0, numSamples * sizeof(int16_t));
if (mTailBufferCount > 0) {
mTailBufferCount--;
}
}
}
}
size_t size = mEffects.size();
// doProcess = true;
LOGD("##AudioFlinger::EffectChain::process_l,size=%d,doProcess=%d,---------------------------\n",size, doProcess);
if (doProcess) {
for (size_t i = 0; i < size; i++) {
LOGD("effect %s,----------------------------------\n", mEffects[i]->mDescriptor.name);
mEffects[i]->process();
}
}
for (size_t i = 0; i < size; i++) {
mEffects[i]->updateState();
}
}