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

Commit bc2261f9 authored by Atneya Nair's avatar Atneya Nair Committed by Automerger Merge Worker
Browse files

Merge "Change total sample count type to 64 bit" into tm-dev am: 85a25fc5

parents 519d4199 85a25fc5
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "ToneGenerator"

#include <inttypes.h>
#include <utility>

#include <math.h>
@@ -1229,7 +1230,8 @@ void ToneGenerator::stopTone() {
                    sec = sec * 1000 + nsec / 1000000; // duration in milliseconds
                    mMaxSmp = (unsigned int)(((int64_t)sec * mSamplingRate) / 1000);
                }
                ALOGV("stopTone() forcing mMaxSmp to %d, total for far %d", mMaxSmp,  mTotalSmp);
                ALOGV("stopTone() forcing mMaxSmp to %d, total for far %" PRIu64, mMaxSmp,
                      mTotalSmp);
            } else {
                mState = TONE_STOPPING;
            }
@@ -1399,7 +1401,7 @@ size_t ToneGenerator::onMoreData(const AudioTrack::Buffer& buffer) {
            mNextSegSmp = TONEGEN_INF; // forced to skip state machine management below
        }

        if (mTotalSmp > mNextSegSmp) {
        if (mTotalSmp > mNextSegSmp && mNextSegSmp != TONEGEN_INF) {
            // Time to go to next sequence segment

            ALOGV("End Segment, time: %d", (unsigned int)(systemTime()/1000000));
+3 −4
Original line number Diff line number Diff line
@@ -287,11 +287,10 @@ private:
    static const ToneDescriptor sToneDescriptors[];

    bool mThreadCanCallJava;
    unsigned int mTotalSmp;  // Total number of audio samples played (gives current time)
    uint64_t mTotalSmp;  // Total number of audio samples played (gives current time)
    // Since these types are 32 bit, we may have issues with aborting on
    // overflow now that we have integer overflow sanitization enabled globally.
    unsigned int mNextSegSmp;  // Position of next segment transition expressed in samples
    // NOTE: because mTotalSmp, mNextSegSmp are stored on 32 bit, current design will operate properly
    // only if tone duration is less than about 27 Hours(@44100Hz sampling rate). If this time is exceeded,
    // no crash will occur but tone sequence will show a glitch.
    unsigned int mMaxSmp;  // Maximum number of audio samples played (maximun tone duration)
    int mDurationMs;  // Maximum tone duration in ms