Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b2254761 authored by Subhash Chandra Bose Naripeddy's avatar Subhash Chandra Bose Naripeddy Committed by Steve Kondik
Browse files

audioflinger: Fix apply SRS effects if tones diabled in tunnel mode

For the use case of SRS post processing in Tunnel mode, the API's
of SRS are called only from write. With the huge buffering for
tunnel mode, once EOS is received there would not be further write.
With system tone enabled, the SRS API's are called during the
check for Parameters change through normal mixer thread.
With system tones disabled, SRS will not be applied after EOS as
no write and mixer thread would not be active.

Fix the issue by adding the Effects Thread for SRS in Tunnel mode.
Fix the compilation issue with ALOGV messages enabled

Change-Id: Ic7e62894840f786119dfe8ae471c5d24812917d7
parent 7f8c8935
Loading
Loading
Loading
Loading
+36 −10
Original line number Diff line number Diff line
@@ -6361,6 +6361,13 @@ AudioFlinger::DirectAudioTrack::DirectAudioTrack(const sp<AudioFlinger>& audioFl
        mAudioFlinger->registerClient(mAudioFlingerClient);

        allocateBufPool();
#ifdef SRS_PROCESSING
    } else if (mFlag & AUDIO_OUTPUT_FLAG_TUNNEL) {
        ALOGV("create effects thread for TUNNEL");
        createEffectThread();
        mAudioFlingerClient = new AudioFlingerDirectTrackClient(this);
        mAudioFlinger->registerClient(mAudioFlingerClient);
#endif
    }
    outputDesc->mVolumeScale = 1.0;
    mDeathRecipient = new PMDeathRecipient(this);
@@ -6377,6 +6384,12 @@ AudioFlinger::DirectAudioTrack::~DirectAudioTrack() {
        mAudioFlinger->deregisterClient(mAudioFlingerClient);
        mAudioFlinger->deleteEffectSession();
        deallocateBufPool();
#ifdef SRS_PROCESSING
    } else if (mFlag & AUDIO_OUTPUT_FLAG_TUNNEL) {
        requestAndWaitForEffectsThreadExit();
        mAudioFlinger->deregisterClient(mAudioFlingerClient);
        mAudioFlinger->deleteEffectSession();
#endif
    }
    AudioSystem::releaseOutput(mOutput);
    releaseWakeLock();
@@ -6553,9 +6566,11 @@ void AudioFlinger::DirectAudioTrack::EffectsThreadEntry() {

        if (mEffectConfigChanged) {
            mEffectConfigChanged = false;
            if (mFlag & AUDIO_OUTPUT_FLAG_LPA) {
                for ( List<BufferInfo>::iterator it = mEffectsPool.begin();
                      it != mEffectsPool.end(); it++) {
                ALOGV("Apply effects on the buffer dspbuf %p, mEffectsPool.size() %d",it->dspBuf,mEffectsPool.size());
                    ALOGV("Apply effects on the buffer dspbuf %p, mEffectsPool.size() %d",
                             it->dspBuf,mEffectsPool.size());
                    mAudioFlinger->applyEffectsOn(static_cast<void *>(this),
                                                  (int16_t *)it->localBuf,
                                                  (int16_t *)it->dspBuf,
@@ -6564,7 +6579,18 @@ void AudioFlinger::DirectAudioTrack::EffectsThreadEntry() {
                        break;
                    }
                }

#ifdef SRS_PROCESSING
            } else if (mFlag & AUDIO_OUTPUT_FLAG_TUNNEL) {
                ALOGV("applying effects for TUNNEL");
                char buffer[2];
                    //dummy buffer to ensure the SRS processing takes place
                    // The API mandates Sample rate and channel mode. Hence
                    // defaulted the sample rate channel mode to 48000 and 2 respectively
                POSTPRO_PATCH_ICS_OUTPROC_DIRECT_SAMPLES(static_cast<void *>(this),
                                                         AUDIO_FORMAT_PCM_16_BIT,
                                                        (int16_t*)buffer, 2, 48000, 2);
#endif
            }
        }
        mEffectLock.unlock();
    }