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

Commit b8bddf5e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "aaudio: convert I16 input to float" into pi-dev

parents 258fb48d 3d786cb5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ cc_library {

    shared_libs: [
        "libaudioclient",
        "libaudioutils",
        "liblog",
        "libcutils",
        "libutils",
+1 −1
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) {
    setInputPreset(configurationOutput.getInputPreset());

    // Save device format so we can do format conversion and volume scaling together.
    mDeviceFormat = configurationOutput.getFormat();
    setDeviceFormat(configurationOutput.getFormat());

    result = mServiceInterface.getStreamDescription(mServiceStreamHandle, mEndPointParcelable);
    if (result != AAUDIO_OK) {
+0 −5
Original line number Diff line number Diff line
@@ -138,8 +138,6 @@ protected:
    // Calculate timeout for an operation involving framesPerOperation.
    int64_t calculateReasonableTimeout(int32_t framesPerOperation);

    aaudio_format_t getDeviceFormat() const { return mDeviceFormat; }

    int32_t getDeviceChannelCount() const { return mDeviceChannelCount; }

    /**
@@ -195,9 +193,6 @@ private:

    int64_t                  mServiceLatencyNanos = 0;

    // Sometimes the hardware is operating with a different format or channel count from the app.
    // Then we require conversion in AAudio.
    aaudio_format_t          mDeviceFormat = AAUDIO_FORMAT_UNSPECIFIED;
    int32_t                  mDeviceChannelCount = 0;
};

+0 −1
Original line number Diff line number Diff line
@@ -367,7 +367,6 @@ aaudio_result_t AudioStream::joinThread(void** returnArg, int64_t timeoutNanosec
    return err ? AAudioConvert_androidToAAudioResult(-errno) : mThreadRegistrationResult;
}


aaudio_data_callback_result_t AudioStream::maybeCallDataCallback(void *audioData,
                                                                 int32_t numFrames) {
    aaudio_data_callback_result_t result = AAUDIO_CALLBACK_RESULT_STOP;
+44 −1
Original line number Diff line number Diff line
@@ -252,6 +252,20 @@ public:
        return AAudioConvert_formatToSizeInBytes(mFormat);
    }

    /**
     * This is only valid after setSamplesPerFrame() and setDeviceFormat() have been called.
     */
    int32_t getBytesPerDeviceFrame() const {
        return mSamplesPerFrame * getBytesPerDeviceSample();
    }

    /**
     * This is only valid after setDeviceFormat() has been called.
     */
    int32_t getBytesPerDeviceSample() const {
        return AAudioConvert_formatToSizeInBytes(getDeviceFormat());
    }

    virtual int64_t getFramesWritten() = 0;

    virtual int64_t getFramesRead() = 0;
@@ -471,6 +485,17 @@ protected:
        mFormat = format;
    }

    /**
     * This should not be called after the open() call.
     */
    void setDeviceFormat(aaudio_format_t format) {
        mDeviceFormat = format;
    }

    aaudio_format_t getDeviceFormat() const {
        return mDeviceFormat;
    }

    void setState(aaudio_stream_state_t state);

    void setDeviceId(int32_t deviceId) {
@@ -485,9 +510,23 @@ protected:

    float                mDuckAndMuteVolume = 1.0f;


protected:

    /**
     * Either convert the data from device format to app format and return a pointer
     * to the conversion buffer,
     * OR just pass back the original pointer.
     *
     * Note that this is only used for the INPUT path.
     *
     * @param audioData
     * @param numFrames
     * @return original pointer or the conversion buffer
     */
    virtual const void * maybeConvertDeviceData(const void *audioData, int32_t numFrames) {
        return audioData;
    }

    void setPeriodNanoseconds(int64_t periodNanoseconds) {
        mPeriodNanoseconds.store(periodNanoseconds, std::memory_order_release);
    }
@@ -539,6 +578,10 @@ private:

    int32_t                     mSessionId = AAUDIO_UNSPECIFIED;

    // Sometimes the hardware is operating with a different format from the app.
    // Then we require conversion in AAudio.
    aaudio_format_t             mDeviceFormat = AAUDIO_FORMAT_UNSPECIFIED;

    // callback ----------------------------------

    AAudioStream_dataCallback   mDataCallbackProc = nullptr;  // external callback functions
Loading