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

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

Merge "audio policy: fix device address passed when opening HAL streams"

parents 7b9317ae 53b810ea
Loading
Loading
Loading
Loading
+2 −10
Original line number Original line Diff line number Diff line
@@ -206,24 +206,16 @@ status_t AudioInputDescriptor::open(const audio_config_t *config,
        lConfig = *config;
        lConfig = *config;
    }
    }


    String8 lAddress = address;
    if (lAddress == "") {
        const DeviceVector& supportedDevices = mProfile->getSupportedDevices();
        const DeviceVector& devicesForType = supportedDevices.getDevicesFromType(device);
        lAddress = devicesForType.size() > 0 ? devicesForType.itemAt(0)->mAddress
                  : String8("");
    }

    mDevice = device;
    mDevice = device;


    ALOGV("opening input for device %08x address %s profile %p name %s",
    ALOGV("opening input for device %08x address %s profile %p name %s",
          mDevice, lAddress.string(), mProfile.get(), mProfile->getName().string());
          mDevice, address.string(), mProfile.get(), mProfile->getName().string());


    status_t status = mClientInterface->openInput(mProfile->getModuleHandle(),
    status_t status = mClientInterface->openInput(mProfile->getModuleHandle(),
                                                  input,
                                                  input,
                                                  &lConfig,
                                                  &lConfig,
                                                  &mDevice,
                                                  &mDevice,
                                                  lAddress,
                                                  address,
                                                  source,
                                                  source,
                                                  flags);
                                                  flags);
    LOG_ALWAYS_FATAL_IF(mDevice != device,
    LOG_ALWAYS_FATAL_IF(mDevice != device,
+2 −10
Original line number Original line Diff line number Diff line
@@ -398,14 +398,6 @@ status_t SwAudioOutputDescriptor::open(const audio_config_t *config,
        lConfig = *config;
        lConfig = *config;
    }
    }


    String8 lAddress = address;
    if (lAddress == "") {
        const DeviceVector& supportedDevices = mProfile->getSupportedDevices();
        const DeviceVector& devicesForType = supportedDevices.getDevicesFromType(device);
        lAddress = devicesForType.size() > 0 ? devicesForType.itemAt(0)->mAddress
                  : String8("");
    }

    mDevice = device;
    mDevice = device;
    // if the selected profile is offloaded and no offload info was specified,
    // if the selected profile is offloaded and no offload info was specified,
    // create a default one
    // create a default one
@@ -425,13 +417,13 @@ status_t SwAudioOutputDescriptor::open(const audio_config_t *config,
    mFlags = (audio_output_flags_t)(mFlags | flags);
    mFlags = (audio_output_flags_t)(mFlags | flags);


    ALOGV("opening output for device %08x address %s profile %p name %s",
    ALOGV("opening output for device %08x address %s profile %p name %s",
          mDevice, lAddress.string(), mProfile.get(), mProfile->getName().string());
          mDevice, address.string(), mProfile.get(), mProfile->getName().string());


    status_t status = mClientInterface->openOutput(mProfile->getModuleHandle(),
    status_t status = mClientInterface->openOutput(mProfile->getModuleHandle(),
                                                   output,
                                                   output,
                                                   &lConfig,
                                                   &lConfig,
                                                   &mDevice,
                                                   &mDevice,
                                                   lAddress,
                                                   address,
                                                   &mLatency,
                                                   &mLatency,
                                                   mFlags);
                                                   mFlags);
    LOG_ALWAYS_FATAL_IF(mDevice != device,
    LOG_ALWAYS_FATAL_IF(mDevice != device,
+20 −2
Original line number Original line Diff line number Diff line
@@ -918,7 +918,12 @@ audio_io_handle_t AudioPolicyManager::getOutputForDevice(
        }
        }


        outputDesc = new SwAudioOutputDescriptor(profile, mpClientInterface);
        outputDesc = new SwAudioOutputDescriptor(profile, mpClientInterface);
        status = outputDesc->open(config, device, String8(""), stream, flags, &output);

        DeviceVector outputDevices = mAvailableOutputDevices.getDevicesFromType(device);
        String8 address = outputDevices.size() > 0 ? outputDevices.itemAt(0)->mAddress
                : String8("");

        status = outputDesc->open(config, device, address, stream, flags, &output);


        // only accept an output with the requested parameters
        // only accept an output with the requested parameters
        if (status != NO_ERROR ||
        if (status != NO_ERROR ||
@@ -1678,6 +1683,12 @@ audio_io_handle_t AudioPolicyManager::getInputForDevice(audio_devices_t device,
    lConfig.channel_mask = profileChannelMask;
    lConfig.channel_mask = profileChannelMask;
    lConfig.format = profileFormat;
    lConfig.format = profileFormat;


    if (address == "") {
        DeviceVector inputDevices = mAvailableInputDevices.getDevicesFromType(device);
        // the inputs vector must be of size >= 1, but we don't want to crash here
        address = inputDevices.size() > 0 ? inputDevices.itemAt(0)->mAddress : String8("");
    }

    status_t status = inputDesc->open(&lConfig, device, address,
    status_t status = inputDesc->open(&lConfig, device, address,
            halInputSource, profileFlags, &input);
            halInputSource, profileFlags, &input);


@@ -3588,10 +3599,17 @@ AudioPolicyManager::AudioPolicyManager(AudioPolicyClientInterface *clientInterfa
            sp<AudioInputDescriptor> inputDesc =
            sp<AudioInputDescriptor> inputDesc =
                    new AudioInputDescriptor(inProfile, mpClientInterface);
                    new AudioInputDescriptor(inProfile, mpClientInterface);


            DeviceVector inputDevices = mAvailableInputDevices.getDevicesFromType(profileType);
            //   the inputs vector must be of size >= 1, but we don't want to crash here
            String8 address = inputDevices.size() > 0 ? inputDevices.itemAt(0)->mAddress
                    : String8("");
            ALOGV("  for input device 0x%x using address %s", profileType, address.string());
            ALOGE_IF(inputDevices.size() == 0, "Input device list is empty!");

            audio_io_handle_t input = AUDIO_IO_HANDLE_NONE;
            audio_io_handle_t input = AUDIO_IO_HANDLE_NONE;
            status_t status = inputDesc->open(nullptr,
            status_t status = inputDesc->open(nullptr,
                                              profileType,
                                              profileType,
                                              String8(""),
                                              address,
                                              AUDIO_SOURCE_MIC,
                                              AUDIO_SOURCE_MIC,
                                              AUDIO_INPUT_FLAG_NONE,
                                              AUDIO_INPUT_FLAG_NONE,
                                              &input);
                                              &input);