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

Commit 3c5f8aaa authored by Andy Hung's avatar Andy Hung Committed by Android (Google) Code Review
Browse files

Merge "Remove getDevicesForStream" into tm-dev

parents f68caf6e 744efbea
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -1253,22 +1253,6 @@ product_strategy_t AudioSystem::getStrategyForStream(audio_stream_type_t stream)
    return result.value_or(PRODUCT_STRATEGY_NONE);
}

DeviceTypeSet AudioSystem::getDevicesForStream(audio_stream_type_t stream) {
    const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
    if (aps == 0) return DeviceTypeSet{};

    auto result = [&]() -> ConversionResult<DeviceTypeSet> {
        AudioStreamType streamAidl = VALUE_OR_RETURN(
                legacy2aidl_audio_stream_type_t_AudioStreamType(stream));
        std::vector<AudioDeviceDescription> resultAidl;
        RETURN_IF_ERROR(statusTFromBinderStatus(
                aps->getDevicesForStream(streamAidl, &resultAidl)));
        return convertContainer<DeviceTypeSet>(resultAidl,
                aidl2legacy_AudioDeviceDescription_audio_devices_t);
    }();
    return result.value_or(DeviceTypeSet{});
}

status_t AudioSystem::getDevicesForAttributes(const AudioAttributes& aa,
                                              AudioDeviceTypeAddrVector* devices,
                                              bool forVolume) {
+0 −2
Original line number Diff line number Diff line
@@ -137,8 +137,6 @@ interface IAudioPolicyService {

    int /* product_strategy_t */ getStrategyForStream(AudioStreamType stream);

    AudioDeviceDescription[] getDevicesForStream(AudioStreamType stream);

    AudioDevice[] getDevicesForAttributes(in AudioAttributesEx attr, boolean forVolume);

    int /* audio_io_handle_t */ getOutputForEffect(in EffectDescriptor desc);
+0 −1
Original line number Diff line number Diff line
@@ -328,7 +328,6 @@ public:
    static status_t getMinVolumeIndexForAttributes(const audio_attributes_t &attr, int &index);

    static product_strategy_t getStrategyForStream(audio_stream_type_t stream);
    static DeviceTypeSet getDevicesForStream(audio_stream_type_t stream);
    static status_t getDevicesForAttributes(const AudioAttributes &aa,
                                            AudioDeviceTypeAddrVector *devices,
                                            bool forVolume);
+0 −3
Original line number Diff line number Diff line
@@ -210,9 +210,6 @@ public:
    // return the strategy corresponding to a given stream type
    virtual product_strategy_t getStrategyForStream(audio_stream_type_t stream) = 0;

    // return the enabled output devices for the given stream type
    virtual DeviceTypeSet getDevicesForStream(audio_stream_type_t stream) = 0;

    // retrieves the list of enabled output devices for the given audio attributes
    virtual status_t getDevicesForAttributes(const audio_attributes_t &attr,
                                             AudioDeviceTypeAddrVector *devices,
+0 −40
Original line number Diff line number Diff line
@@ -6430,46 +6430,6 @@ bool AudioPolicyManager::streamsMatchForvolume(audio_stream_type_t stream1,
    return (stream1 == stream2);
}

DeviceTypeSet AudioPolicyManager::getDevicesForStream(audio_stream_type_t stream) {
    // By checking the range of stream before calling getStrategy, we avoid
    // getOutputDevicesForStream's behavior for invalid streams.
    // engine's getOutputDevicesForStream would fallback on its default behavior (most probably
    // device for music stream), but we want to return the empty set.
    if (stream < AUDIO_STREAM_MIN || stream >= AUDIO_STREAM_PUBLIC_CNT) {
        return DeviceTypeSet{};
    }
    DeviceVector activeDevices;
    DeviceVector devices;
    for (int i = AUDIO_STREAM_MIN; i < AUDIO_STREAM_PUBLIC_CNT; ++i) {
        const audio_stream_type_t curStream{static_cast<audio_stream_type_t>(i)};
        if (!streamsMatchForvolume(stream, curStream)) {
            continue;
        }
        DeviceVector curDevices = mEngine->getOutputDevicesForStream(curStream, false/*fromCache*/);
        devices.merge(curDevices);
        for (audio_io_handle_t output : getOutputsForDevices(curDevices, mOutputs)) {
            sp<AudioOutputDescriptor> outputDesc = mOutputs.valueFor(output);
            if (outputDesc->isActive(toVolumeSource(curStream, false))) {
                activeDevices.merge(outputDesc->devices());
            }
        }
    }

    // Favor devices selected on active streams if any to report correct device in case of
    // explicit device selection
    if (!activeDevices.isEmpty()) {
        devices = activeDevices;
    }
    /*Filter SPEAKER_SAFE out of results, as AudioService doesn't know about it
      and doesn't really need to.*/
    DeviceVector speakerSafeDevices = devices.getDevicesFromType(AUDIO_DEVICE_OUT_SPEAKER_SAFE);
    if (!speakerSafeDevices.isEmpty()) {
        devices.merge(mAvailableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_SPEAKER));
        devices.remove(speakerSafeDevices);
    }
    return devices.types();
}

// TODO - consider MSD routes b/214971780
status_t AudioPolicyManager::getDevicesForAttributes(
        const audio_attributes_t &attr, AudioDeviceTypeAddrVector *devices, bool forVolume) {
Loading