Loading services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h +7 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,13 @@ public: DeviceVector getDevicesFromHwModule(audio_module_handle_t moduleHandle) const; audio_devices_t getDeviceTypesFromHwModule(audio_module_handle_t moduleHandle) const; DeviceVector getFirstDevicesFromTypes(std::vector<audio_devices_t> orderedTypes) const; sp<DeviceDescriptor> getFirstExistingDevice(std::vector<audio_devices_t> orderedTypes) const; // If there are devices with the given type and the devices to add is not empty, // remove all the devices with the given type and add all the devices to add. void replaceDevicesByType(audio_devices_t typeToRemove, const DeviceVector &devicesToAdd); bool contains(const sp<DeviceDescriptor>& item) const { return indexOf(item) >= 0; } /** Loading services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp +32 −1 Original line number Diff line number Diff line Loading @@ -255,7 +255,6 @@ DeviceVector DeviceVector::getDevicesFromTypeMask(audio_devices_t type) const audio_devices_t curType = itemAt(i)->type() & ~AUDIO_DEVICE_BIT_IN; if ((isOutput == curIsOutput) && ((type & curType) != 0)) { devices.add(itemAt(i)); type &= ~curType; ALOGV("DeviceVector::%s() for type %08x found %p", __func__, itemAt(i)->type(), itemAt(i).get()); } Loading @@ -273,6 +272,38 @@ sp<DeviceDescriptor> DeviceVector::getDeviceFromTagName(const String8 &tagName) return nullptr; } DeviceVector DeviceVector::getFirstDevicesFromTypes( std::vector<audio_devices_t> orderedTypes) const { DeviceVector devices; for (auto deviceType : orderedTypes) { if (!(devices = getDevicesFromTypeMask(deviceType)).isEmpty()) { break; } } return devices; } sp<DeviceDescriptor> DeviceVector::getFirstExistingDevice( std::vector<audio_devices_t> orderedTypes) const { sp<DeviceDescriptor> device; for (auto deviceType : orderedTypes) { if ((device = getDevice(deviceType, String8(""), AUDIO_FORMAT_DEFAULT)) != nullptr) { break; } } return device; } void DeviceVector::replaceDevicesByType( audio_devices_t typeToRemove, const DeviceVector &devicesToAdd) { DeviceVector devicesToRemove = getDevicesFromTypeMask(typeToRemove); if (!devicesToRemove.isEmpty() && !devicesToAdd.isEmpty()) { remove(devicesToRemove); add(devicesToAdd); } } void DeviceVector::dump(String8 *dst, const String8 &tag, int spaces, bool verbose) const { if (isEmpty()) { Loading services/audiopolicy/enginedefault/src/Engine.cpp +217 −279 File changed.Preview size limit exceeded, changes collapsed. Show changes services/audiopolicy/enginedefault/src/Engine.h +5 −6 Original line number Diff line number Diff line Loading @@ -73,15 +73,14 @@ private: status_t setDefaultDevice(audio_devices_t device); audio_devices_t getDeviceForStrategyInt(legacy_strategy strategy, DeviceVector getDevicesForStrategyInt(legacy_strategy strategy, DeviceVector availableOutputDevices, DeviceVector availableInputDevices, const SwAudioOutputCollection &outputs, uint32_t outputDeviceTypesToIgnore) const; const SwAudioOutputCollection &outputs) const; DeviceVector getDevicesForProductStrategy(product_strategy_t strategy) const; audio_devices_t getDeviceForInputSource(audio_source_t inputSource) const; sp<DeviceDescriptor> getDeviceForInputSource(audio_source_t inputSource) const; DeviceStrategyMap mDevicesForStrategies; Loading Loading
services/audiopolicy/common/managerdefinitions/include/DeviceDescriptor.h +7 −0 Original line number Diff line number Diff line Loading @@ -116,6 +116,13 @@ public: DeviceVector getDevicesFromHwModule(audio_module_handle_t moduleHandle) const; audio_devices_t getDeviceTypesFromHwModule(audio_module_handle_t moduleHandle) const; DeviceVector getFirstDevicesFromTypes(std::vector<audio_devices_t> orderedTypes) const; sp<DeviceDescriptor> getFirstExistingDevice(std::vector<audio_devices_t> orderedTypes) const; // If there are devices with the given type and the devices to add is not empty, // remove all the devices with the given type and add all the devices to add. void replaceDevicesByType(audio_devices_t typeToRemove, const DeviceVector &devicesToAdd); bool contains(const sp<DeviceDescriptor>& item) const { return indexOf(item) >= 0; } /** Loading
services/audiopolicy/common/managerdefinitions/src/DeviceDescriptor.cpp +32 −1 Original line number Diff line number Diff line Loading @@ -255,7 +255,6 @@ DeviceVector DeviceVector::getDevicesFromTypeMask(audio_devices_t type) const audio_devices_t curType = itemAt(i)->type() & ~AUDIO_DEVICE_BIT_IN; if ((isOutput == curIsOutput) && ((type & curType) != 0)) { devices.add(itemAt(i)); type &= ~curType; ALOGV("DeviceVector::%s() for type %08x found %p", __func__, itemAt(i)->type(), itemAt(i).get()); } Loading @@ -273,6 +272,38 @@ sp<DeviceDescriptor> DeviceVector::getDeviceFromTagName(const String8 &tagName) return nullptr; } DeviceVector DeviceVector::getFirstDevicesFromTypes( std::vector<audio_devices_t> orderedTypes) const { DeviceVector devices; for (auto deviceType : orderedTypes) { if (!(devices = getDevicesFromTypeMask(deviceType)).isEmpty()) { break; } } return devices; } sp<DeviceDescriptor> DeviceVector::getFirstExistingDevice( std::vector<audio_devices_t> orderedTypes) const { sp<DeviceDescriptor> device; for (auto deviceType : orderedTypes) { if ((device = getDevice(deviceType, String8(""), AUDIO_FORMAT_DEFAULT)) != nullptr) { break; } } return device; } void DeviceVector::replaceDevicesByType( audio_devices_t typeToRemove, const DeviceVector &devicesToAdd) { DeviceVector devicesToRemove = getDevicesFromTypeMask(typeToRemove); if (!devicesToRemove.isEmpty() && !devicesToAdd.isEmpty()) { remove(devicesToRemove); add(devicesToAdd); } } void DeviceVector::dump(String8 *dst, const String8 &tag, int spaces, bool verbose) const { if (isEmpty()) { Loading
services/audiopolicy/enginedefault/src/Engine.cpp +217 −279 File changed.Preview size limit exceeded, changes collapsed. Show changes
services/audiopolicy/enginedefault/src/Engine.h +5 −6 Original line number Diff line number Diff line Loading @@ -73,15 +73,14 @@ private: status_t setDefaultDevice(audio_devices_t device); audio_devices_t getDeviceForStrategyInt(legacy_strategy strategy, DeviceVector getDevicesForStrategyInt(legacy_strategy strategy, DeviceVector availableOutputDevices, DeviceVector availableInputDevices, const SwAudioOutputCollection &outputs, uint32_t outputDeviceTypesToIgnore) const; const SwAudioOutputCollection &outputs) const; DeviceVector getDevicesForProductStrategy(product_strategy_t strategy) const; audio_devices_t getDeviceForInputSource(audio_source_t inputSource) const; sp<DeviceDescriptor> getDeviceForInputSource(audio_source_t inputSource) const; DeviceStrategyMap mDevicesForStrategies; Loading