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

Commit b36bc776 authored by Andy Hung's avatar Andy Hung Committed by Android (Google) Code Review
Browse files

Merge "Reduce log messages on AudioFlinger throttle" into mnc-dev

parents 91b0018d 40eb1a1f
Loading
Loading
Loading
Loading
+15 −2
Original line number Original line Diff line number Diff line
@@ -2194,6 +2194,8 @@ void AudioFlinger::PlaybackThread::readOutputParameters_l()


    // Check if we want to throttle the processing to no more than 2x normal rate
    // Check if we want to throttle the processing to no more than 2x normal rate
    mThreadThrottle = property_get_bool("af.thread.throttle", true /* default_value */);
    mThreadThrottle = property_get_bool("af.thread.throttle", true /* default_value */);
    mThreadThrottleTimeMs = 0;
    mThreadThrottleEndMs = 0;
    mHalfBufferMs = mNormalFrameCount * 1000 / (2 * mSampleRate);
    mHalfBufferMs = mNormalFrameCount * 1000 / (2 * mSampleRate);


    // mSinkBuffer is the sink buffer.  Size is always multiple-of-16 frames.
    // mSinkBuffer is the sink buffer.  Size is always multiple-of-16 frames.
@@ -2960,8 +2962,19 @@ bool AudioFlinger::PlaybackThread::threadLoop()
                        const int32_t throttleMs = mHalfBufferMs - deltaMs;
                        const int32_t throttleMs = mHalfBufferMs - deltaMs;
                        if ((signed)mHalfBufferMs >= throttleMs && throttleMs > 0) {
                        if ((signed)mHalfBufferMs >= throttleMs && throttleMs > 0) {
                            usleep(throttleMs * 1000);
                            usleep(throttleMs * 1000);
                            ALOGD("mixer(%p) throttle: ret(%zd) deltaMs(%d) requires sleep %d ms",
                            // notify of throttle start on verbose log
                            ALOGV_IF(mThreadThrottleEndMs == mThreadThrottleTimeMs,
                                    "mixer(%p) throttle begin:"
                                    " ret(%zd) deltaMs(%d) requires sleep %d ms",
                                    this, ret, deltaMs, throttleMs);
                                    this, ret, deltaMs, throttleMs);
                            mThreadThrottleTimeMs += throttleMs;
                        } else {
                            uint32_t diff = mThreadThrottleTimeMs - mThreadThrottleEndMs;
                            if (diff > 0) {
                                // notify of throttle end on debug log
                                ALOGD("mixer(%p) throttle end: throttle time(%u)", this, diff);
                                mThreadThrottleEndMs = mThreadThrottleTimeMs;
                            }
                        }
                        }
                    }
                    }
                }
                }
@@ -4340,7 +4353,7 @@ void AudioFlinger::MixerThread::dumpInternals(int fd, const Vector<String16>& ar
    String8 result;
    String8 result;


    PlaybackThread::dumpInternals(fd, args);
    PlaybackThread::dumpInternals(fd, args);

    dprintf(fd, "  Thread throttle time (msecs): %u\n", mThreadThrottleTimeMs);
    dprintf(fd, "  AudioMixer tracks: 0x%08x\n", mAudioMixer->trackNames());
    dprintf(fd, "  AudioMixer tracks: 0x%08x\n", mAudioMixer->trackNames());


    // Make a non-atomic copy of fast mixer dump state so it won't change underneath us
    // Make a non-atomic copy of fast mixer dump state so it won't change underneath us
+2 −0
Original line number Original line Diff line number Diff line
@@ -614,6 +614,8 @@ protected:
    size_t                          mNormalFrameCount;  // normal mixer and effects
    size_t                          mNormalFrameCount;  // normal mixer and effects


    bool                            mThreadThrottle;     // throttle the thread processing
    bool                            mThreadThrottle;     // throttle the thread processing
    uint32_t                        mThreadThrottleTimeMs; // throttle time for MIXER threads
    uint32_t                        mThreadThrottleEndMs;  // notify once per throttling
    uint32_t                        mHalfBufferMs;       // half the buffer size in milliseconds
    uint32_t                        mHalfBufferMs;       // half the buffer size in milliseconds


    void*                           mSinkBuffer;         // frame size aligned sink buffer
    void*                           mSinkBuffer;         // frame size aligned sink buffer