Audio: Add routing option between HDMI speakers and device speakers

Add option that routing  between HDMI audio output and device audio
output, when HDMI is connected.

Change-Id: I9bbe9b1cbee5b6659502dae386c086f37bef2120
This commit is contained in:
Tanya Finkel 2014-03-05 23:59:45 +02:00
parent a372462d1f
commit de496d8d5f
3 changed files with 54 additions and 1 deletions

View File

@ -29,6 +29,9 @@ endif
ifneq ($(strip $(AUDIO_FEATURE_DISABLED_INCALL_MUSIC)),true)
LOCAL_CFLAGS += -DAUDIO_EXTN_INCALL_MUSIC_ENABLED
endif
ifneq ($(strip $(AUDIO_FEATURE_DISABLED_HDMI_SPK)),true)
LOCAL_CFLAGS += -DAUDIO_EXTN_HDMI_SPK_ENABLED
endif
ifeq ($(strip $(TARGET_BOARD_PLATFORM)),msm8916)

View File

@ -44,6 +44,7 @@ namespace android_audio_legacy {
// ----------------------------------------------------------------------------
// AudioPolicyInterface implementation
// ----------------------------------------------------------------------------
const char* AudioPolicyManager::HDMI_SPKR_STR = "hdmi_spkr";
status_t AudioPolicyManager::setDeviceConnectionState(audio_devices_t device,
AudioSystem::device_connection_state state,
@ -85,6 +86,15 @@ status_t AudioPolicyManager::setDeviceConnectionState(audio_devices_t device,
// handle output device connection
case AudioSystem::DEVICE_STATE_AVAILABLE:
if (mAvailableOutputDevices & device) {
#ifdef AUDIO_EXTN_HDMI_SPK_ENABLED
if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_AUX_DIGITAL)) {
if (!strncmp(device_address, HDMI_SPKR_STR, MAX_DEVICE_ADDRESS_LEN)) {
mHdmiAudioDisabled = false;
} else {
mHdmiAudioEvent = true;
}
}
#endif
ALOGW("setDeviceConnectionState() device already connected: %x", device);
return INVALID_OPERATION;
}
@ -98,6 +108,18 @@ status_t AudioPolicyManager::setDeviceConnectionState(audio_devices_t device,
// register new device as available
mAvailableOutputDevices = (audio_devices_t)(mAvailableOutputDevices | device);
#ifdef AUDIO_EXTN_HDMI_SPK_ENABLED
if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_AUX_DIGITAL)) {
if (!strncmp(device_address, HDMI_SPKR_STR, MAX_DEVICE_ADDRESS_LEN)) {
mHdmiAudioDisabled = false;
} else {
mHdmiAudioEvent = true;
}
if (mHdmiAudioDisabled || !mHdmiAudioEvent) {
mAvailableOutputDevices = (audio_devices_t)(mAvailableOutputDevices & ~device);
}
}
#endif
if (!outputs.isEmpty()) {
String8 paramStr;
if (mHasA2dp && audio_is_a2dp_device(device)) {
@ -127,6 +149,15 @@ status_t AudioPolicyManager::setDeviceConnectionState(audio_devices_t device,
// handle output device disconnection
case AudioSystem::DEVICE_STATE_UNAVAILABLE: {
if (!(mAvailableOutputDevices & device)) {
#ifdef AUDIO_EXTN_HDMI_SPK_ENABLED
if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_AUX_DIGITAL)) {
if (!strncmp(device_address, HDMI_SPKR_STR, MAX_DEVICE_ADDRESS_LEN)) {
mHdmiAudioDisabled = true;
} else {
mHdmiAudioEvent = false;
}
}
#endif
ALOGW("setDeviceConnectionState() device not connected: %x", device);
return INVALID_OPERATION;
}
@ -135,6 +166,15 @@ status_t AudioPolicyManager::setDeviceConnectionState(audio_devices_t device,
// remove device from available output devices
mAvailableOutputDevices = (audio_devices_t)(mAvailableOutputDevices & ~device);
#ifdef AUDIO_EXTN_HDMI_SPK_ENABLED
if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_AUX_DIGITAL)) {
if (!strncmp(device_address, HDMI_SPKR_STR, MAX_DEVICE_ADDRESS_LEN)) {
mHdmiAudioDisabled = true;
} else {
mHdmiAudioEvent = false;
}
}
#endif
checkOutputsForDevice(device, state, outputs);
if (mHasA2dp && audio_is_a2dp_device(device)) {
// handle A2DP device disconnection

View File

@ -35,7 +35,9 @@ class AudioPolicyManager: public AudioPolicyManagerBase
public:
AudioPolicyManager(AudioPolicyClientInterface *clientInterface)
: AudioPolicyManagerBase(clientInterface) {}
: AudioPolicyManagerBase(clientInterface) {
mHdmiAudioDisabled = false;
mHdmiAudioEvent = false; }
virtual ~AudioPolicyManager() {}
@ -89,5 +91,13 @@ protected:
// returns the category the device belongs to with regard to volume curve management
static device_category getDeviceCategory(audio_devices_t device);
static const char* HDMI_SPKR_STR;
//parameter indicates of HDMI speakers disabled from the Qualcomm settings
bool mHdmiAudioDisabled;
//parameter indicates if HDMI plug in/out detected
bool mHdmiAudioEvent;
};
};