Loading services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h +0 −5 Original line number Original line Diff line number Diff line Loading @@ -498,11 +498,6 @@ public: */ */ bool isA2dpOffloadedOnPrimary() const; bool isA2dpOffloadedOnPrimary() const; /** * returns true if A2DP is supported (either via hardware offload or software encoding) */ bool isA2dpSupported() const; sp<SwAudioOutputDescriptor> getOutputFromId(audio_port_handle_t id) const; sp<SwAudioOutputDescriptor> getOutputFromId(audio_port_handle_t id) const; sp<SwAudioOutputDescriptor> getPrimaryOutput() const; sp<SwAudioOutputDescriptor> getPrimaryOutput() const; Loading services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp +0 −5 Original line number Original line Diff line number Diff line Loading @@ -764,11 +764,6 @@ bool SwAudioOutputCollection::isA2dpOffloadedOnPrimary() const return false; return false; } } bool SwAudioOutputCollection::isA2dpSupported() const { return (isA2dpOffloadedOnPrimary() || (getA2dpOutput() != 0)); } sp<SwAudioOutputDescriptor> SwAudioOutputCollection::getPrimaryOutput() const sp<SwAudioOutputDescriptor> SwAudioOutputCollection::getPrimaryOutput() const { { for (size_t i = 0; i < size(); i++) { for (size_t i = 0; i < size(); i++) { Loading services/audiopolicy/engine/common/src/LastRemovableMediaDevices.cpp +5 −0 Original line number Original line Diff line number Diff line Loading @@ -69,6 +69,11 @@ device_out_group_t LastRemovableMediaDevices::getDeviceOutGroup(audio_devices_t case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP: case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP: case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES: case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES: case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER: case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER: // TODO (b/122931261): remove when preferred device for strategy media will be used instead of // AUDIO_POLICY_FORCE_NO_BT_A2DP. case AUDIO_DEVICE_OUT_HEARING_AID: case AUDIO_DEVICE_OUT_BLE_HEADSET: case AUDIO_DEVICE_OUT_BLE_SPEAKER: return GROUP_BT_A2DP; return GROUP_BT_A2DP; default: default: return GROUP_NONE; return GROUP_NONE; Loading services/audiopolicy/enginedefault/src/Engine.cpp +29 −19 Original line number Original line Diff line number Diff line Loading @@ -241,10 +241,15 @@ DeviceVector Engine::getDevicesForStrategyInt(legacy_strategy strategy, default: // FORCE_NONE default: // FORCE_NONE devices = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_HEARING_AID); devices = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_HEARING_AID); if (!devices.isEmpty()) break; if (!devices.isEmpty()) break; // TODO (b/161358428): remove when preferred device // for strategy phone will be used instead of AUDIO_POLICY_FORCE_FOR_COMMUNICATION devices = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_BLE_HEADSET); if (!devices.isEmpty()) break; // when not in a phone call, phone strategy should route STREAM_VOICE_CALL to A2DP // when not in a phone call, phone strategy should route STREAM_VOICE_CALL to A2DP if (!isInCall() && if (!isInCall() && (getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) != AUDIO_POLICY_FORCE_NO_BT_A2DP) && (getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) != AUDIO_POLICY_FORCE_NO_BT_A2DP)) { outputs.isA2dpSupported()) { devices = availableOutputDevices.getFirstDevicesFromTypes({ devices = availableOutputDevices.getFirstDevicesFromTypes({ AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES}); AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES}); Loading @@ -267,13 +272,17 @@ DeviceVector Engine::getDevicesForStrategyInt(legacy_strategy strategy, case AUDIO_POLICY_FORCE_SPEAKER: case AUDIO_POLICY_FORCE_SPEAKER: // when not in a phone call, phone strategy should route STREAM_VOICE_CALL to // when not in a phone call, phone strategy should route STREAM_VOICE_CALL to // A2DP speaker when forcing to speaker output // A2DP speaker when forcing to speaker output if (!isInCall() && if (!isInCall()) { (getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) != AUDIO_POLICY_FORCE_NO_BT_A2DP) && devices = availableOutputDevices.getDevicesFromType( outputs.isA2dpSupported()) { AUDIO_DEVICE_OUT_BLE_SPEAKER); if (!devices.isEmpty()) break; if ((getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) != AUDIO_POLICY_FORCE_NO_BT_A2DP)) { devices = availableOutputDevices.getDevicesFromType( devices = availableOutputDevices.getDevicesFromType( AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER); AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER); if (!devices.isEmpty()) break; if (!devices.isEmpty()) break; } } } if (!isInCall()) { if (!isInCall()) { devices = availableOutputDevices.getFirstDevicesFromTypes({ devices = availableOutputDevices.getFirstDevicesFromTypes({ AUDIO_DEVICE_OUT_USB_ACCESSORY, AUDIO_DEVICE_OUT_USB_DEVICE, AUDIO_DEVICE_OUT_USB_ACCESSORY, AUDIO_DEVICE_OUT_USB_DEVICE, Loading Loading @@ -386,18 +395,13 @@ DeviceVector Engine::getDevicesForStrategyInt(legacy_strategy strategy, STRATEGY_PHONE, availableOutputDevices, availableInputDevices, outputs); STRATEGY_PHONE, availableOutputDevices, availableInputDevices, outputs); break; break; } } // FIXME: Find a better solution to prevent routing to BT hearing aid(b/122931261). if ((devices2.isEmpty()) && (getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) != AUDIO_POLICY_FORCE_NO_BT_A2DP)) { devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_HEARING_AID); } if ((devices2.isEmpty()) && if ((devices2.isEmpty()) && (getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) == AUDIO_POLICY_FORCE_SPEAKER)) { (getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) == AUDIO_POLICY_FORCE_SPEAKER)) { devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_SPEAKER); devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_SPEAKER); } } if (devices2.isEmpty() && (getLastRemovableMediaDevices().size() > 0)) { if (devices2.isEmpty() && (getLastRemovableMediaDevices().size() > 0)) { if ((getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) != AUDIO_POLICY_FORCE_NO_BT_A2DP) && if ((getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) != AUDIO_POLICY_FORCE_NO_BT_A2DP)) { outputs.isA2dpSupported()) { // Get the last connected device of wired and bluetooth a2dp // Get the last connected device of wired and bluetooth a2dp devices2 = availableOutputDevices.getFirstDevicesFromTypes( devices2 = availableOutputDevices.getFirstDevicesFromTypes( getLastRemovableMediaDevices()); getLastRemovableMediaDevices()); Loading Loading @@ -514,8 +518,9 @@ sp<DeviceDescriptor> Engine::getDeviceForInputSource(audio_source_t inputSource) if (device != nullptr) break; if (device != nullptr) break; } } device = availableDevices.getFirstExistingDevice({ device = availableDevices.getFirstExistingDevice({ AUDIO_DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_IN_USB_HEADSET, AUDIO_DEVICE_IN_BLE_HEADSET, AUDIO_DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_IN_BUILTIN_MIC}); AUDIO_DEVICE_IN_USB_HEADSET, AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_IN_BUILTIN_MIC}); break; break; case AUDIO_SOURCE_VOICE_COMMUNICATION: case AUDIO_SOURCE_VOICE_COMMUNICATION: Loading @@ -539,9 +544,13 @@ sp<DeviceDescriptor> Engine::getDeviceForInputSource(audio_source_t inputSource) FALLTHROUGH_INTENDED; FALLTHROUGH_INTENDED; default: // FORCE_NONE default: // FORCE_NONE // TODO (b/161358428): remove AUDIO_DEVICE_IN_BLE_HEADSET from the list // when preferred device for strategy phone will be used instead of // AUDIO_POLICY_FORCE_FOR_COMMUNICATION. device = availableDevices.getFirstExistingDevice({ device = availableDevices.getFirstExistingDevice({ AUDIO_DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_IN_USB_HEADSET, AUDIO_DEVICE_IN_BLE_HEADSET, AUDIO_DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_IN_BUILTIN_MIC}); AUDIO_DEVICE_IN_USB_HEADSET, AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_IN_BUILTIN_MIC}); break; break; case AUDIO_POLICY_FORCE_SPEAKER: case AUDIO_POLICY_FORCE_SPEAKER: Loading @@ -566,8 +575,9 @@ sp<DeviceDescriptor> Engine::getDeviceForInputSource(audio_source_t inputSource) if (device != nullptr) break; if (device != nullptr) break; } } device = availableDevices.getFirstExistingDevice({ device = availableDevices.getFirstExistingDevice({ AUDIO_DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_IN_USB_HEADSET, AUDIO_DEVICE_IN_BLE_HEADSET, AUDIO_DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_IN_BUILTIN_MIC}); AUDIO_DEVICE_IN_USB_HEADSET, AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_IN_BUILTIN_MIC}); break; break; case AUDIO_SOURCE_CAMCORDER: case AUDIO_SOURCE_CAMCORDER: // For a device without built-in mic, adding usb device // For a device without built-in mic, adding usb device Loading Loading
services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h +0 −5 Original line number Original line Diff line number Diff line Loading @@ -498,11 +498,6 @@ public: */ */ bool isA2dpOffloadedOnPrimary() const; bool isA2dpOffloadedOnPrimary() const; /** * returns true if A2DP is supported (either via hardware offload or software encoding) */ bool isA2dpSupported() const; sp<SwAudioOutputDescriptor> getOutputFromId(audio_port_handle_t id) const; sp<SwAudioOutputDescriptor> getOutputFromId(audio_port_handle_t id) const; sp<SwAudioOutputDescriptor> getPrimaryOutput() const; sp<SwAudioOutputDescriptor> getPrimaryOutput() const; Loading
services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp +0 −5 Original line number Original line Diff line number Diff line Loading @@ -764,11 +764,6 @@ bool SwAudioOutputCollection::isA2dpOffloadedOnPrimary() const return false; return false; } } bool SwAudioOutputCollection::isA2dpSupported() const { return (isA2dpOffloadedOnPrimary() || (getA2dpOutput() != 0)); } sp<SwAudioOutputDescriptor> SwAudioOutputCollection::getPrimaryOutput() const sp<SwAudioOutputDescriptor> SwAudioOutputCollection::getPrimaryOutput() const { { for (size_t i = 0; i < size(); i++) { for (size_t i = 0; i < size(); i++) { Loading
services/audiopolicy/engine/common/src/LastRemovableMediaDevices.cpp +5 −0 Original line number Original line Diff line number Diff line Loading @@ -69,6 +69,11 @@ device_out_group_t LastRemovableMediaDevices::getDeviceOutGroup(audio_devices_t case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP: case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP: case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES: case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES: case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER: case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER: // TODO (b/122931261): remove when preferred device for strategy media will be used instead of // AUDIO_POLICY_FORCE_NO_BT_A2DP. case AUDIO_DEVICE_OUT_HEARING_AID: case AUDIO_DEVICE_OUT_BLE_HEADSET: case AUDIO_DEVICE_OUT_BLE_SPEAKER: return GROUP_BT_A2DP; return GROUP_BT_A2DP; default: default: return GROUP_NONE; return GROUP_NONE; Loading
services/audiopolicy/enginedefault/src/Engine.cpp +29 −19 Original line number Original line Diff line number Diff line Loading @@ -241,10 +241,15 @@ DeviceVector Engine::getDevicesForStrategyInt(legacy_strategy strategy, default: // FORCE_NONE default: // FORCE_NONE devices = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_HEARING_AID); devices = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_HEARING_AID); if (!devices.isEmpty()) break; if (!devices.isEmpty()) break; // TODO (b/161358428): remove when preferred device // for strategy phone will be used instead of AUDIO_POLICY_FORCE_FOR_COMMUNICATION devices = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_BLE_HEADSET); if (!devices.isEmpty()) break; // when not in a phone call, phone strategy should route STREAM_VOICE_CALL to A2DP // when not in a phone call, phone strategy should route STREAM_VOICE_CALL to A2DP if (!isInCall() && if (!isInCall() && (getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) != AUDIO_POLICY_FORCE_NO_BT_A2DP) && (getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) != AUDIO_POLICY_FORCE_NO_BT_A2DP)) { outputs.isA2dpSupported()) { devices = availableOutputDevices.getFirstDevicesFromTypes({ devices = availableOutputDevices.getFirstDevicesFromTypes({ AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES}); AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES}); Loading @@ -267,13 +272,17 @@ DeviceVector Engine::getDevicesForStrategyInt(legacy_strategy strategy, case AUDIO_POLICY_FORCE_SPEAKER: case AUDIO_POLICY_FORCE_SPEAKER: // when not in a phone call, phone strategy should route STREAM_VOICE_CALL to // when not in a phone call, phone strategy should route STREAM_VOICE_CALL to // A2DP speaker when forcing to speaker output // A2DP speaker when forcing to speaker output if (!isInCall() && if (!isInCall()) { (getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) != AUDIO_POLICY_FORCE_NO_BT_A2DP) && devices = availableOutputDevices.getDevicesFromType( outputs.isA2dpSupported()) { AUDIO_DEVICE_OUT_BLE_SPEAKER); if (!devices.isEmpty()) break; if ((getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) != AUDIO_POLICY_FORCE_NO_BT_A2DP)) { devices = availableOutputDevices.getDevicesFromType( devices = availableOutputDevices.getDevicesFromType( AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER); AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER); if (!devices.isEmpty()) break; if (!devices.isEmpty()) break; } } } if (!isInCall()) { if (!isInCall()) { devices = availableOutputDevices.getFirstDevicesFromTypes({ devices = availableOutputDevices.getFirstDevicesFromTypes({ AUDIO_DEVICE_OUT_USB_ACCESSORY, AUDIO_DEVICE_OUT_USB_DEVICE, AUDIO_DEVICE_OUT_USB_ACCESSORY, AUDIO_DEVICE_OUT_USB_DEVICE, Loading Loading @@ -386,18 +395,13 @@ DeviceVector Engine::getDevicesForStrategyInt(legacy_strategy strategy, STRATEGY_PHONE, availableOutputDevices, availableInputDevices, outputs); STRATEGY_PHONE, availableOutputDevices, availableInputDevices, outputs); break; break; } } // FIXME: Find a better solution to prevent routing to BT hearing aid(b/122931261). if ((devices2.isEmpty()) && (getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) != AUDIO_POLICY_FORCE_NO_BT_A2DP)) { devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_HEARING_AID); } if ((devices2.isEmpty()) && if ((devices2.isEmpty()) && (getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) == AUDIO_POLICY_FORCE_SPEAKER)) { (getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) == AUDIO_POLICY_FORCE_SPEAKER)) { devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_SPEAKER); devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_SPEAKER); } } if (devices2.isEmpty() && (getLastRemovableMediaDevices().size() > 0)) { if (devices2.isEmpty() && (getLastRemovableMediaDevices().size() > 0)) { if ((getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) != AUDIO_POLICY_FORCE_NO_BT_A2DP) && if ((getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) != AUDIO_POLICY_FORCE_NO_BT_A2DP)) { outputs.isA2dpSupported()) { // Get the last connected device of wired and bluetooth a2dp // Get the last connected device of wired and bluetooth a2dp devices2 = availableOutputDevices.getFirstDevicesFromTypes( devices2 = availableOutputDevices.getFirstDevicesFromTypes( getLastRemovableMediaDevices()); getLastRemovableMediaDevices()); Loading Loading @@ -514,8 +518,9 @@ sp<DeviceDescriptor> Engine::getDeviceForInputSource(audio_source_t inputSource) if (device != nullptr) break; if (device != nullptr) break; } } device = availableDevices.getFirstExistingDevice({ device = availableDevices.getFirstExistingDevice({ AUDIO_DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_IN_USB_HEADSET, AUDIO_DEVICE_IN_BLE_HEADSET, AUDIO_DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_IN_BUILTIN_MIC}); AUDIO_DEVICE_IN_USB_HEADSET, AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_IN_BUILTIN_MIC}); break; break; case AUDIO_SOURCE_VOICE_COMMUNICATION: case AUDIO_SOURCE_VOICE_COMMUNICATION: Loading @@ -539,9 +544,13 @@ sp<DeviceDescriptor> Engine::getDeviceForInputSource(audio_source_t inputSource) FALLTHROUGH_INTENDED; FALLTHROUGH_INTENDED; default: // FORCE_NONE default: // FORCE_NONE // TODO (b/161358428): remove AUDIO_DEVICE_IN_BLE_HEADSET from the list // when preferred device for strategy phone will be used instead of // AUDIO_POLICY_FORCE_FOR_COMMUNICATION. device = availableDevices.getFirstExistingDevice({ device = availableDevices.getFirstExistingDevice({ AUDIO_DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_IN_USB_HEADSET, AUDIO_DEVICE_IN_BLE_HEADSET, AUDIO_DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_IN_BUILTIN_MIC}); AUDIO_DEVICE_IN_USB_HEADSET, AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_IN_BUILTIN_MIC}); break; break; case AUDIO_POLICY_FORCE_SPEAKER: case AUDIO_POLICY_FORCE_SPEAKER: Loading @@ -566,8 +575,9 @@ sp<DeviceDescriptor> Engine::getDeviceForInputSource(audio_source_t inputSource) if (device != nullptr) break; if (device != nullptr) break; } } device = availableDevices.getFirstExistingDevice({ device = availableDevices.getFirstExistingDevice({ AUDIO_DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_IN_USB_HEADSET, AUDIO_DEVICE_IN_BLE_HEADSET, AUDIO_DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_IN_BUILTIN_MIC}); AUDIO_DEVICE_IN_USB_HEADSET, AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_IN_BUILTIN_MIC}); break; break; case AUDIO_SOURCE_CAMCORDER: case AUDIO_SOURCE_CAMCORDER: // For a device without built-in mic, adding usb device // For a device without built-in mic, adding usb device Loading