Add a mechanism for handling audio device configuration change
* Added new call handleDeviceConfigChange() to the Media Framework.
That call can be used when there are device configuration changes
(e.g., Bluetooth A2DP codec configuration has changed).
* Added new method AudioPolicyManager::handleDeviceConfigChange().
That method toggles the UNAVAILABLE/AVAILABLE connection state of the
device, so it can be reconfigured as appropriate - e.g., the audio
feeding parameters can be updated.
* Fix ALOGVV compilation errors when extra logging is enabled.
Test: A2DP streaming to headsets
Bug: 30958229
Change-Id: I388abbbb3ec4d1a003b441cb0c77e00d80cad668
diff --git a/media/libaudioclient/AudioSystem.cpp b/media/libaudioclient/AudioSystem.cpp
index 33974e0..bbe6a8f 100644
--- a/media/libaudioclient/AudioSystem.cpp
+++ b/media/libaudioclient/AudioSystem.cpp
@@ -751,6 +751,25 @@
return aps->getDeviceConnectionState(device, device_address);
}
+status_t AudioSystem::handleDeviceConfigChange(audio_devices_t device,
+ const char *device_address,
+ const char *device_name)
+{
+ const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
+ const char *address = "";
+ const char *name = "";
+
+ if (aps == 0) return PERMISSION_DENIED;
+
+ if (device_address != NULL) {
+ address = device_address;
+ }
+ if (device_name != NULL) {
+ name = device_name;
+ }
+ return aps->handleDeviceConfigChange(device, address, name);
+}
+
status_t AudioSystem::setPhoneState(audio_mode_t state)
{
if (uint32_t(state) >= AUDIO_MODE_CNT) return BAD_VALUE;
diff --git a/media/libaudioclient/IAudioPolicyService.cpp b/media/libaudioclient/IAudioPolicyService.cpp
index 946da8a..222189a 100644
--- a/media/libaudioclient/IAudioPolicyService.cpp
+++ b/media/libaudioclient/IAudioPolicyService.cpp
@@ -33,6 +33,7 @@
enum {
SET_DEVICE_CONNECTION_STATE = IBinder::FIRST_CALL_TRANSACTION,
GET_DEVICE_CONNECTION_STATE,
+ HANDLE_DEVICE_CONFIG_CHANGE,
SET_PHONE_STATE,
SET_RINGER_MODE, // reserved, no longer used
SET_FORCE_USE,
@@ -116,6 +117,19 @@
return static_cast <audio_policy_dev_state_t>(reply.readInt32());
}
+ virtual status_t handleDeviceConfigChange(audio_devices_t device,
+ const char *device_address,
+ const char *device_name)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
+ data.writeInt32(static_cast <uint32_t>(device));
+ data.writeCString(device_address);
+ data.writeCString(device_name);
+ remote()->transact(HANDLE_DEVICE_CONFIG_CHANGE, data, &reply);
+ return static_cast <status_t> (reply.readInt32());
+ }
+
virtual status_t setPhoneState(audio_mode_t state)
{
Parcel data, reply;
@@ -838,6 +852,18 @@
return NO_ERROR;
} break;
+ case HANDLE_DEVICE_CONFIG_CHANGE: {
+ CHECK_INTERFACE(IAudioPolicyService, data, reply);
+ audio_devices_t device =
+ static_cast <audio_devices_t>(data.readInt32());
+ const char *device_address = data.readCString();
+ const char *device_name = data.readCString();
+ reply->writeInt32(static_cast<uint32_t> (handleDeviceConfigChange(device,
+ device_address,
+ device_name)));
+ return NO_ERROR;
+ } break;
+
case SET_PHONE_STATE: {
CHECK_INTERFACE(IAudioPolicyService, data, reply);
reply->writeInt32(static_cast <uint32_t>(setPhoneState(