diff options
author | Ricardo Garcia <rago@google.com> | 2015-03-23 17:21:15 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-03-23 17:21:17 +0000 |
commit | d6f524bc7d0438ba8427deb7b15736dd2adff82b (patch) | |
tree | 67aafb1fc3e49c613d06e6edc5f2a6a31d49d170 /modules | |
parent | 6c560c0233ee551d38d79e28ff5e8b74eb8a5947 (diff) | |
parent | 37cd77257b07d6f078763e9435487698dfb353c4 (diff) | |
download | hardware_libhardware-d6f524bc7d0438ba8427deb7b15736dd2adff82b.zip hardware_libhardware-d6f524bc7d0438ba8427deb7b15736dd2adff82b.tar.gz hardware_libhardware-d6f524bc7d0438ba8427deb7b15736dd2adff82b.tar.bz2 |
Merge "Creating audio.stub.default for default HAL audio output"
Diffstat (limited to 'modules')
-rw-r--r-- | modules/audio/Android.mk | 17 | ||||
-rw-r--r-- | modules/audio/audio_hw.c | 61 |
2 files changed, 71 insertions, 7 deletions
diff --git a/modules/audio/Android.mk b/modules/audio/Android.mk index a31c85f..ef4b8f5 100644 --- a/modules/audio/Android.mk +++ b/modules/audio/Android.mk @@ -31,6 +31,23 @@ LOCAL_CFLAGS := -Wno-unused-parameter include $(BUILD_SHARED_LIBRARY) +# The stub audio HAL module, identical to the default audio hal, but with +# different name to be loaded concurrently with other audio HALs if necessary. +# This can also be used as skeleton for new implementations +# +# The format of the name is audio.<type>.<hardware/etc>.so where the only +# required type is 'primary'. Other possibilites are 'a2dp', 'usb', etc. +include $(CLEAR_VARS) + +LOCAL_MODULE := audio.stub.default +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_SRC_FILES := audio_hw.c +LOCAL_SHARED_LIBRARIES := liblog libcutils +LOCAL_MODULE_TAGS := optional +LOCAL_CFLAGS := -Wno-unused-parameter + +include $(BUILD_SHARED_LIBRARY) + # The stub audio policy HAL module that can be used as a skeleton for # new implementations. include $(CLEAR_VARS) diff --git a/modules/audio/audio_hw.c b/modules/audio/audio_hw.c index 637e3f4..de8685d 100644 --- a/modules/audio/audio_hw.c +++ b/modules/audio/audio_hw.c @@ -48,65 +48,78 @@ static uint32_t out_get_sample_rate(const struct audio_stream *stream) static int out_set_sample_rate(struct audio_stream *stream, uint32_t rate) { - return 0; + ALOGV("out_set_sample_rate: %d", 0); + return -ENOSYS; } static size_t out_get_buffer_size(const struct audio_stream *stream) { + ALOGV("out_get_buffer_size: %d", 4096); return 4096; } static audio_channel_mask_t out_get_channels(const struct audio_stream *stream) { + ALOGV("out_get_channels"); return AUDIO_CHANNEL_OUT_STEREO; } static audio_format_t out_get_format(const struct audio_stream *stream) { + ALOGV("out_get_format"); return AUDIO_FORMAT_PCM_16_BIT; } static int out_set_format(struct audio_stream *stream, audio_format_t format) { - return 0; + ALOGV("out_set_format: %d",format); + return -ENOSYS; } static int out_standby(struct audio_stream *stream) { + ALOGV("out_standby"); + return 0; } static int out_dump(const struct audio_stream *stream, int fd) { + ALOGV("out_dump"); return 0; } static int out_set_parameters(struct audio_stream *stream, const char *kvpairs) { + ALOGV("out_set_parameters"); return 0; } static char * out_get_parameters(const struct audio_stream *stream, const char *keys) { + ALOGV("out_get_parameters"); return strdup(""); } static uint32_t out_get_latency(const struct audio_stream_out *stream) { + ALOGV("out_get_latency"); return 0; } static int out_set_volume(struct audio_stream_out *stream, float left, float right) { + ALOGV("out_set_volume: Left:%f Right:%f", left, right); return 0; } static ssize_t out_write(struct audio_stream_out *stream, const void* buffer, size_t bytes) { + ALOGV("out_write: bytes: %d", bytes); /* XXX: fake timing for audio output */ - usleep(bytes * 1000000 / audio_stream_out_frame_size(stream) / + usleep((int64_t)bytes * 1000000 / audio_stream_out_frame_size(stream) / out_get_sample_rate(&stream->common)); return bytes; } @@ -114,43 +127,53 @@ static ssize_t out_write(struct audio_stream_out *stream, const void* buffer, static int out_get_render_position(const struct audio_stream_out *stream, uint32_t *dsp_frames) { + *dsp_frames = 0; + ALOGV("out_get_render_position: dsp_frames: %d", (int)dsp_frames); return -EINVAL; } static int out_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect) { + ALOGV("out_add_audio_effect: %d", (int)effect); return 0; } static int out_remove_audio_effect(const struct audio_stream *stream, effect_handle_t effect) { + ALOGV("out_remove_audio_effect: %d", (int)effect); return 0; } static int out_get_next_write_timestamp(const struct audio_stream_out *stream, int64_t *timestamp) { + *timestamp = 0; + ALOGV("out_get_next_write_timestamp: %ld", (long int)(*timestamp)); return -EINVAL; } /** audio_stream_in implementation **/ static uint32_t in_get_sample_rate(const struct audio_stream *stream) { + ALOGV("in_get_sample_rate"); return 8000; } static int in_set_sample_rate(struct audio_stream *stream, uint32_t rate) { - return 0; + ALOGV("in_set_sample_rate: %d", rate); + return -ENOSYS; } static size_t in_get_buffer_size(const struct audio_stream *stream) { + ALOGV("in_get_buffer_size: %d", 320); return 320; } static audio_channel_mask_t in_get_channels(const struct audio_stream *stream) { + ALOGV("in_get_channels: %d", AUDIO_CHANNEL_IN_MONO); return AUDIO_CHANNEL_IN_MONO; } @@ -161,7 +184,7 @@ static audio_format_t in_get_format(const struct audio_stream *stream) static int in_set_format(struct audio_stream *stream, audio_format_t format) { - return 0; + return -ENOSYS; } static int in_standby(struct audio_stream *stream) @@ -193,9 +216,11 @@ static int in_set_gain(struct audio_stream_in *stream, float gain) static ssize_t in_read(struct audio_stream_in *stream, void* buffer, size_t bytes) { + ALOGV("in_read: bytes %d", bytes); /* XXX: fake timing for audio input */ - usleep(bytes * 1000000 / audio_stream_in_frame_size(stream) / + usleep((int64_t)bytes * 1000000 / audio_stream_in_frame_size(stream) / in_get_sample_rate(&stream->common)); + memset(buffer, 0, bytes); return bytes; } @@ -222,6 +247,8 @@ static int adev_open_output_stream(struct audio_hw_device *dev, struct audio_stream_out **stream_out, const char *address __unused) { + ALOGV("adev_open_output_stream..."); + struct stub_audio_device *ladev = (struct stub_audio_device *)dev; struct stub_stream_out *out; int ret; @@ -260,68 +287,81 @@ err_open: static void adev_close_output_stream(struct audio_hw_device *dev, struct audio_stream_out *stream) { + ALOGV("adev_close_output_stream..."); free(stream); } static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs) { + ALOGV("adev_set_parameters"); return -ENOSYS; } static char * adev_get_parameters(const struct audio_hw_device *dev, const char *keys) { - return NULL; + ALOGV("adev_get_parameters"); + return strdup(""); } static int adev_init_check(const struct audio_hw_device *dev) { + ALOGV("adev_init_check"); return 0; } static int adev_set_voice_volume(struct audio_hw_device *dev, float volume) { + ALOGV("adev_set_voice_volume: %f", volume); return -ENOSYS; } static int adev_set_master_volume(struct audio_hw_device *dev, float volume) { + ALOGV("adev_set_master_volume: %f", volume); return -ENOSYS; } static int adev_get_master_volume(struct audio_hw_device *dev, float *volume) { + ALOGV("adev_get_master_volume: %f", *volume); return -ENOSYS; } static int adev_set_master_mute(struct audio_hw_device *dev, bool muted) { + ALOGV("adev_set_master_mute: %d", muted); return -ENOSYS; } static int adev_get_master_mute(struct audio_hw_device *dev, bool *muted) { + ALOGV("adev_get_master_mute: %d", *muted); return -ENOSYS; } static int adev_set_mode(struct audio_hw_device *dev, audio_mode_t mode) { + ALOGV("adev_set_mode: %d", mode); return 0; } static int adev_set_mic_mute(struct audio_hw_device *dev, bool state) { + ALOGV("adev_set_mic_mute: %d",state); return -ENOSYS; } static int adev_get_mic_mute(const struct audio_hw_device *dev, bool *state) { + ALOGV("adev_get_mic_mute"); return -ENOSYS; } static size_t adev_get_input_buffer_size(const struct audio_hw_device *dev, const struct audio_config *config) { + ALOGV("adev_get_input_buffer_size: %d", 320); return 320; } @@ -334,6 +374,8 @@ static int adev_open_input_stream(struct audio_hw_device *dev, const char *address __unused, audio_source_t source __unused) { + ALOGV("adev_open_input_stream..."); + struct stub_audio_device *ladev = (struct stub_audio_device *)dev; struct stub_stream_in *in; int ret; @@ -370,16 +412,19 @@ err_open: static void adev_close_input_stream(struct audio_hw_device *dev, struct audio_stream_in *in) { + ALOGV("adev_close_input_stream..."); return; } static int adev_dump(const audio_hw_device_t *device, int fd) { + ALOGV("adev_dump"); return 0; } static int adev_close(hw_device_t *device) { + ALOGV("adev_close"); free(device); return 0; } @@ -387,6 +432,8 @@ static int adev_close(hw_device_t *device) static int adev_open(const hw_module_t* module, const char* name, hw_device_t** device) { + ALOGV("adev_open: %s", name); + struct stub_audio_device *adev; int ret; |