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

Commit d3058a98 authored by Mikhail Naganov's avatar Mikhail Naganov Committed by Gerrit Code Review
Browse files

Merge "Use HAL-provided config for getInputBufferSize" into main

parents 0bdfd3d7 d5b643f0
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -271,15 +271,16 @@ status_t DeviceHalAidl::getParameters(const String8& keys, String8 *values) {
    return parseAndGetVendorParameters(mVendorExt, mModule, parameterKeys, values);
}

status_t DeviceHalAidl::getInputBufferSize(const struct audio_config* config, size_t* size) {
status_t DeviceHalAidl::getInputBufferSize(struct audio_config* config, size_t* size) {
    ALOGD("%p %s::%s", this, getClassName().c_str(), __func__);
    TIME_CHECK();
    if (mModule == nullptr) return NO_INIT;
    if (config == nullptr || size == nullptr) {
        return BAD_VALUE;
    }
    constexpr bool isInput = true;
    AudioConfig aidlConfig = VALUE_OR_RETURN_STATUS(
            ::aidl::android::legacy2aidl_audio_config_t_AudioConfig(*config, true /*isInput*/));
            ::aidl::android::legacy2aidl_audio_config_t_AudioConfig(*config, isInput));
    AudioDevice aidlDevice;
    aidlDevice.type.type = AudioDeviceType::IN_DEFAULT;
    AudioSource aidlSource = AudioSource::DEFAULT;
@@ -293,6 +294,9 @@ status_t DeviceHalAidl::getInputBufferSize(const struct audio_config* config, si
                        0 /*handle*/, aidlDevice, aidlFlags, aidlSource,
                        &cleanups, &aidlConfig, &mixPortConfig, &aidlPatch));
    }
    *config = VALUE_OR_RETURN_STATUS(
            ::aidl::android::aidl2legacy_AudioConfig_audio_config_t(aidlConfig, isInput));
    if (mixPortConfig.id == 0) return BAD_VALUE;  // HAL suggests a different config.
    *size = aidlConfig.frameCount *
            getFrameSizeInBytes(aidlConfig.base.format, aidlConfig.base.channelMask);
    // Do not disarm cleanups to release temporary port configs.
+1 −1
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ class DeviceHalAidl : public DeviceHalInterface, public ConversionHelperAidl,
    status_t getParameters(const String8& keys, String8 *values) override;

    // Returns audio input buffer size according to parameters passed.
    status_t getInputBufferSize(const struct audio_config* config, size_t* size) override;
    status_t getInputBufferSize(struct audio_config* config, size_t* size) override;

    // Creates and opens the audio hardware output stream. The stream is closed
    // by releasing all references to the returned object.
+1 −1
Original line number Diff line number Diff line
@@ -236,7 +236,7 @@ status_t DeviceHalHidl::getParameters(const String8& keys, String8 *values) {
}

status_t DeviceHalHidl::getInputBufferSize(
        const struct audio_config *config, size_t *size) {
        struct audio_config *config, size_t *size) {
    TIME_CHECK();
    if (mDevice == 0) return NO_INIT;
    AudioConfig hidlConfig;
+1 −1
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ class DeviceHalHidl : public DeviceHalInterface, public CoreConversionHelperHidl
    status_t getParameters(const String8& keys, String8 *values) override;

    // Returns audio input buffer size according to parameters passed.
    status_t getInputBufferSize(const struct audio_config* config, size_t* size) override;
    status_t getInputBufferSize(struct audio_config* config, size_t* size) override;

    // Creates and opens the audio hardware output stream. The stream is closed
    // by releasing all references to the returned object.
+3 −2
Original line number Diff line number Diff line
@@ -78,8 +78,9 @@ class DeviceHalInterface : public virtual RefBase
    virtual status_t getParameters(const String8& keys, String8 *values) = 0;

    // Returns audio input buffer size according to parameters passed.
    virtual status_t getInputBufferSize(const struct audio_config *config,
            size_t *size) = 0;
    // If there is no possibility for the HAL to open an input with the provided
    // parameters, the method will return BAD_VALUE and modify the provided `config`.
    virtual status_t getInputBufferSize(struct audio_config *config, size_t *size) = 0;

    // Creates and opens the audio hardware output stream. The stream is closed
    // by releasing all references to the returned object.
Loading