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:
parent
a372462d1f
commit
de496d8d5f
|
@ -29,6 +29,9 @@ endif
|
||||||
ifneq ($(strip $(AUDIO_FEATURE_DISABLED_INCALL_MUSIC)),true)
|
ifneq ($(strip $(AUDIO_FEATURE_DISABLED_INCALL_MUSIC)),true)
|
||||||
LOCAL_CFLAGS += -DAUDIO_EXTN_INCALL_MUSIC_ENABLED
|
LOCAL_CFLAGS += -DAUDIO_EXTN_INCALL_MUSIC_ENABLED
|
||||||
endif
|
endif
|
||||||
|
ifneq ($(strip $(AUDIO_FEATURE_DISABLED_HDMI_SPK)),true)
|
||||||
|
LOCAL_CFLAGS += -DAUDIO_EXTN_HDMI_SPK_ENABLED
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
ifeq ($(strip $(TARGET_BOARD_PLATFORM)),msm8916)
|
ifeq ($(strip $(TARGET_BOARD_PLATFORM)),msm8916)
|
||||||
|
|
|
@ -44,6 +44,7 @@ namespace android_audio_legacy {
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// AudioPolicyInterface implementation
|
// AudioPolicyInterface implementation
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
const char* AudioPolicyManager::HDMI_SPKR_STR = "hdmi_spkr";
|
||||||
|
|
||||||
status_t AudioPolicyManager::setDeviceConnectionState(audio_devices_t device,
|
status_t AudioPolicyManager::setDeviceConnectionState(audio_devices_t device,
|
||||||
AudioSystem::device_connection_state state,
|
AudioSystem::device_connection_state state,
|
||||||
|
@ -85,6 +86,15 @@ status_t AudioPolicyManager::setDeviceConnectionState(audio_devices_t device,
|
||||||
// handle output device connection
|
// handle output device connection
|
||||||
case AudioSystem::DEVICE_STATE_AVAILABLE:
|
case AudioSystem::DEVICE_STATE_AVAILABLE:
|
||||||
if (mAvailableOutputDevices & device) {
|
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);
|
ALOGW("setDeviceConnectionState() device already connected: %x", device);
|
||||||
return INVALID_OPERATION;
|
return INVALID_OPERATION;
|
||||||
}
|
}
|
||||||
|
@ -98,6 +108,18 @@ status_t AudioPolicyManager::setDeviceConnectionState(audio_devices_t device,
|
||||||
// register new device as available
|
// register new device as available
|
||||||
mAvailableOutputDevices = (audio_devices_t)(mAvailableOutputDevices | device);
|
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()) {
|
if (!outputs.isEmpty()) {
|
||||||
String8 paramStr;
|
String8 paramStr;
|
||||||
if (mHasA2dp && audio_is_a2dp_device(device)) {
|
if (mHasA2dp && audio_is_a2dp_device(device)) {
|
||||||
|
@ -127,6 +149,15 @@ status_t AudioPolicyManager::setDeviceConnectionState(audio_devices_t device,
|
||||||
// handle output device disconnection
|
// handle output device disconnection
|
||||||
case AudioSystem::DEVICE_STATE_UNAVAILABLE: {
|
case AudioSystem::DEVICE_STATE_UNAVAILABLE: {
|
||||||
if (!(mAvailableOutputDevices & device)) {
|
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);
|
ALOGW("setDeviceConnectionState() device not connected: %x", device);
|
||||||
return INVALID_OPERATION;
|
return INVALID_OPERATION;
|
||||||
}
|
}
|
||||||
|
@ -135,6 +166,15 @@ status_t AudioPolicyManager::setDeviceConnectionState(audio_devices_t device,
|
||||||
// remove device from available output devices
|
// remove device from available output devices
|
||||||
mAvailableOutputDevices = (audio_devices_t)(mAvailableOutputDevices & ~device);
|
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);
|
checkOutputsForDevice(device, state, outputs);
|
||||||
if (mHasA2dp && audio_is_a2dp_device(device)) {
|
if (mHasA2dp && audio_is_a2dp_device(device)) {
|
||||||
// handle A2DP device disconnection
|
// handle A2DP device disconnection
|
||||||
|
|
|
@ -35,7 +35,9 @@ class AudioPolicyManager: public AudioPolicyManagerBase
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AudioPolicyManager(AudioPolicyClientInterface *clientInterface)
|
AudioPolicyManager(AudioPolicyClientInterface *clientInterface)
|
||||||
: AudioPolicyManagerBase(clientInterface) {}
|
: AudioPolicyManagerBase(clientInterface) {
|
||||||
|
mHdmiAudioDisabled = false;
|
||||||
|
mHdmiAudioEvent = false; }
|
||||||
|
|
||||||
virtual ~AudioPolicyManager() {}
|
virtual ~AudioPolicyManager() {}
|
||||||
|
|
||||||
|
@ -89,5 +91,13 @@ protected:
|
||||||
// returns the category the device belongs to with regard to volume curve management
|
// returns the category the device belongs to with regard to volume curve management
|
||||||
static device_category getDeviceCategory(audio_devices_t device);
|
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;
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue