diff options
-rw-r--r-- | policy_hal/AudioPolicyManager.cpp | 36 | ||||
-rw-r--r-- | policy_hal/AudioPolicyManager.h | 4 |
2 files changed, 20 insertions, 20 deletions
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp index b1cf8fed..28441ea5 100644 --- a/policy_hal/AudioPolicyManager.cpp +++ b/policy_hal/AudioPolicyManager.cpp @@ -164,8 +164,15 @@ status_t AudioPolicyManagerCustom::setDeviceConnectionStateInt(audio_devices_t d return NO_MEMORY; } + // Before checking outputs, broadcast connect event to allow HAL to retrieve dynamic + // parameters on newly connected devices (instead of opening the outputs...) + broadcastDeviceConnectionState(device, state, devDesc->mAddress); + if (checkOutputsForDevice(devDesc, state, outputs, devDesc->mAddress) != NO_ERROR) { mAvailableOutputDevices.remove(devDesc); + + broadcastDeviceConnectionState(device, AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, + devDesc->mAddress); return INVALID_OPERATION; } // Propagate device availability to Engine @@ -177,11 +184,6 @@ status_t AudioPolicyManagerCustom::setDeviceConnectionStateInt(audio_devices_t d ALOGV("setDeviceConnectionState() checkOutputsForDevice() returned %zu outputs", outputs.size()); - // Send connect to HALs - AudioParameter param = AudioParameter(devDesc->mAddress); - param.addInt(String8(AUDIO_PARAMETER_DEVICE_CONNECT), device); - mpClientInterface->setParameters(AUDIO_IO_HANDLE_NONE, param.toString()); - } break; // handle output device disconnection case AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE: { @@ -202,9 +204,7 @@ status_t AudioPolicyManagerCustom::setDeviceConnectionStateInt(audio_devices_t d ALOGV("setDeviceConnectionState() disconnecting output device %x", device); // Send Disconnect to HALs - AudioParameter param = AudioParameter(devDesc->mAddress); - param.addInt(String8(AUDIO_PARAMETER_DEVICE_DISCONNECT), device); - mpClientInterface->setParameters(AUDIO_IO_HANDLE_NONE, param.toString()); + broadcastDeviceConnectionState(device, state, devDesc->mAddress); // remove device from available output devices mAvailableOutputDevices.remove(devDesc); @@ -321,7 +321,14 @@ status_t AudioPolicyManagerCustom::setDeviceConnectionStateInt(audio_devices_t d device); return INVALID_OPERATION; } + + // Before checking intputs, broadcast connect event to allow HAL to retrieve dynamic + // parameters on newly connected devices (instead of opening the inputs...) + broadcastDeviceConnectionState(device, state, devDesc->mAddress); + if (checkInputsForDevice(devDesc, state, inputs, devDesc->mAddress) != NO_ERROR) { + broadcastDeviceConnectionState(device, AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE, + devDesc->mAddress); return INVALID_OPERATION; } @@ -332,11 +339,6 @@ status_t AudioPolicyManagerCustom::setDeviceConnectionStateInt(audio_devices_t d return NO_MEMORY; } - // Set connect to HALs - AudioParameter param = AudioParameter(devDesc->mAddress); - param.addInt(String8(AUDIO_PARAMETER_DEVICE_CONNECT), device); - mpClientInterface->setParameters(AUDIO_IO_HANDLE_NONE, param.toString()); - // Propagate device availability to Engine mEngine->setDeviceConnectionState(devDesc, state); } break; @@ -351,9 +353,7 @@ status_t AudioPolicyManagerCustom::setDeviceConnectionStateInt(audio_devices_t d ALOGV("setDeviceConnectionState() disconnecting input device %x", device); // Set Disconnect to HALs - AudioParameter param = AudioParameter(devDesc->mAddress); - param.addInt(String8(AUDIO_PARAMETER_DEVICE_DISCONNECT), device); - mpClientInterface->setParameters(AUDIO_IO_HANDLE_NONE, param.toString()); + broadcastDeviceConnectionState(device, state, devDesc->mAddress); checkInputsForDevice(devDesc, state, inputs, devDesc->mAddress); mAvailableInputDevices.remove(devDesc); @@ -665,7 +665,7 @@ void AudioPolicyManagerCustom::setForceUse(audio_policy_force_use_t usage, } -status_t AudioPolicyManagerCustom::stopSource(sp<AudioOutputDescriptor> outputDesc, +status_t AudioPolicyManagerCustom::stopSource(const sp<AudioOutputDescriptor>& outputDesc, audio_stream_type_t stream, bool forceDeviceUpdate) { @@ -737,7 +737,7 @@ status_t AudioPolicyManagerCustom::stopSource(sp<AudioOutputDescriptor> outputDe return INVALID_OPERATION; } } -status_t AudioPolicyManagerCustom::startSource(sp<AudioOutputDescriptor> outputDesc, +status_t AudioPolicyManagerCustom::startSource(const sp<AudioOutputDescriptor>& outputDesc, audio_stream_type_t stream, audio_devices_t device, const char *address, diff --git a/policy_hal/AudioPolicyManager.h b/policy_hal/AudioPolicyManager.h index bda70fbe..770995b6 100644 --- a/policy_hal/AudioPolicyManager.h +++ b/policy_hal/AudioPolicyManager.h @@ -78,12 +78,12 @@ protected: // if argument "device" is different from AUDIO_DEVICE_NONE, startSource() will force // the re-evaluation of the output device. - status_t startSource(sp<AudioOutputDescriptor> outputDesc, + status_t startSource(const sp<AudioOutputDescriptor>& outputDesc, audio_stream_type_t stream, audio_devices_t device, const char *address, uint32_t *delayMs); - status_t stopSource(sp<AudioOutputDescriptor> outputDesc, + status_t stopSource(const sp<AudioOutputDescriptor>& outputDesc, audio_stream_type_t stream, bool forceDeviceUpdate); // event is one of STARTING_OUTPUT, STARTING_BEACON, STOPPING_OUTPUT, STOPPING_BEACON 313 |