Loading media/libaudiofoundation/AudioProfile.cpp +27 −0 Original line number Diff line number Diff line Loading @@ -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 media/libaudiofoundation/include/media/AudioContainers.h +9 −0 Original line number Diff line number Diff line Loading @@ -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) { Loading media/libaudiofoundation/include/media/AudioProfile.h +2 −0 Original line number Diff line number Diff line Loading @@ -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 services/audiopolicy/AudioPolicyInterface.h +2 −2 Original line number Diff line number Diff line Loading @@ -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, Loading services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h +11 −0 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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) Loading @@ -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 Loading
media/libaudiofoundation/AudioProfile.cpp +27 −0 Original line number Diff line number Diff line Loading @@ -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
media/libaudiofoundation/include/media/AudioContainers.h +9 −0 Original line number Diff line number Diff line Loading @@ -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) { Loading
media/libaudiofoundation/include/media/AudioProfile.h +2 −0 Original line number Diff line number Diff line Loading @@ -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
services/audiopolicy/AudioPolicyInterface.h +2 −2 Original line number Diff line number Diff line Loading @@ -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, Loading
services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h +11 −0 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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) Loading @@ -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