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

Commit 72214517 authored by Eric Laurent's avatar Eric Laurent Committed by android-build-merger
Browse files

Merge "audiopolicy: Optimize A2DP codec config change" into pi-dev

am: 0ba1ae39

Change-Id: I8a8da84dafe1f941b7fb0240ac353c35ea06ace3
parents 52f0c239 0ba1ae39
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -81,6 +81,11 @@ public:

    static const char * const valueListSeparator;

    // keyReconfigA2dp: Ask HwModule to reconfigure A2DP offloaded codec
    // keyReconfigA2dpSupported: Query if HwModule supports A2DP offload codec config
    static const char * const keyReconfigA2dp;
    static const char * const keyReconfigA2dpSupported;

    String8 toString() const { return toStringImpl(true); }
    String8 keysToString() const { return toStringImpl(false); }

+2 −0
Original line number Diff line number Diff line
@@ -47,6 +47,8 @@ const char * const AudioParameter::keyStreamSupportedSamplingRates =
const char * const AudioParameter::valueOn = AUDIO_PARAMETER_VALUE_ON;
const char * const AudioParameter::valueOff = AUDIO_PARAMETER_VALUE_OFF;
const char * const AudioParameter::valueListSeparator = AUDIO_PARAMETER_VALUE_LIST_SEPARATOR;
const char * const AudioParameter::keyReconfigA2dp = AUDIO_PARAMETER_RECONFIG_A2DP;
const char * const AudioParameter::keyReconfigA2dpSupported = AUDIO_PARAMETER_A2DP_RECONFIG_SUPPORTED;

AudioParameter::AudioParameter(const String8& keyValuePairs)
{
+23 −0
Original line number Diff line number Diff line
@@ -368,6 +368,9 @@ status_t AudioPolicyManager::handleDeviceConfigChange(audio_devices_t device,
                                                      const char *device_name)
{
    status_t status;
    String8 reply;
    AudioParameter param;
    int isReconfigA2dpSupported = 0;

    ALOGV("handleDeviceConfigChange(() device: 0x%X, address %s name %s",
          device, device_address, device_name);
@@ -384,6 +387,26 @@ status_t AudioPolicyManager::handleDeviceConfigChange(audio_devices_t device,
        return NO_ERROR;
    }

    // For offloaded A2DP, Hw modules may have the capability to
    // configure codecs. Check if any of the loaded hw modules
    // supports this.
    // If supported, send a set parameter to configure A2DP codecs
    // and return. No need to toggle device state.
    if (device & AUDIO_DEVICE_OUT_ALL_A2DP) {
        reply = mpClientInterface->getParameters(
                    AUDIO_IO_HANDLE_NONE,
                    String8(AudioParameter::keyReconfigA2dpSupported));
        AudioParameter repliedParameters(reply);
        repliedParameters.getInt(
                String8(AudioParameter::keyReconfigA2dpSupported), isReconfigA2dpSupported);
        if (isReconfigA2dpSupported) {
            const String8 key(AudioParameter::keyReconfigA2dp);
            param.add(key, String8("true"));
            mpClientInterface->setParameters(AUDIO_IO_HANDLE_NONE, param.toString());
            return NO_ERROR;
        }
    }

    // Toggle the device state: UNAVAILABLE -> AVAILABLE
    // This will force reading again the device configuration
    status = setDeviceConnectionState(device,