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

Commit 0e7cdae3 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

release-request-4850daec-e2fc-44da-a2dc-4646a78e4550-for-git_oc-dr1-release-39...

release-request-4850daec-e2fc-44da-a2dc-4646a78e4550-for-git_oc-dr1-release-3944849 snap-temp-L34500000057864766

Change-Id: Id6ef9a1ecb52d9ea76358b07fbf000bbd8cf3e73
parents 96c0b2f9 b5ef3889
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -295,6 +295,8 @@ public:
    std::string toString() const {
        std::stringstream ss;
        ss << "mInterpolatorType: " << mInterpolatorType << std::endl;
        ss << "mFirstSlope: " << mFirstSlope << std::endl;
        ss << "mLastSlope: " << mLastSlope << std::endl;
        for (const auto &pt : *this) {
            ss << pt.first << " " << pt.second << std::endl;
        }
+24 −10
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ public:
            , mId(-1) {
        }

        Configuration(const Configuration &configuration)
        explicit Configuration(const Configuration &configuration)
            : Interpolator<S, T>(*static_cast<const Interpolator<S, T> *>(&configuration))
            , mType(configuration.mType)
            , mOptionFlags(configuration.mOptionFlags)
@@ -236,6 +236,7 @@ public:
            clampVolume();
        }

        // The parcel layout must match VolumeShaper.java
        status_t writeToParcel(Parcel *parcel) const {
            if (parcel == nullptr) return BAD_VALUE;
            return parcel->writeInt32((int32_t)mType)
@@ -300,15 +301,19 @@ public:
            : Operation(FLAG_NONE, -1 /* replaceId */) {
        }

        explicit Operation(Flag flags, int replaceId)
        Operation(Flag flags, int replaceId)
            : Operation(flags, replaceId, std::numeric_limits<S>::quiet_NaN() /* xOffset */) {
        }

        Operation(const Operation &operation)
        explicit Operation(const Operation &operation)
            : Operation(operation.mFlags, operation.mReplaceId, operation.mXOffset) {
        }

        explicit Operation(Flag flags, int replaceId, S xOffset)
        explicit Operation(const sp<Operation> &operation)
            : Operation(*operation.get()) {
        }

        Operation(Flag flags, int replaceId, S xOffset)
            : mFlags(flags)
            , mReplaceId(replaceId)
            , mXOffset(xOffset) {
@@ -375,7 +380,7 @@ public:
    // must match with VolumeShaper.java in frameworks/base
    class State : public RefBase {
    public:
        explicit State(T volume, S xOffset)
        State(T volume, S xOffset)
            : mVolume(volume)
            , mXOffset(xOffset) {
        }
@@ -480,7 +485,7 @@ public:
    // TODO: Since we pass configuration and operation as shared pointers
    // there is a potential risk that the caller may modify these after
    // delivery.  Currently, we don't require copies made here.
    explicit VolumeShaper(
    VolumeShaper(
            const sp<VolumeShaper::Configuration> &configuration,
            const sp<VolumeShaper::Operation> &operation)
        : mConfiguration(configuration) // we do not make a copy
@@ -628,7 +633,8 @@ public:
    explicit VolumeHandler(uint32_t sampleRate)
        : mSampleRate((double)sampleRate)
        , mLastFrame(0)
        , mVolumeShaperIdCounter(VolumeShaper::kSystemIdMax) {
        , mVolumeShaperIdCounter(VolumeShaper::kSystemIdMax)
        , mLastVolume(1.f, false) {
    }

    VolumeShaper::Status applyVolumeShaper(
@@ -758,7 +764,13 @@ public:
            activeCount += shaperVolume.second;
            ++it;
        }
        return std::make_pair(volume, activeCount != 0);
        mLastVolume = std::make_pair(volume, activeCount != 0);
        return mLastVolume;
    }

    std::pair<T /* volume */, bool /* active */> getLastVolume() const {
        AutoMutex _l(mLock);
        return mLastVolume;
    }

    std::string toString() const {
@@ -776,6 +788,7 @@ public:
            const sp<VolumeShaper::Configuration> &configuration,
            const sp<VolumeShaper::Operation> &operation)> &lambda) {
        AutoMutex _l(mLock);
        VS_LOG("forall: mVolumeShapers.size() %zu", mVolumeShapers.size());
        for (const auto &shaper : mVolumeShapers) {
            VS_LOG("forall applying lambda");
            (void)lambda(shaper.mConfiguration, shaper.mOperation);
@@ -785,7 +798,7 @@ public:
    void reset() {
        AutoMutex _l(mLock);
        mVolumeShapers.clear();
        mLastFrame = -1;
        mLastFrame = 0;
        // keep mVolumeShaperIdCounter as is.
    }

@@ -827,8 +840,9 @@ private:

    mutable Mutex mLock;
    double mSampleRate; // in samples (frames) per second
    int64_t mLastFrame; // logging purpose only
    int64_t mLastFrame; // logging purpose only, 0 on start
    int32_t mVolumeShaperIdCounter; // a counter to return a unique volume shaper id.
    std::pair<T /* volume */, bool /* active */> mLastVolume;
    std::list<VolumeShaper> mVolumeShapers; // list provides stable iterators on erase
}; // VolumeHandler

+15 −15
Original line number Diff line number Diff line
@@ -63,8 +63,8 @@ int main(int argc, char **argv)

    aaudio_result_t result = AAUDIO_OK;

    const int requestedSamplesPerFrame = 2;
    int actualSamplesPerFrame = 0;
    const int requestedChannelCount = 2;
    int actualChannelCount = 0;
    const int requestedSampleRate = SAMPLE_RATE;
    int actualSampleRate = 0;
    aaudio_audio_format_t actualDataFormat = AAUDIO_FORMAT_UNSPECIFIED;
@@ -90,7 +90,7 @@ int main(int argc, char **argv)
    // in a buffer if we hang or crash.
    setvbuf(stdout, nullptr, _IONBF, (size_t) 0);

    printf("%s - Play a sine wave using AAudio, Z2\n", argv[0]);
    printf("%s - Play a sine wave using AAudio\n", argv[0]);

    // Use an AAudioStreamBuilder to contain requested parameters.
    result = AAudio_createStreamBuilder(&aaudioBuilder);
@@ -100,7 +100,7 @@ int main(int argc, char **argv)

    // Request stream properties.
    AAudioStreamBuilder_setSampleRate(aaudioBuilder, requestedSampleRate);
    AAudioStreamBuilder_setSamplesPerFrame(aaudioBuilder, requestedSamplesPerFrame);
    AAudioStreamBuilder_setChannelCount(aaudioBuilder, requestedChannelCount);
    AAudioStreamBuilder_setFormat(aaudioBuilder, REQUESTED_FORMAT);
    AAudioStreamBuilder_setSharingMode(aaudioBuilder, REQUESTED_SHARING_MODE);

@@ -120,9 +120,9 @@ int main(int argc, char **argv)
    sineOsc1.setup(440.0, actualSampleRate);
    sineOsc2.setup(660.0, actualSampleRate);

    actualSamplesPerFrame = AAudioStream_getSamplesPerFrame(aaudioStream);
    printf("SamplesPerFrame: requested = %d, actual = %d\n",
            requestedSamplesPerFrame, actualSamplesPerFrame);
    actualChannelCount = AAudioStream_getChannelCount(aaudioStream);
    printf("ChannelCount: requested = %d, actual = %d\n",
            requestedChannelCount, actualChannelCount);

    actualSharingMode = AAudioStream_getSharingMode(aaudioStream);
    printf("SharingMode: requested = %s, actual = %s\n",
@@ -152,9 +152,9 @@ int main(int argc, char **argv)

    // Allocate a buffer for the audio data.
    if (actualDataFormat == AAUDIO_FORMAT_PCM_FLOAT) {
        floatData = new float[framesPerWrite * actualSamplesPerFrame];
        floatData = new float[framesPerWrite * actualChannelCount];
    } else if (actualDataFormat == AAUDIO_FORMAT_PCM_I16) {
        shortData = new int16_t[framesPerWrite * actualSamplesPerFrame];
        shortData = new int16_t[framesPerWrite * actualChannelCount];
    } else {
        printf("ERROR Unsupported data format!\n");
        goto finish;
@@ -178,15 +178,15 @@ int main(int argc, char **argv)

        if (actualDataFormat == AAUDIO_FORMAT_PCM_FLOAT) {
            // Render sine waves to left and right channels.
            sineOsc1.render(&floatData[0], actualSamplesPerFrame, framesPerWrite);
            if (actualSamplesPerFrame > 1) {
                sineOsc2.render(&floatData[1], actualSamplesPerFrame, framesPerWrite);
            sineOsc1.render(&floatData[0], actualChannelCount, framesPerWrite);
            if (actualChannelCount > 1) {
                sineOsc2.render(&floatData[1], actualChannelCount, framesPerWrite);
            }
        } else if (actualDataFormat == AAUDIO_FORMAT_PCM_I16) {
            // Render sine waves to left and right channels.
            sineOsc1.render(&shortData[0], actualSamplesPerFrame, framesPerWrite);
            if (actualSamplesPerFrame > 1) {
                sineOsc2.render(&shortData[1], actualSamplesPerFrame, framesPerWrite);
            sineOsc1.render(&shortData[0], actualChannelCount, framesPerWrite);
            if (actualChannelCount > 1) {
                sineOsc2.render(&shortData[1], actualChannelCount, framesPerWrite);
            }
        }

+5 −5
Original line number Diff line number Diff line
@@ -65,11 +65,11 @@ public:
    /**
     * Only call this after open() has been called.
     */
    int32_t getSamplesPerFrame() {
    int32_t getChannelCount() {
        if (mStream == nullptr) {
            return AAUDIO_ERROR_INVALID_STATE;
        }
        return AAudioStream_getSamplesPerFrame(mStream);;
        return AAudioStream_getChannelCount(mStream);;
    }

    /**
@@ -119,7 +119,7 @@ public:

    // Write zero data to fill up the buffer and prevent underruns.
    aaudio_result_t prime() {
        int32_t samplesPerFrame = AAudioStream_getSamplesPerFrame(mStream);
        int32_t samplesPerFrame = AAudioStream_getChannelCount(mStream);
        const int numFrames = 32;
        float zeros[numFrames * samplesPerFrame];
        memset(zeros, 0, sizeof(zeros));
@@ -186,7 +186,7 @@ aaudio_data_callback_result_t MyDataCallbackProc(
        sineData->schedulerChecked = true;
    }

    int32_t samplesPerFrame = AAudioStream_getSamplesPerFrame(stream);
    int32_t samplesPerFrame = AAudioStream_getChannelCount(stream);
    // This code only plays on the first one or two channels.
    // TODO Support arbitrary number of channels.
    switch (AAudioStream_getFormat(stream)) {
@@ -239,7 +239,7 @@ int main(int argc, char **argv)
        goto error;
    }
    printf("player.getFramesPerSecond() = %d\n", player.getFramesPerSecond());
    printf("player.getSamplesPerFrame() = %d\n", player.getSamplesPerFrame());
    printf("player.getChannelCount() = %d\n", player.getChannelCount());
    myData.sineOsc1.setup(440.0, 48000);
    myData.sineOsc1.setSweep(300.0, 600.0, 5.0);
    myData.sineOsc2.setup(660.0, 48000);
+22 −4
Original line number Diff line number Diff line
@@ -206,18 +206,26 @@ AAUDIO_API void AAudioStreamBuilder_setSampleRate(AAudioStreamBuilder* builder,
                                                       int32_t sampleRate);

/**
 * Request a number of samples per frame.
 * Request a number of channels for the stream.
 *
 * The stream may be opened with a different value.
 * So the application should query for the actual value after the stream is opened.
 *
 * The default, if you do not call this function, is AAUDIO_UNSPECIFIED.
 *
 * Note, this quantity is sometimes referred to as "channel count".
 * Note, this quantity is sometimes referred to as "samples per frame".
 *
 * @param builder reference provided by AAudio_createStreamBuilder()
 * @param samplesPerFrame Number of samples in one frame, ie. numChannels.
 * @param channelCount Number of channels desired.
 */
AAUDIO_API void AAudioStreamBuilder_setChannelCount(AAudioStreamBuilder* builder,
                                                   int32_t channelCount);

/**
 *
 * @deprecated use AAudioStreamBuilder_setChannelCount()
 */
// TODO remove as soon as the NDK and OS are in sync, before RC1
AAUDIO_API void AAudioStreamBuilder_setSamplesPerFrame(AAudioStreamBuilder* builder,
                                                       int32_t samplesPerFrame);

@@ -676,9 +684,19 @@ AAUDIO_API int32_t AAudioStream_getXRunCount(AAudioStream* stream);
 */
AAUDIO_API int32_t AAudioStream_getSampleRate(AAudioStream* stream);

/**
 * A stream has one or more channels of data.
 * A frame will contain one sample for each channel.
 *
 * @param stream reference provided by AAudioStreamBuilder_openStream()
 * @return actual number of channels
 */
AAUDIO_API int32_t AAudioStream_getChannelCount(AAudioStream* stream);

/**
 * The samplesPerFrame is also known as channelCount.
 *
 * @deprecated use AAudioStream_getChannelCount()
 * @param stream reference provided by AAudioStreamBuilder_openStream()
 * @return actual samples per frame
 */
Loading