summaryrefslogtreecommitdiffstats
path: root/hal
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2013-09-18 20:58:29 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-18 20:58:29 +0000
commit957b4382a1fdd8b7bf3cb32db32041887863fa37 (patch)
tree71c7334b930d0d1b1bd8d0df65a4e2b23f5a26b8 /hal
parentb891db5473ab23a0cbc52d566a97c3d3529f8ddd (diff)
parentc4aef75c2c5a0d49cac941d22235ac0b9e435ca0 (diff)
downloadandroid_hardware_qcom_audio-957b4382a1fdd8b7bf3cb32db32041887863fa37.tar.gz
android_hardware_qcom_audio-957b4382a1fdd8b7bf3cb32db32041887863fa37.tar.bz2
android_hardware_qcom_audio-957b4382a1fdd8b7bf3cb32db32041887863fa37.zip
Merge "add offloaded audio visualizer" into klp-dev
Diffstat (limited to 'hal')
-rw-r--r--hal/audio_hw.c25
-rw-r--r--hal/audio_hw.h7
2 files changed, 32 insertions, 0 deletions
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 4f92ea3a..c2997c66 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -29,6 +29,7 @@
#include <sys/time.h>
#include <stdlib.h>
#include <math.h>
+#include <dlfcn.h>
#include <sys/resource.h>
#include <sys/prctl.h>
@@ -797,6 +798,10 @@ static int stop_output_stream(struct stream_out *out)
return -EINVAL;
}
+ if (out->usecase == USECASE_AUDIO_PLAYBACK_OFFLOAD &&
+ adev->visualizer_stop_output != NULL)
+ adev->visualizer_stop_output(out->handle);
+
/* 1. Get and set stream specific mixer controls */
disable_audio_route(adev, uc_info, true);
@@ -863,6 +868,9 @@ int start_output_stream(struct stream_out *out)
}
if (out->offload_callback)
compress_nonblock(out->compr, out->non_blocking);
+
+ if (adev->visualizer_start_output != NULL)
+ adev->visualizer_start_output(out->handle);
}
ALOGV("%s: exit", __func__);
return 0;
@@ -1742,6 +1750,7 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
out->sample_rate = config->sample_rate;
out->channel_mask = AUDIO_CHANNEL_OUT_STEREO;
out->supported_channel_masks[0] = AUDIO_CHANNEL_OUT_STEREO;
+ out->handle = handle;
/* Init use case and pcm_config */
if (out->flags & AUDIO_OUTPUT_FLAG_DIRECT &&
@@ -2263,6 +2272,22 @@ static int adev_open(const hw_module_t *module, const char *name,
*device = NULL;
return -EINVAL;
}
+
+ if (access(VISUALIZER_LIBRARY_PATH, R_OK) == 0) {
+ adev->visualizer_lib = dlopen(VISUALIZER_LIBRARY_PATH, RTLD_NOW);
+ if (adev->visualizer_lib == NULL) {
+ ALOGE("%s: DLOPEN failed for %s", __func__, VISUALIZER_LIBRARY_PATH);
+ } else {
+ ALOGV("%s: DLOPEN successful for %s", __func__, VISUALIZER_LIBRARY_PATH);
+ adev->visualizer_start_output =
+ (int (*)(audio_io_handle_t))dlsym(adev->visualizer_lib,
+ "visualizer_hal_start_output");
+ adev->visualizer_stop_output =
+ (int (*)(audio_io_handle_t))dlsym(adev->visualizer_lib,
+ "visualizer_hal_stop_output");
+ }
+ }
+
*device = &adev->device.common;
ALOGV("%s: exit", __func__);
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 2c7fffd8..717c0a6c 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -25,6 +25,8 @@
#include <audio_route/audio_route.h>
+#define VISUALIZER_LIBRARY_PATH "/system/lib/soundfx/libqcomvisualizer.so"
+
/* Flags used to initialize acdb_settings variable that goes to ACDB library */
#define DMIC_FLAG 0x00000002
#define TTY_MODE_OFF 0x00000010
@@ -110,6 +112,7 @@ struct stream_out {
audio_channel_mask_t supported_channel_masks[MAX_SUPPORTED_CHANNEL_MASKS + 1];
bool muted;
uint64_t written; /* total frames written, not cleared when entering standby */
+ audio_io_handle_t handle;
int non_blocking;
int playback_started;
@@ -187,6 +190,10 @@ struct audio_device {
bool speaker_lr_swap;
void *platform;
+
+ void *visualizer_lib;
+ int (*visualizer_start_output)(audio_io_handle_t);
+ int (*visualizer_stop_output)(audio_io_handle_t);
};
/*