Skip to content
Browse files

alsa_sound: Make low-latency audio feature optional

 * This requires a baseband update on most devices, so make it optional.

Change-Id: I0be3b6d0c19c26663c9ce8a26d5769a8940b318c
  • Loading branch information...
1 parent 9eb1a4f commit b469b0ea98baf3b1866865206c0c93e7e8baec30 @cyanogen cyanogen committed Dec 1, 2012
Showing with 21 additions and 1 deletion.
  1. +4 −0 alsa_sound/Android.mk
  2. +17 −1 alsa_sound/AudioHardwareALSA.cpp
View
4 alsa_sound/Android.mk
@@ -22,6 +22,10 @@ ifeq ($(strip $(BOARD_USES_SEPERATED_AUDIO_INPUT)),true)
LOCAL_CFLAGS += -DSEPERATED_AUDIO_INPUT
endif
+ifeq ($(strip $(BOARD_HAVE_LOW_LATENCY_AUDIO)),true)
+LOCAL_CFLAGS += -DQCOM_LOW_LATENCY_AUDIO_ENABLED
+endif
+
LOCAL_SRC_FILES := \
AudioHardwareALSA.cpp \
AudioStreamOutALSA.cpp \
View
18 alsa_sound/AudioHardwareALSA.cpp
@@ -905,7 +905,7 @@ AudioHardwareALSA::openOutputStream(uint32_t devices,
char *use_case;
snd_use_case_get(mUcMgr, "_verb", (const char **)&use_case);
-
+#ifdef QCOM_LOW_LATENCY_AUDIO_ENABLED
if (flag & AUDIO_OUTPUT_FLAG_DEEP_BUFFER) {
ALOGD("openOutputStream: DeepBuffer Output");
alsa_handle.isDeepbufferOutput = true;
@@ -924,6 +924,14 @@ AudioHardwareALSA::openOutputStream(uint32_t devices,
strlcpy(alsa_handle.useCase, SND_USE_CASE_MOD_PLAY_LOWLATENCY_MUSIC, sizeof(alsa_handle.useCase));
}
}
+#else
+ ALOGD("openOutputStream: Standard Output");
+ if ((use_case == NULL) || (!strcmp(use_case, SND_USE_CASE_VERB_INACTIVE))) {
+ strlcpy(alsa_handle.useCase, SND_USE_CASE_VERB_HIFI, sizeof(alsa_handle.useCase));
+ } else {
+ strlcpy(alsa_handle.useCase, SND_USE_CASE_MOD_PLAY_MUSIC, sizeof(alsa_handle.useCase));
+ }
+#endif
free(use_case);
mDeviceList.push_back(alsa_handle);
ALSAHandleList::iterator it = mDeviceList.end();
@@ -937,6 +945,7 @@ AudioHardwareALSA::openOutputStream(uint32_t devices,
}
#endif
mALSADevice->route(&(*it), devices, mode());
+#ifdef QCOM_LOW_LATENCY_AUDIO_ENABLED
if (flag & AUDIO_OUTPUT_FLAG_DEEP_BUFFER) {
if(!strcmp(it->useCase, SND_USE_CASE_VERB_HIFI)) {
snd_use_case_set(mUcMgr, "_verb", SND_USE_CASE_VERB_HIFI);
@@ -950,6 +959,13 @@ AudioHardwareALSA::openOutputStream(uint32_t devices,
snd_use_case_set(mUcMgr, "_enamod", SND_USE_CASE_MOD_PLAY_LOWLATENCY_MUSIC);
}
}
+#else
+ if(!strcmp(it->useCase, SND_USE_CASE_VERB_HIFI)) {
+ snd_use_case_set(mUcMgr, "_verb", SND_USE_CASE_VERB_HIFI);
+ } else {
+ snd_use_case_set(mUcMgr, "_enamod", SND_USE_CASE_MOD_PLAY_MUSIC);
+ }
+#endif
err = mALSADevice->open(&(*it));
if (err) {
ALOGE("Device open failed");

0 comments on commit b469b0e

Please sign in to comment.
Something went wrong with that request. Please try again.