diff options
author | Mike Lockwood <lockwood@google.com> | 2014-05-21 09:28:05 -0700 |
---|---|---|
committer | Mike Lockwood <lockwood@google.com> | 2014-05-28 12:21:52 -0700 |
commit | 33bf1b0fe363bd4892349d160f54d860567fab12 (patch) | |
tree | ac059d10872e4b4ad0924c30476f47ac50bf9f4a /audio | |
parent | b26e377bb1b2f5466438092cdc85cd0e8dc631ca (diff) | |
download | platform_hardware_libhardware_legacy-33bf1b0fe363bd4892349d160f54d860567fab12.tar.gz platform_hardware_libhardware_legacy-33bf1b0fe363bd4892349d160f54d860567fab12.tar.bz2 platform_hardware_libhardware_legacy-33bf1b0fe363bd4892349d160f54d860567fab12.zip |
AudioPolicyManagerBase: Add support for A2DP sink input
Change-Id: I500d1f2f8f2199c674b289cf671b7f863a7d02ee
Diffstat (limited to 'audio')
-rw-r--r-- | audio/A2dpAudioInterface.cpp | 4 | ||||
-rw-r--r-- | audio/AudioPolicyManagerBase.cpp | 22 |
2 files changed, 19 insertions, 7 deletions
diff --git a/audio/A2dpAudioInterface.cpp b/audio/A2dpAudioInterface.cpp index 9359ec3..4ab52ba 100644 --- a/audio/A2dpAudioInterface.cpp +++ b/audio/A2dpAudioInterface.cpp @@ -63,7 +63,7 @@ status_t A2dpAudioInterface::initCheck() AudioStreamOut* A2dpAudioInterface::openOutputStream( uint32_t devices, int *format, uint32_t *channels, uint32_t *sampleRate, status_t *status) { - if (!audio_is_a2dp_device(devices)) { + if (!audio_is_a2dp_out_device(devices)) { ALOGV("A2dpAudioInterface::openOutputStream() open HW device: %x", devices); return mHardwareInterface->openOutputStream(devices, format, channels, sampleRate, status); } @@ -398,7 +398,7 @@ status_t A2dpAudioInterface::A2dpAudioStreamOut::setParameters(const String8& ke } key = AudioParameter::keyRouting; if (param.getInt(key, device) == NO_ERROR) { - if (audio_is_a2dp_device(device)) { + if (audio_is_a2dp_out_device(device)) { mDevice = device; status = NO_ERROR; } else { diff --git a/audio/AudioPolicyManagerBase.cpp b/audio/AudioPolicyManagerBase.cpp index a12eeff..461c47a 100644 --- a/audio/AudioPolicyManagerBase.cpp +++ b/audio/AudioPolicyManagerBase.cpp @@ -67,7 +67,7 @@ status_t AudioPolicyManagerBase::setDeviceConnectionState(audio_devices_t device if (audio_is_output_device(device)) { SortedVector <audio_io_handle_t> outputs; - if (!mHasA2dp && audio_is_a2dp_device(device)) { + if (!mHasA2dp && audio_is_a2dp_out_device(device)) { ALOGE("setDeviceConnectionState() invalid A2DP device: %x", device); return BAD_VALUE; } @@ -94,7 +94,7 @@ status_t AudioPolicyManagerBase::setDeviceConnectionState(audio_devices_t device } ALOGV("setDeviceConnectionState() connecting device %x", device); - if (mHasA2dp && audio_is_a2dp_device(device)) { + if (mHasA2dp && audio_is_a2dp_out_device(device)) { // handle A2DP device connection AudioParameter param; param.add(String8(AUDIO_PARAMETER_A2DP_SINK_ADDRESS), String8(device_address)); @@ -112,7 +112,7 @@ status_t AudioPolicyManagerBase::setDeviceConnectionState(audio_devices_t device // register new device as available mAvailableOutputDevices = (audio_devices_t)(mAvailableOutputDevices | device); - if (mHasA2dp && audio_is_a2dp_device(device)) { + if (mHasA2dp && audio_is_a2dp_out_device(device)) { // handle A2DP device connection mA2dpDeviceAddress = String8(device_address, MAX_DEVICE_ADDRESS_LEN); mA2dpSuspended = false; @@ -137,7 +137,7 @@ status_t AudioPolicyManagerBase::setDeviceConnectionState(audio_devices_t device mAvailableOutputDevices = (audio_devices_t)(mAvailableOutputDevices & ~device); checkOutputsForDevice(device, state, outputs, paramStr); - if (mHasA2dp && audio_is_a2dp_device(device)) { + if (mHasA2dp && audio_is_a2dp_out_device(device)) { // handle A2DP device disconnection mA2dpDeviceAddress = ""; mA2dpSuspended = false; @@ -212,6 +212,11 @@ status_t AudioPolicyManagerBase::setDeviceConnectionState(audio_devices_t device if (mHasUsb && audio_is_usb_in_device(device)) { // handle USB device connection paramStr = String8(device_address, MAX_DEVICE_ADDRESS_LEN); + } else if (mHasA2dp && audio_is_a2dp_in_device(device)) { + // handle A2DP device connection + AudioParameter param; + param.add(String8(AUDIO_PARAMETER_A2DP_SOURCE_ADDRESS), String8(device_address)); + paramStr = param.toString(); } if (checkInputsForDevice(device, state, inputs, paramStr) != NO_ERROR) { @@ -252,7 +257,7 @@ AudioSystem::device_connection_state AudioPolicyManagerBase::getDeviceConnection String8 address = String8(device_address); if (audio_is_output_device(device)) { if (device & mAvailableOutputDevices) { - if (audio_is_a2dp_device(device) && + if (audio_is_a2dp_out_device(device) && (!mHasA2dp || (address != "" && mA2dpDeviceAddress != address))) { return state; } @@ -2910,6 +2915,12 @@ audio_devices_t AudioPolicyManagerBase::getDeviceForInputSource(int inputSource) case AUDIO_SOURCE_DEFAULT: case AUDIO_SOURCE_MIC: + if (mAvailableInputDevices & AUDIO_DEVICE_IN_BLUETOOTH_A2DP) { + device = AUDIO_DEVICE_IN_BLUETOOTH_A2DP; + break; + } + // FALL THROUGH + case AUDIO_SOURCE_VOICE_RECOGNITION: case AUDIO_SOURCE_HOTWORD: case AUDIO_SOURCE_VOICE_COMMUNICATION: @@ -3911,6 +3922,7 @@ const struct StringToEnum sDeviceNameToEnumTable[] = { STRING_TO_ENUM(AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET), STRING_TO_ENUM(AUDIO_DEVICE_IN_USB_ACCESSORY), STRING_TO_ENUM(AUDIO_DEVICE_IN_USB_DEVICE), + STRING_TO_ENUM(AUDIO_DEVICE_IN_BLUETOOTH_A2DP), }; const struct StringToEnum sFlagNameToEnumTable[] = { |