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

Commit 52057641 authored by Eric Laurent's avatar Eric Laurent
Browse files

audio flinger: Bluetooth latency mode control

Add APIs to discover support and control the use
of latency mode control over Bluetooth link.

Bug: 257922898
Test: make

Change-Id: I8d23a40f21465d566f0adc553cfc77e64571395e
parent 249f9147
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -2459,6 +2459,23 @@ status_t AudioSystem::getSupportedLatencyModes(audio_io_handle_t output,
    return af->getSupportedLatencyModes(output, modes);
}

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

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

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

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

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

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

    return NO_ERROR;
}

status_t AudioFlingerClientAdapter::getSoundDoseInterface(
        const sp<media::ISoundDoseCallback> &callback,
        sp<media::ISoundDose>* soundDose) {
@@ -1374,6 +1389,14 @@ Status AudioFlingerServerAdapter::getSupportedLatencyModes(
    return Status::ok();
}

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

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

Status AudioFlingerServerAdapter::getSoundDoseInterface(
        const sp<media::ISoundDoseCallback>& callback,
        sp<media::ISoundDose>* soundDose)
+15 −0
Original line number Diff line number Diff line
@@ -246,6 +246,21 @@ interface IAudioFlingerService {
     */
    LatencyMode[] getSupportedLatencyModes(int output);

    /**
     * Requests if the implementation supports controlling the latency modes
     * over the Bleutooth 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 supportsBluetoothLatencyModes();

    /**
     * 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 with is a built-in feature.
     */
    void setBluetoothLatencyModesEnabled(boolean enabled);

    /**
     * Registers the sound dose callback and returns the interface for executing
     * sound dose methods on the audio server.
+4 −0
Original line number Diff line number Diff line
@@ -629,6 +629,10 @@ public:
    static status_t getSupportedLatencyModes(audio_io_handle_t output,
            std::vector<audio_latency_mode_t>* modes);

    static status_t setBluetoothLatencyModesEnabled(bool enabled);

    static status_t supportsBluetoothLatencyModes(bool *support);

    static status_t getSupportedMixerAttributes(audio_port_handle_t portId,
                                                std::vector<audio_mixer_attributes_t> *mixerAttrs);
    static status_t setPreferredMixerAttributes(const audio_attributes_t *attr,
+12 −0
Original line number Diff line number Diff line
@@ -374,6 +374,10 @@ public:
                                           sp<media::ISoundDose>* soundDose) = 0;

    virtual status_t invalidateTracks(const std::vector<audio_port_handle_t>& portIds) = 0;

    virtual status_t setBluetoothLatencyModesEnabled(bool enabled) = 0;

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

/**
@@ -479,6 +483,8 @@ 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 setBluetoothLatencyModesEnabled(bool enabled) override;
    status_t supportsBluetoothLatencyModes(bool* support) override;
    status_t getSoundDoseInterface(const sp<media::ISoundDoseCallback>& callback,
                                   sp<media::ISoundDose>* soundDose) override;
    status_t invalidateTracks(const std::vector<audio_port_handle_t>& portIds) override;
@@ -572,6 +578,10 @@ 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_LATENCY_MODES_ENABLED =
                    media::BnAudioFlingerService::TRANSACTION_setBluetoothLatencyModesEnabled,
            SUPPORTS_BLUETOOTH_LATENCY_MODES =
                    media::BnAudioFlingerService::TRANSACTION_supportsBluetoothLatencyModes,
            GET_SOUND_DOSE_INTERFACE = media::BnAudioFlingerService::TRANSACTION_getSoundDoseInterface,
            INVALIDATE_TRACKS = media::BnAudioFlingerService::TRANSACTION_invalidateTracks,
        };
@@ -697,6 +707,8 @@ public:
    Status setRequestedLatencyMode(int output, media::LatencyMode mode) override;
    Status getSupportedLatencyModes(int output,
            std::vector<media::LatencyMode>* _aidl_return) override;
    Status setBluetoothLatencyModesEnabled(bool enabled) override;
    Status supportsBluetoothLatencyModes(bool* support) override;
    Status getSoundDoseInterface(const sp<media::ISoundDoseCallback>& callback,
                                 sp<media::ISoundDose>* _aidl_return) override;
    Status invalidateTracks(const std::vector<int32_t>& portIds) override;
Loading