Stop using audio device types as bit mask in policy.h

Bug: 135621476
Test: atest AudioHostTest, AudioPlaybackCaptureTest
Test: atest AudioServiceHostTest, audiopolicy_tests
Test: listen to music, make phone call with BT device
Test: test play music via Android Auto emulator
Change-Id: I154555579b0ebb8b020d00e9c05c8b9f79a08db4
Merged-In: I154555579b0ebb8b020d00e9c05c8b9f79a08db4
gugelfrei
jiabin 5 years ago
parent d7631f083d
commit 9b307d7e1e

@ -42,14 +42,6 @@ static const uint32_t SONIFICATION_RESPECTFUL_AFTER_MUSIC_DELAY = 5000;
// Do not limit channel count otherwise
#define MAX_MIXER_CHANNEL_COUNT FCC_8
/**
* A device mask for all audio input and output devices where matching inputs/outputs on device
* type alone is not enough: the address must match too
*/
#define APM_AUDIO_DEVICE_OUT_MATCH_ADDRESS_ALL (AUDIO_DEVICE_OUT_REMOTE_SUBMIX|AUDIO_DEVICE_OUT_BUS)
#define APM_AUDIO_DEVICE_IN_MATCH_ADDRESS_ALL (AUDIO_DEVICE_IN_REMOTE_SUBMIX|AUDIO_DEVICE_IN_BUS)
/**
* Alias to AUDIO_DEVICE_OUT_DEFAULT defined for clarification when this value is used by volume
* control APIs (e.g setStreamVolumeIndex().
@ -70,6 +62,34 @@ static inline bool is_state_in_call(int state)
return (state == AUDIO_MODE_IN_CALL) || (state == AUDIO_MODE_IN_COMMUNICATION);
}
/**
* Check whether the output device type is one
* where addresses are used to distinguish between one connected device and another
*
* @param[in] device to consider
*
* @return true if the device needs distinguish on address, false otherwise..
*/
static inline bool apm_audio_out_device_distinguishes_on_address(audio_devices_t device)
{
return device == AUDIO_DEVICE_OUT_REMOTE_SUBMIX ||
device == AUDIO_DEVICE_OUT_BUS;
}
/**
* Check whether the input device type is one
* where addresses are used to distinguish between one connected device and another
*
* @param[in] device to consider
*
* @return true if the device needs distinguish on address, false otherwise..
*/
static inline bool apm_audio_in_device_distinguishes_on_address(audio_devices_t device)
{
return device == AUDIO_DEVICE_IN_REMOTE_SUBMIX ||
device == AUDIO_DEVICE_IN_BUS;
}
/**
* Check whether the device type is one
* where addresses are used to distinguish between one connected device and another
@ -80,10 +100,8 @@ static inline bool is_state_in_call(int state)
*/
static inline bool device_distinguishes_on_address(audio_devices_t device)
{
return (((device & AUDIO_DEVICE_BIT_IN) != 0) &&
((~AUDIO_DEVICE_BIT_IN & device & APM_AUDIO_DEVICE_IN_MATCH_ADDRESS_ALL) != 0)) ||
(((device & AUDIO_DEVICE_BIT_IN) == 0) &&
((device & APM_AUDIO_DEVICE_OUT_MATCH_ADDRESS_ALL) != 0));
return apm_audio_in_device_distinguishes_on_address(device) ||
apm_audio_out_device_distinguishes_on_address(device);
}
/**
@ -95,10 +113,7 @@ static inline bool device_distinguishes_on_address(audio_devices_t device)
*/
static inline bool device_has_encoding_capability(audio_devices_t device)
{
if (device & AUDIO_DEVICE_OUT_ALL_A2DP) {
return true;
}
return false;
return audio_is_a2dp_out_device(device);
}
/**

Loading…
Cancel
Save