Loading services/audiopolicy/managerdefault/AudioPolicyManager.cpp +32 −14 Original line number Original line Diff line number Diff line Loading @@ -1080,8 +1080,16 @@ status_t AudioPolicyManager::startOutput(audio_io_handle_t output, mOutputRoutes.incRouteActivity(session); mOutputRoutes.incRouteActivity(session); audio_devices_t newDevice; audio_devices_t newDevice; AudioMix *policyMix = NULL; const char *address = NULL; if (outputDesc->mPolicyMix != NULL) { if (outputDesc->mPolicyMix != NULL) { policyMix = outputDesc->mPolicyMix; address = policyMix->mDeviceAddress.string(); if ((policyMix->mRouteFlags & MIX_ROUTE_FLAG_RENDER) == MIX_ROUTE_FLAG_RENDER) { newDevice = policyMix->mDeviceType; } else { newDevice = AUDIO_DEVICE_OUT_REMOTE_SUBMIX; newDevice = AUDIO_DEVICE_OUT_REMOTE_SUBMIX; } } else if (mOutputRoutes.hasRouteChanged(session)) { } else if (mOutputRoutes.hasRouteChanged(session)) { newDevice = getNewOutputDevice(outputDesc, false /*fromCache*/); newDevice = getNewOutputDevice(outputDesc, false /*fromCache*/); checkStrategyRoute(getStrategy(stream), output); checkStrategyRoute(getStrategy(stream), output); Loading @@ -1091,7 +1099,7 @@ status_t AudioPolicyManager::startOutput(audio_io_handle_t output, uint32_t delayMs = 0; uint32_t delayMs = 0; status_t status = startSource(outputDesc, stream, newDevice, &delayMs); status_t status = startSource(outputDesc, stream, newDevice, address, &delayMs); if (status != NO_ERROR) { if (status != NO_ERROR) { mOutputRoutes.decRouteActivity(session); mOutputRoutes.decRouteActivity(session); Loading @@ -1099,11 +1107,11 @@ status_t AudioPolicyManager::startOutput(audio_io_handle_t output, } } // Automatically enable the remote submix input when output is started on a re routing mix // Automatically enable the remote submix input when output is started on a re routing mix // of type MIX_TYPE_RECORDERS // of type MIX_TYPE_RECORDERS if (audio_is_remote_submix_device(newDevice) && outputDesc->mPolicyMix != NULL && if (audio_is_remote_submix_device(newDevice) && policyMix != NULL && outputDesc->mPolicyMix->mMixType == MIX_TYPE_RECORDERS) { policyMix->mMixType == MIX_TYPE_RECORDERS) { setDeviceConnectionStateInt(AUDIO_DEVICE_IN_REMOTE_SUBMIX, setDeviceConnectionStateInt(AUDIO_DEVICE_IN_REMOTE_SUBMIX, AUDIO_POLICY_DEVICE_STATE_AVAILABLE, AUDIO_POLICY_DEVICE_STATE_AVAILABLE, outputDesc->mPolicyMix->mDeviceAddress, address, "remote-submix"); "remote-submix"); } } Loading @@ -1117,6 +1125,7 @@ status_t AudioPolicyManager::startOutput(audio_io_handle_t output, status_t AudioPolicyManager::startSource(sp<AudioOutputDescriptor> outputDesc, status_t AudioPolicyManager::startSource(sp<AudioOutputDescriptor> outputDesc, audio_stream_type_t stream, audio_stream_type_t stream, audio_devices_t device, audio_devices_t device, const char *address, uint32_t *delayMs) uint32_t *delayMs) { { // cannot start playback of STREAM_TTS if any other output is being used // cannot start playback of STREAM_TTS if any other output is being used Loading Loading @@ -1173,7 +1182,7 @@ status_t AudioPolicyManager::startSource(sp<AudioOutputDescriptor> outputDesc, } } } } } } uint32_t muteWaitMs = setOutputDevice(outputDesc, device, force); uint32_t muteWaitMs = setOutputDevice(outputDesc, device, force, 0, NULL, address); // handle special case for sonification while in call // handle special case for sonification while in call if (isInCall()) { if (isInCall()) { Loading Loading @@ -2097,7 +2106,6 @@ status_t AudioPolicyManager::registerPolicyMixes(Vector<AudioMix> mixes) && (patch->mPatch.sinks[0].ext.device.type == device) && (patch->mPatch.sinks[0].ext.device.type == device) && (strncmp(patch->mPatch.sinks[0].ext.device.address, address.string(), && (strncmp(patch->mPatch.sinks[0].ext.device.address, address.string(), AUDIO_DEVICE_MAX_ADDRESS_LEN) == 0)) { AUDIO_DEVICE_MAX_ADDRESS_LEN) == 0)) { if (mPolicyMixes.registerMix(address, mixes[i], desc) != NO_ERROR) { if (mPolicyMixes.registerMix(address, mixes[i], desc) != NO_ERROR) { res = INVALID_OPERATION; res = INVALID_OPERATION; } else { } else { Loading Loading @@ -2976,7 +2984,7 @@ status_t AudioPolicyManager::connectAudioSource(const sp<AudioSourceDescriptor>& return INVALID_OPERATION; return INVALID_OPERATION; } } uint32_t delayMs = 0; uint32_t delayMs = 0; status = startSource(outputDesc, stream, sinkDevice, &delayMs); status = startSource(outputDesc, stream, sinkDevice, NULL, &delayMs); if (status != NO_ERROR) { if (status != NO_ERROR) { mpClientInterface->releaseAudioPatch(sourceDesc->mPatchDesc->mAfPatchHandle, 0); mpClientInterface->releaseAudioPatch(sourceDesc->mPatchDesc->mAfPatchHandle, 0); Loading Loading @@ -3200,6 +3208,10 @@ AudioPolicyManager::AudioPolicyManager(AudioPolicyClientInterface *clientInterfa } } sp<SwAudioOutputDescriptor> outputDesc = new SwAudioOutputDescriptor(outProfile, sp<SwAudioOutputDescriptor> outputDesc = new SwAudioOutputDescriptor(outProfile, mpClientInterface); mpClientInterface); const DeviceVector &supportedDevices = outProfile->getSupportedDevices(); const DeviceVector &devicesForType = supportedDevices.getDevicesFromType(profileType); String8 address = devicesForType.size() > 0 ? devicesForType.itemAt(0)->mAddress : String8(""); outputDesc->mDevice = profileType; outputDesc->mDevice = profileType; audio_config_t config = AUDIO_CONFIG_INITIALIZER; audio_config_t config = AUDIO_CONFIG_INITIALIZER; Loading @@ -3211,7 +3223,7 @@ AudioPolicyManager::AudioPolicyManager(AudioPolicyClientInterface *clientInterfa &output, &output, &config, &config, &outputDesc->mDevice, &outputDesc->mDevice, String8(""), address, &outputDesc->mLatency, &outputDesc->mLatency, outputDesc->mFlags); outputDesc->mFlags); Loading @@ -3224,7 +3236,6 @@ AudioPolicyManager::AudioPolicyManager(AudioPolicyClientInterface *clientInterfa outputDesc->mChannelMask = config.channel_mask; outputDesc->mChannelMask = config.channel_mask; outputDesc->mFormat = config.format; outputDesc->mFormat = config.format; const DeviceVector &supportedDevices = outProfile->getSupportedDevices(); for (size_t k = 0; k < supportedDevices.size(); k++) { for (size_t k = 0; k < supportedDevices.size(); k++) { ssize_t index = mAvailableOutputDevices.indexOf(supportedDevices[k]); ssize_t index = mAvailableOutputDevices.indexOf(supportedDevices[k]); // give a valid ID to an attached device once confirmed it is reachable // give a valid ID to an attached device once confirmed it is reachable Loading @@ -3239,7 +3250,10 @@ AudioPolicyManager::AudioPolicyManager(AudioPolicyClientInterface *clientInterfa addOutput(output, outputDesc); addOutput(output, outputDesc); setOutputDevice(outputDesc, setOutputDevice(outputDesc, outputDesc->mDevice, outputDesc->mDevice, true); true, 0, NULL, address.string()); } } } } // open input streams needed to access attached devices to validate // open input streams needed to access attached devices to validate Loading Loading @@ -4614,9 +4628,13 @@ uint32_t AudioPolicyManager::setOutputDevice(const sp<AudioOutputDescriptor>& ou if (device == AUDIO_DEVICE_NONE) { if (device == AUDIO_DEVICE_NONE) { resetOutputDevice(outputDesc, delayMs, NULL); resetOutputDevice(outputDesc, delayMs, NULL); } else { } else { DeviceVector deviceList = (address == NULL) ? DeviceVector deviceList; mAvailableOutputDevices.getDevicesFromType(device) if ((address == NULL) || (strlen(address) == 0)) { : mAvailableOutputDevices.getDevicesFromTypeAddr(device, String8(address)); deviceList = mAvailableOutputDevices.getDevicesFromType(device); } else { deviceList = mAvailableOutputDevices.getDevicesFromTypeAddr(device, String8(address)); } if (!deviceList.isEmpty()) { if (!deviceList.isEmpty()) { struct audio_patch patch; struct audio_patch patch; outputDesc->toAudioPortConfig(&patch.sources[0]); outputDesc->toAudioPortConfig(&patch.sources[0]); Loading services/audiopolicy/managerdefault/AudioPolicyManager.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -484,6 +484,7 @@ protected: status_t startSource(sp<AudioOutputDescriptor> outputDesc, status_t startSource(sp<AudioOutputDescriptor> outputDesc, audio_stream_type_t stream, audio_stream_type_t stream, audio_devices_t device, audio_devices_t device, const char *address, uint32_t *delayMs); uint32_t *delayMs); status_t stopSource(sp<AudioOutputDescriptor> outputDesc, status_t stopSource(sp<AudioOutputDescriptor> outputDesc, audio_stream_type_t stream, audio_stream_type_t stream, Loading Loading
services/audiopolicy/managerdefault/AudioPolicyManager.cpp +32 −14 Original line number Original line Diff line number Diff line Loading @@ -1080,8 +1080,16 @@ status_t AudioPolicyManager::startOutput(audio_io_handle_t output, mOutputRoutes.incRouteActivity(session); mOutputRoutes.incRouteActivity(session); audio_devices_t newDevice; audio_devices_t newDevice; AudioMix *policyMix = NULL; const char *address = NULL; if (outputDesc->mPolicyMix != NULL) { if (outputDesc->mPolicyMix != NULL) { policyMix = outputDesc->mPolicyMix; address = policyMix->mDeviceAddress.string(); if ((policyMix->mRouteFlags & MIX_ROUTE_FLAG_RENDER) == MIX_ROUTE_FLAG_RENDER) { newDevice = policyMix->mDeviceType; } else { newDevice = AUDIO_DEVICE_OUT_REMOTE_SUBMIX; newDevice = AUDIO_DEVICE_OUT_REMOTE_SUBMIX; } } else if (mOutputRoutes.hasRouteChanged(session)) { } else if (mOutputRoutes.hasRouteChanged(session)) { newDevice = getNewOutputDevice(outputDesc, false /*fromCache*/); newDevice = getNewOutputDevice(outputDesc, false /*fromCache*/); checkStrategyRoute(getStrategy(stream), output); checkStrategyRoute(getStrategy(stream), output); Loading @@ -1091,7 +1099,7 @@ status_t AudioPolicyManager::startOutput(audio_io_handle_t output, uint32_t delayMs = 0; uint32_t delayMs = 0; status_t status = startSource(outputDesc, stream, newDevice, &delayMs); status_t status = startSource(outputDesc, stream, newDevice, address, &delayMs); if (status != NO_ERROR) { if (status != NO_ERROR) { mOutputRoutes.decRouteActivity(session); mOutputRoutes.decRouteActivity(session); Loading @@ -1099,11 +1107,11 @@ status_t AudioPolicyManager::startOutput(audio_io_handle_t output, } } // Automatically enable the remote submix input when output is started on a re routing mix // Automatically enable the remote submix input when output is started on a re routing mix // of type MIX_TYPE_RECORDERS // of type MIX_TYPE_RECORDERS if (audio_is_remote_submix_device(newDevice) && outputDesc->mPolicyMix != NULL && if (audio_is_remote_submix_device(newDevice) && policyMix != NULL && outputDesc->mPolicyMix->mMixType == MIX_TYPE_RECORDERS) { policyMix->mMixType == MIX_TYPE_RECORDERS) { setDeviceConnectionStateInt(AUDIO_DEVICE_IN_REMOTE_SUBMIX, setDeviceConnectionStateInt(AUDIO_DEVICE_IN_REMOTE_SUBMIX, AUDIO_POLICY_DEVICE_STATE_AVAILABLE, AUDIO_POLICY_DEVICE_STATE_AVAILABLE, outputDesc->mPolicyMix->mDeviceAddress, address, "remote-submix"); "remote-submix"); } } Loading @@ -1117,6 +1125,7 @@ status_t AudioPolicyManager::startOutput(audio_io_handle_t output, status_t AudioPolicyManager::startSource(sp<AudioOutputDescriptor> outputDesc, status_t AudioPolicyManager::startSource(sp<AudioOutputDescriptor> outputDesc, audio_stream_type_t stream, audio_stream_type_t stream, audio_devices_t device, audio_devices_t device, const char *address, uint32_t *delayMs) uint32_t *delayMs) { { // cannot start playback of STREAM_TTS if any other output is being used // cannot start playback of STREAM_TTS if any other output is being used Loading Loading @@ -1173,7 +1182,7 @@ status_t AudioPolicyManager::startSource(sp<AudioOutputDescriptor> outputDesc, } } } } } } uint32_t muteWaitMs = setOutputDevice(outputDesc, device, force); uint32_t muteWaitMs = setOutputDevice(outputDesc, device, force, 0, NULL, address); // handle special case for sonification while in call // handle special case for sonification while in call if (isInCall()) { if (isInCall()) { Loading Loading @@ -2097,7 +2106,6 @@ status_t AudioPolicyManager::registerPolicyMixes(Vector<AudioMix> mixes) && (patch->mPatch.sinks[0].ext.device.type == device) && (patch->mPatch.sinks[0].ext.device.type == device) && (strncmp(patch->mPatch.sinks[0].ext.device.address, address.string(), && (strncmp(patch->mPatch.sinks[0].ext.device.address, address.string(), AUDIO_DEVICE_MAX_ADDRESS_LEN) == 0)) { AUDIO_DEVICE_MAX_ADDRESS_LEN) == 0)) { if (mPolicyMixes.registerMix(address, mixes[i], desc) != NO_ERROR) { if (mPolicyMixes.registerMix(address, mixes[i], desc) != NO_ERROR) { res = INVALID_OPERATION; res = INVALID_OPERATION; } else { } else { Loading Loading @@ -2976,7 +2984,7 @@ status_t AudioPolicyManager::connectAudioSource(const sp<AudioSourceDescriptor>& return INVALID_OPERATION; return INVALID_OPERATION; } } uint32_t delayMs = 0; uint32_t delayMs = 0; status = startSource(outputDesc, stream, sinkDevice, &delayMs); status = startSource(outputDesc, stream, sinkDevice, NULL, &delayMs); if (status != NO_ERROR) { if (status != NO_ERROR) { mpClientInterface->releaseAudioPatch(sourceDesc->mPatchDesc->mAfPatchHandle, 0); mpClientInterface->releaseAudioPatch(sourceDesc->mPatchDesc->mAfPatchHandle, 0); Loading Loading @@ -3200,6 +3208,10 @@ AudioPolicyManager::AudioPolicyManager(AudioPolicyClientInterface *clientInterfa } } sp<SwAudioOutputDescriptor> outputDesc = new SwAudioOutputDescriptor(outProfile, sp<SwAudioOutputDescriptor> outputDesc = new SwAudioOutputDescriptor(outProfile, mpClientInterface); mpClientInterface); const DeviceVector &supportedDevices = outProfile->getSupportedDevices(); const DeviceVector &devicesForType = supportedDevices.getDevicesFromType(profileType); String8 address = devicesForType.size() > 0 ? devicesForType.itemAt(0)->mAddress : String8(""); outputDesc->mDevice = profileType; outputDesc->mDevice = profileType; audio_config_t config = AUDIO_CONFIG_INITIALIZER; audio_config_t config = AUDIO_CONFIG_INITIALIZER; Loading @@ -3211,7 +3223,7 @@ AudioPolicyManager::AudioPolicyManager(AudioPolicyClientInterface *clientInterfa &output, &output, &config, &config, &outputDesc->mDevice, &outputDesc->mDevice, String8(""), address, &outputDesc->mLatency, &outputDesc->mLatency, outputDesc->mFlags); outputDesc->mFlags); Loading @@ -3224,7 +3236,6 @@ AudioPolicyManager::AudioPolicyManager(AudioPolicyClientInterface *clientInterfa outputDesc->mChannelMask = config.channel_mask; outputDesc->mChannelMask = config.channel_mask; outputDesc->mFormat = config.format; outputDesc->mFormat = config.format; const DeviceVector &supportedDevices = outProfile->getSupportedDevices(); for (size_t k = 0; k < supportedDevices.size(); k++) { for (size_t k = 0; k < supportedDevices.size(); k++) { ssize_t index = mAvailableOutputDevices.indexOf(supportedDevices[k]); ssize_t index = mAvailableOutputDevices.indexOf(supportedDevices[k]); // give a valid ID to an attached device once confirmed it is reachable // give a valid ID to an attached device once confirmed it is reachable Loading @@ -3239,7 +3250,10 @@ AudioPolicyManager::AudioPolicyManager(AudioPolicyClientInterface *clientInterfa addOutput(output, outputDesc); addOutput(output, outputDesc); setOutputDevice(outputDesc, setOutputDevice(outputDesc, outputDesc->mDevice, outputDesc->mDevice, true); true, 0, NULL, address.string()); } } } } // open input streams needed to access attached devices to validate // open input streams needed to access attached devices to validate Loading Loading @@ -4614,9 +4628,13 @@ uint32_t AudioPolicyManager::setOutputDevice(const sp<AudioOutputDescriptor>& ou if (device == AUDIO_DEVICE_NONE) { if (device == AUDIO_DEVICE_NONE) { resetOutputDevice(outputDesc, delayMs, NULL); resetOutputDevice(outputDesc, delayMs, NULL); } else { } else { DeviceVector deviceList = (address == NULL) ? DeviceVector deviceList; mAvailableOutputDevices.getDevicesFromType(device) if ((address == NULL) || (strlen(address) == 0)) { : mAvailableOutputDevices.getDevicesFromTypeAddr(device, String8(address)); deviceList = mAvailableOutputDevices.getDevicesFromType(device); } else { deviceList = mAvailableOutputDevices.getDevicesFromTypeAddr(device, String8(address)); } if (!deviceList.isEmpty()) { if (!deviceList.isEmpty()) { struct audio_patch patch; struct audio_patch patch; outputDesc->toAudioPortConfig(&patch.sources[0]); outputDesc->toAudioPortConfig(&patch.sources[0]); Loading
services/audiopolicy/managerdefault/AudioPolicyManager.h +1 −0 Original line number Original line Diff line number Diff line Loading @@ -484,6 +484,7 @@ protected: status_t startSource(sp<AudioOutputDescriptor> outputDesc, status_t startSource(sp<AudioOutputDescriptor> outputDesc, audio_stream_type_t stream, audio_stream_type_t stream, audio_devices_t device, audio_devices_t device, const char *address, uint32_t *delayMs); uint32_t *delayMs); status_t stopSource(sp<AudioOutputDescriptor> outputDesc, status_t stopSource(sp<AudioOutputDescriptor> outputDesc, audio_stream_type_t stream, audio_stream_type_t stream, Loading