Fix potential overflow in Visualizer effect am: 57ac66340a am: 63a995164c am: 38dcbab6b3 am: 624981438d am: 94cc18ee82
am: 3f11c1f175
Change-Id: Iabb0b3b45b7eb0d559ee26c3c7c2ea7ebd1e8b55
diff --git a/hal/Android.mk b/hal/Android.mk
index 18b8bf4..a7531e8 100644
--- a/hal/Android.mk
+++ b/hal/Android.mk
@@ -54,6 +54,10 @@
LOCAL_SRC_FILES += audio_extn/hfp.c
endif
+ifeq ($(strip $(AUDIO_FEATURE_NO_AUDIO_OUT)),true)
+ LOCAL_CFLAGS += -DNO_AUDIO_OUT
+endif
+
LOCAL_MODULE := audio.primary.$(TARGET_BOARD_PLATFORM)
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 864ab5c..8b2ac5e 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1446,6 +1446,23 @@
return -ENOSYS;
}
+#ifdef NO_AUDIO_OUT
+static ssize_t out_write_for_no_output(struct audio_stream_out *stream,
+ const void *buffer, size_t bytes)
+{
+ struct stream_out *out = (struct stream_out *)stream;
+
+ /* No Output device supported other than BT for playback.
+ * Sleep for the amount of buffer duration
+ */
+ pthread_mutex_lock(&out->lock);
+ usleep(bytes * 1000000 / audio_stream_frame_size(&out->stream.common) /
+ out_get_sample_rate(&out->stream.common));
+ pthread_mutex_unlock(&out->lock);
+ return bytes;
+}
+#endif
+
static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
size_t bytes)
{
@@ -2088,7 +2105,11 @@
out->stream.common.remove_audio_effect = out_remove_audio_effect;
out->stream.get_latency = out_get_latency;
out->stream.set_volume = out_set_volume;
+#ifdef NO_AUDIO_OUT
+ out->stream.write = out_write_for_no_output;
+#else
out->stream.write = out_write;
+#endif
out->stream.get_render_position = out_get_render_position;
out->stream.get_next_write_timestamp = out_get_next_write_timestamp;
out->stream.get_presentation_position = out_get_presentation_position;
diff --git a/legacy/alsa_sound/Android.mk b/legacy/alsa_sound/Android.mk
index 534dd6a..8d5c84d 100644
--- a/legacy/alsa_sound/Android.mk
+++ b/legacy/alsa_sound/Android.mk
@@ -45,11 +45,7 @@
libpower \
libalsa-intf
-ifeq ($(TARGET_SIMULATOR),true)
- LOCAL_LDLIBS += -ldl
-else
- LOCAL_SHARED_LIBRARIES += libdl
-endif
+LOCAL_SHARED_LIBRARIES += libdl
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/audio-alsa
LOCAL_C_INCLUDES += $(TARGET_OUT_HEADERS)/mm-audio/libalsa-intf
@@ -97,7 +93,6 @@
include $(CLEAR_VARS)
-LOCAL_PRELINK_MODULE := false
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
@@ -128,11 +123,7 @@
liblog \
libalsa-intf
-ifeq ($(TARGET_SIMULATOR),true)
- LOCAL_LDLIBS += -ldl
-else
- LOCAL_SHARED_LIBRARIES += libdl
-endif
+LOCAL_SHARED_LIBRARIES += libdl
LOCAL_MODULE:= alsa.msm8960
LOCAL_MODULE_TAGS := optional
diff --git a/legacy/libalsa-intf/Android.mk b/legacy/libalsa-intf/Android.mk
index 5d509b3..c259d9f 100644
--- a/legacy/libalsa-intf/Android.mk
+++ b/legacy/libalsa-intf/Android.mk
@@ -44,11 +44,6 @@
LOCAL_SHARED_LIBRARIES:= libc libcutils #libutils #libmedia libhardware_legacy
LOCAL_CFLAGS := -DQC_PROP -DCONFIG_DIR=\"/system/etc/snd_soc_msm/\"
-ifeq ($(TARGET_SIMULATOR),true)
- LOCAL_LDLIBS += -ldl
-else
- LOCAL_SHARED_LIBRARIES += libdl
-endif
-LOCAL_PRELINK_MODULE := false
+LOCAL_SHARED_LIBRARIES += libdl
include $(BUILD_SHARED_LIBRARY)
endif
diff --git a/post_proc/effect_api.c b/post_proc/effect_api.c
index cf3968b..9c15e8f 100644
--- a/post_proc/effect_api.c
+++ b/post_proc/effect_api.c
@@ -17,6 +17,7 @@
#define LOG_TAG "offload_effect_api"
//#define LOG_NDEBUG 0
+#include <errno.h>
#include <stdbool.h>
#include <cutils/log.h>
#include <tinyalsa/asoundlib.h>