summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Chen <chenche@codeaurora.org>2017-06-05 13:28:47 -0400
committerArne Coucheron <arco68@gmail.com>2017-10-13 19:28:54 +0000
commita82bc8b8e9d2ae00adc9c6bcc0c17f017354969c (patch)
tree335f61833701a67f91d15c467209aa0ed24946d4
parentf15c4f719af187ba10f326476c102fabba6ed7bf (diff)
downloadhardware_qcom_audio-a82bc8b8e9d2ae00adc9c6bcc0c17f017354969c.tar.gz
hardware_qcom_audio-a82bc8b8e9d2ae00adc9c6bcc0c17f017354969c.tar.bz2
hardware_qcom_audio-a82bc8b8e9d2ae00adc9c6bcc0c17f017354969c.zip
policy_hal: update custom audio policy APIs against AOSP
1) Update startSource() and stopSource() input parameter outputDesc to align with AOSP. 2) audio policy: broadcast device connect event before refreshing profiles This patch broadcasts the connect device event before checking and reloading capabilities of profiles. It allows the HAL implementor to use connect / disconnect event to respectively load / reset capabilities of devices that has dynamic capabilities (e.g. HDMI). Change-Id: Ie0533da25fed89cb9e5bbfc5b1fc886b3176837d CRs-fixed: 2056377 Change-Id: I15c877be8cdb85d1cb4b52a8b379ac254df3dca2
-rw-r--r--policy_hal/AudioPolicyManager.cpp36
-rw-r--r--policy_hal/AudioPolicyManager.h4
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