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

Commit fd18f3c2 authored by Andy Hung's avatar Andy Hung
Browse files

FastPath: More clang-tidy optimizations

use-default-member-init

Test: ALLOW_LOCAL_TIDY_TRUE=1 mm -j .
Test: atest AudioTrackTest AudioRecordTest
Bug: 284390461
Merged-In: I4b5570bcbe3d4c3df890d87f547bab1de3c62187
Change-Id: I4b5570bcbe3d4c3df890d87f547bab1de3c62187
(cherry picked from commit 87e740a6)
parent 71f05bab
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -61,16 +61,7 @@ fastpath_tidy_errors = [
    "-bugprone-narrowing-conversions", // b/182410845

    // TODO(b/275642749) Reenable these warnings
    "-bugprone-assignment-in-if-condition",
    "-bugprone-forward-declaration-namespace",
    "-bugprone-parent-virtual-call",
    "-cert-dcl59-cpp",
    "-cert-err34-c",
    "-google-runtime-int",
    "-misc-non-private-member-variables-in-classes",
    "-modernize-concat-nested-namespaces",
    "-modernize-loop-convert",
    "-modernize-use-default-member-init",
    "-performance-no-int-to-ptr",
]

+3 −7
Original line number Diff line number Diff line
@@ -30,17 +30,13 @@

namespace android {

/*static*/ const FastCaptureState FastCapture::sInitial;
/*static*/ const FastCaptureState FastCapture::sInitial{};

FastCapture::FastCapture() : FastThread("cycleC_ms", "loadC_us"),
    mInputSource(nullptr), mInputSourceGen(0), mPipeSink(nullptr), mPipeSinkGen(0),
    mReadBuffer(nullptr), mReadBufferState(-1), mFormat(Format_Invalid), mSampleRate(0),
    // mDummyDumpState
    mTotalNativeFramesRead(0)
FastCapture::FastCapture() : FastThread("cycleC_ms", "loadC_us")
{
    // base class initialization
    mPrevious = &sInitial;
    mCurrent = &sInitial;

    mDummyDumpState = &mDummyFastCaptureDumpState;
}

+10 −10
Original line number Diff line number Diff line
@@ -48,17 +48,17 @@ private:

    FastCaptureState    mPreIdle;   // copy of state before we went into idle
    // FIXME by renaming, could pull up many of these to FastThread
    NBAIO_Source*       mInputSource;
    int                 mInputSourceGen;
    NBAIO_Sink*         mPipeSink;
    int                 mPipeSinkGen;
    void*               mReadBuffer;
    ssize_t             mReadBufferState;   // number of initialized frames in readBuffer,
    NBAIO_Source*       mInputSource = nullptr;
    int                 mInputSourceGen = 0;
    NBAIO_Sink*         mPipeSink = nullptr;
    int                 mPipeSinkGen = 0;
    void*               mReadBuffer = nullptr;
    ssize_t             mReadBufferState = -1;  // number of initialized frames in readBuffer,
                                                // or -1 to clear
    NBAIO_Format        mFormat;
    unsigned            mSampleRate;
    NBAIO_Format        mFormat = Format_Invalid;
    unsigned            mSampleRate = 0;
    FastCaptureDumpState mDummyFastCaptureDumpState;
    uint32_t            mTotalNativeFramesRead; // copied to dumpState->mFramesRead
    uint32_t            mTotalNativeFramesRead = 0; // copied to dumpState->mFramesRead

};  // class FastCapture

+0 −5
Original line number Diff line number Diff line
@@ -24,11 +24,6 @@

namespace android {

FastCaptureDumpState::FastCaptureDumpState() : FastThreadDumpState(),
    mReadSequence(0), mFramesRead(0), mReadErrors(0), mSampleRate(0), mFrameCount(0)
{
}

void FastCaptureDumpState::dump(int fd) const
{
    if (mCommand == FastCaptureState::INITIAL) {
+5 −7
Original line number Diff line number Diff line
@@ -24,16 +24,14 @@
namespace android {

struct FastCaptureDumpState : FastThreadDumpState {
    FastCaptureDumpState();

    void dump(int fd) const;    // should only be called on a stable copy, not the original

    // FIXME by renaming, could pull up many of these to FastThreadDumpState
    uint32_t mReadSequence;     // incremented before and after each read()
    uint32_t mFramesRead;       // total number of frames read successfully
    uint32_t mReadErrors;       // total number of read() errors
    uint32_t mSampleRate;
    size_t   mFrameCount;
    uint32_t mReadSequence = 0;  // incremented before and after each read()
    uint32_t mFramesRead = 0;    // total number of frames read successfully
    uint32_t mReadErrors = 0;    // total number of read() errors
    uint32_t mSampleRate = 0;
    size_t   mFrameCount = 0;
    bool     mSilenced = false; // capture is silenced
};

Loading