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

Commit dc2f403f authored by Shunkai Yao's avatar Shunkai Yao Committed by Gerrit Code Review
Browse files

Merge changes from topic "variable_latency_api"

* changes:
  audio flinger: rename Bluetooth latency mode APIs
  audio flinger: Bluetooth latency mode control
parents 6a341dd4 49879b76
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -2426,6 +2426,32 @@ status_t AudioSystem::getSupportedLatencyModes(audio_io_handle_t output,
    return af->getSupportedLatencyModes(output, modes);
}

status_t AudioSystem::setBluetoothVariableLatencyEnabled(bool enabled) {
    const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
    if (af == nullptr) {
        return PERMISSION_DENIED;
    }
    return af->setBluetoothVariableLatencyEnabled(enabled);
}

status_t AudioSystem::isBluetoothVariableLatencyEnabled(
        bool *enabled) {
    const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
    if (af == nullptr) {
        return PERMISSION_DENIED;
    }
    return af->isBluetoothVariableLatencyEnabled(enabled);
}

status_t AudioSystem::supportsBluetoothVariableLatency(
        bool *support) {
    const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
    if (af == nullptr) {
        return PERMISSION_DENIED;
    }
    return af->supportsBluetoothVariableLatency(support);
}

class CaptureStateListenerImpl : public media::BnCaptureStateListener,
                                 public IBinder::DeathRecipient {
public:
+38 −0
Original line number Diff line number Diff line
@@ -837,6 +837,32 @@ status_t AudioFlingerClientAdapter::getSupportedLatencyModes(
    return NO_ERROR;
}

status_t AudioFlingerClientAdapter::setBluetoothVariableLatencyEnabled(bool enabled) {
    return statusTFromBinderStatus(mDelegate->setBluetoothVariableLatencyEnabled(enabled));
}

status_t AudioFlingerClientAdapter::isBluetoothVariableLatencyEnabled(bool* enabled) {
    if (enabled == nullptr) {
        return BAD_VALUE;
    }

    RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
            mDelegate->isBluetoothVariableLatencyEnabled(enabled)));

    return NO_ERROR;
}

status_t AudioFlingerClientAdapter::supportsBluetoothVariableLatency(bool* support) {
    if (support == nullptr) {
        return BAD_VALUE;
    }

    RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(
            mDelegate->supportsBluetoothVariableLatency(support)));

    return NO_ERROR;
}

////////////////////////////////////////////////////////////////////////////////////////////////////
// AudioFlingerServerAdapter
AudioFlingerServerAdapter::AudioFlingerServerAdapter(
@@ -1357,4 +1383,16 @@ Status AudioFlingerServerAdapter::getSupportedLatencyModes(
    return Status::ok();
}

Status AudioFlingerServerAdapter::setBluetoothVariableLatencyEnabled(bool enabled) {
    return Status::fromStatusT(mDelegate->setBluetoothVariableLatencyEnabled(enabled));
}

Status AudioFlingerServerAdapter::isBluetoothVariableLatencyEnabled(bool *enabled) {
    return Status::fromStatusT(mDelegate->isBluetoothVariableLatencyEnabled(enabled));
}

Status AudioFlingerServerAdapter::supportsBluetoothVariableLatency(bool *support) {
    return Status::fromStatusT(mDelegate->supportsBluetoothVariableLatency(support));
}

} // namespace android
+20 −0
Original line number Diff line number Diff line
@@ -246,6 +246,26 @@ interface IAudioFlingerService {
     */
    AudioLatencyMode[] getSupportedLatencyModes(int output);

    /**
     * Requests if the implementation supports controlling the latency modes
     * over the Bluetooth A2DP or LE Audio links. If it does,
     * setRequestedLatencyMode() and getSupportedLatencyModes() APIs can also be used
     * for streams routed to Bluetooth and not just for the spatializer output.
     */
     boolean supportsBluetoothVariableLatency();

    /**
     * Enables or disables the variable Bluetooth latency control mechanism in the
     * audio framework and the audio HAL. This does not apply to the latency mode control
     * on the spatializer output as this is a built-in feature.
     */
    void setBluetoothVariableLatencyEnabled(boolean enabled);

    /**
     * Indicates if the variable Bluetooth latency control mechanism is enabled or disabled.
     */
    boolean isBluetoothVariableLatencyEnabled();

    // When adding a new method, please review and update
    // IAudioFlinger.h AudioFlingerServerAdapter::Delegate::TransactionCode
    // AudioFlinger.cpp AudioFlinger::onTransactWrapper()
+6 −0
Original line number Diff line number Diff line
@@ -575,6 +575,12 @@ public:
    static status_t getSupportedLatencyModes(audio_io_handle_t output,
            std::vector<audio_latency_mode_t>* modes);

    static status_t setBluetoothVariableLatencyEnabled(bool enabled);

    static status_t isBluetoothVariableLatencyEnabled(bool *enabled);

    static status_t supportsBluetoothVariableLatency(bool *support);

    // A listener for capture state changes.
    class CaptureStateListener : public virtual RefBase {
    public:
+17 −0
Original line number Diff line number Diff line
@@ -367,6 +367,11 @@ public:
    virtual status_t getSupportedLatencyModes(audio_io_handle_t output,
            std::vector<audio_latency_mode_t>* modes) = 0;

    virtual status_t setBluetoothVariableLatencyEnabled(bool enabled) = 0;

    virtual status_t isBluetoothVariableLatencyEnabled(bool* enabled) = 0;

    virtual status_t supportsBluetoothVariableLatency(bool* support) = 0;
};

/**
@@ -473,6 +478,9 @@ public:
            audio_latency_mode_t mode) override;
    status_t getSupportedLatencyModes(
            audio_io_handle_t output, std::vector<audio_latency_mode_t>* modes) override;
    status_t setBluetoothVariableLatencyEnabled(bool enabled) override;
    status_t isBluetoothVariableLatencyEnabled(bool* enabled) override;
    status_t supportsBluetoothVariableLatency(bool* support) override;

private:
    const sp<media::IAudioFlingerService> mDelegate;
@@ -564,6 +572,12 @@ public:
            SET_DEVICE_CONNECTED_STATE = media::BnAudioFlingerService::TRANSACTION_setDeviceConnectedState,
            SET_REQUESTED_LATENCY_MODE = media::BnAudioFlingerService::TRANSACTION_setRequestedLatencyMode,
            GET_SUPPORTED_LATENCY_MODES = media::BnAudioFlingerService::TRANSACTION_getSupportedLatencyModes,
            SET_BLUETOOTH_VARIABLE_LATENCY_ENABLED =
                    media::BnAudioFlingerService::TRANSACTION_setBluetoothVariableLatencyEnabled,
            IS_BLUETOOTH_VARIABLE_LATENCY_ENABLED =
                    media::BnAudioFlingerService::TRANSACTION_isBluetoothVariableLatencyEnabled,
            SUPPORTS_BLUETOOTH_VARIABLE_LATENCY =
                    media::BnAudioFlingerService::TRANSACTION_supportsBluetoothVariableLatency,
        };

    protected:
@@ -689,6 +703,9 @@ public:
            int output, media::audio::common::AudioLatencyMode mode) override;
    Status getSupportedLatencyModes(int output,
            std::vector<media::audio::common::AudioLatencyMode>* _aidl_return) override;
    Status setBluetoothVariableLatencyEnabled(bool enabled) override;
    Status isBluetoothVariableLatencyEnabled(bool* enabled) override;
    Status supportsBluetoothVariableLatency(bool* support) override;
private:
    const sp<AudioFlingerServerAdapter::Delegate> mDelegate;
};
Loading