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

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

Merge "Support connecting multiple devices to APM."

parents 95f8fd2c bce0c1de
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -355,4 +355,31 @@ legacy2aidl_AudioProfileVector(const AudioProfileVector& legacy) {
    return convertContainer<std::vector<media::AudioProfile>>(legacy, legacy2aidl_AudioProfile);
}

AudioProfileVector intersectAudioProfiles(const AudioProfileVector& profiles1,
                                          const AudioProfileVector& profiles2)
{
    std::map<audio_format_t, std::pair<ChannelMaskSet, SampleRateSet>> infos2;
    for (const auto& profile : profiles2) {
        infos2.emplace(profile->getFormat(),
                std::make_pair(profile->getChannels(), profile->getSampleRates()));
    }
    AudioProfileVector profiles;
    for (const auto& profile : profiles1) {
        const auto it = infos2.find(profile->getFormat());
        if (it == infos2.end()) {
            continue;
        }
        ChannelMaskSet channelMasks = SetIntersection(profile->getChannels(), it->second.first);
        if (channelMasks.empty()) {
            continue;
        }
        SampleRateSet sampleRates = SetIntersection(profile->getSampleRates(), it->second.second);
        if (sampleRates.empty()) {
            continue;
        }
        profiles.push_back(new AudioProfile(profile->getFormat(), channelMasks, sampleRates));
    }
    return profiles;
}

} // namespace android
+9 −0
Original line number Diff line number Diff line
@@ -50,6 +50,15 @@ static std::vector<T> Intersection(const std::set<T>& a, const std::set<T>& b) {
    return intersection;
}

template<typename T>
static std::set<T> SetIntersection(const std::set<T>& a, const std::set<T> b) {
    std::set<T> intersection;
    std::set_intersection(a.begin(), a.end(),
                          b.begin(), b.end(),
                          std::inserter(intersection, intersection.begin()));
    return intersection;
}

static inline ChannelMaskSet asInMask(const ChannelMaskSet& channelMasks) {
    ChannelMaskSet inMaskSet;
    for (const auto &channel : channelMasks) {
+2 −0
Original line number Diff line number Diff line
@@ -137,5 +137,7 @@ aidl2legacy_AudioProfileVector(const std::vector<media::AudioProfile>& aidl);
ConversionResult<std::vector<media::AudioProfile>>
legacy2aidl_AudioProfileVector(const AudioProfileVector& legacy);

AudioProfileVector intersectAudioProfiles(const AudioProfileVector& profiles1,
                                          const AudioProfileVector& profiles2);

} // namespace android
+2 −2
Original line number Diff line number Diff line
@@ -133,8 +133,8 @@ public:
    virtual status_t startOutput(audio_port_handle_t portId) = 0;
    // indicates to the audio policy manager that the output stops being used by corresponding stream.
    virtual status_t stopOutput(audio_port_handle_t portId) = 0;
    // releases the output.
    virtual void releaseOutput(audio_port_handle_t portId) = 0;
    // releases the output, return true if the output descriptor is reopened.
    virtual bool releaseOutput(audio_port_handle_t portId) = 0;

    // request an input appropriate for record from the supplied device with supplied parameters.
    virtual status_t getInputForAttr(const audio_attributes_t *attr,
+11 −0
Original line number Diff line number Diff line
@@ -338,6 +338,8 @@ public:
    bool sharesHwModuleWith(const sp<SwAudioOutputDescriptor>& outputDesc);
    virtual DeviceVector supportedDevices() const;
    virtual bool devicesSupportEncodedFormats(const DeviceTypeSet& deviceTypes);
    virtual bool containsSingleDeviceSupportingEncodedFormats(
            const sp<DeviceDescriptor>& device) const;
    virtual uint32_t latency();
    virtual bool isDuplicated() const { return (mOutput1 != NULL && mOutput2 != NULL); }
    virtual bool isFixedVolume(const DeviceTypeSet& deviceTypes);
@@ -395,6 +397,14 @@ public:
     */
    bool supportsAllDevices(const DeviceVector &devices) const;

    /**
     * @brief supportsDevicesForPlayback
     * @param devices to be checked against
     * @return true if the devices is a supported combo for playback
     *         false otherwise
     */
    bool supportsDevicesForPlayback(const DeviceVector &devices) const;

    /**
     * @brief filterSupportedDevices takes a vector of devices and filters them according to the
     * device supported by this output (the profile from which this output derives from)
@@ -412,6 +422,7 @@ public:
    sp<SwAudioOutputDescriptor> mOutput2;    // used by duplicated outputs: second output
    uint32_t mDirectOpenCount; // number of clients using this output (direct outputs only)
    audio_session_t mDirectClientSession; // session id of the direct output client
    bool mPendingReopenToQueryProfiles = false;
};

// Audio output driven by an input device directly.
Loading