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

Commit 975cd6b1 authored by jiabin's avatar jiabin Committed by android-build-merger
Browse files

Merge "Copy haptic data directly from effect in buffer to out buffer." into qt-dev am: 4b99b0dc

am: b63d977c

Change-Id: I4b580191e46c8eaf2dc01adaf27455cf90be3846
parents 0edc4f46 b63d977c
Loading
Loading
Loading
Loading
+22 −0
Original line number Original line Diff line number Diff line
@@ -3610,8 +3610,30 @@ bool AudioFlinger::PlaybackThread::threadLoop()


            // only process effects if we're going to write
            // only process effects if we're going to write
            if (mSleepTimeUs == 0 && mType != OFFLOAD) {
            if (mSleepTimeUs == 0 && mType != OFFLOAD) {
                audio_session_t activeHapticId = AUDIO_SESSION_NONE;
                if (mHapticChannelCount > 0 && effectChains.size() > 0) {
                    for (auto track : mActiveTracks) {
                        if (track->getHapticPlaybackEnabled()) {
                            activeHapticId = track->sessionId();
                            break;
                        }
                    }
                }
                for (size_t i = 0; i < effectChains.size(); i ++) {
                for (size_t i = 0; i < effectChains.size(); i ++) {
                    effectChains[i]->process_l();
                    effectChains[i]->process_l();
                    // TODO: Write haptic data directly to sink buffer when mixing.
                    if (activeHapticId != AUDIO_SESSION_NONE
                            && activeHapticId == effectChains[i]->sessionId()) {
                        // Haptic data is active in this case, copy it directly from
                        // in buffer to out buffer.
                        const size_t audioBufferSize = mNormalFrameCount
                                * audio_bytes_per_frame(mChannelCount, EFFECT_BUFFER_FORMAT);
                        memcpy_by_audio_format(
                                (uint8_t*)effectChains[i]->outBuffer() + audioBufferSize,
                                EFFECT_BUFFER_FORMAT,
                                (const uint8_t*)effectChains[i]->inBuffer() + audioBufferSize,
                                EFFECT_BUFFER_FORMAT, mNormalFrameCount * mHapticChannelCount);
                    }
                }
                }
            }
            }
        }
        }