diff options
author | Eric Laurent <elaurent@google.com> | 2012-04-10 16:56:32 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2012-04-17 16:02:48 -0700 |
commit | 55786bcf3ced97dea8fa7ce79df2889d4d06e8a7 (patch) | |
tree | ea7089f133e92da7112cfcb15bbc1bc7a9041ef0 | |
parent | 0c8e630ad66b30058009b9afa682b28b7f55b33a (diff) | |
download | hardware_libhardware-55786bcf3ced97dea8fa7ce79df2889d4d06e8a7.zip hardware_libhardware-55786bcf3ced97dea8fa7ce79df2889d4d06e8a7.tar.gz hardware_libhardware-55786bcf3ced97dea8fa7ce79df2889d4d06e8a7.tar.bz2 |
audio: updated audio HAL device API
Modified open output and input stream functions to add new
parameters needed by audio HAL. Also grouped parameters
in a config structure for clarity.
Change-Id: I60832d8e5b5e4a48f209a6d83f5ca9c044be61f1
-rw-r--r-- | include/hardware/audio.h | 51 | ||||
-rw-r--r-- | modules/audio/audio_hw.c | 23 |
2 files changed, 50 insertions, 24 deletions
diff --git a/include/hardware/audio.h b/include/hardware/audio.h index 878b1b2..ef7d342 100644 --- a/include/hardware/audio.h +++ b/include/hardware/audio.h @@ -41,6 +41,20 @@ __BEGIN_DECLS */ #define AUDIO_HARDWARE_INTERFACE "audio_hw_if" + +/* Use version 0.1 to be compatible with first generation of audio hw module with version_major + * hardcoded to 1. No audio module API change. + */ +#define AUDIO_MODULE_API_VERSION_0_1 HARDWARE_MODULE_API_VERSION(0, 1) +#define AUDIO_MODULE_API_VERSION_CURRENT AUDIO_MODULE_API_VERSION_0_1 + +/* First generation of audio devices had version hardcoded to 0. all devices with versions < 1.0 + * will be considered of first generation API. + */ +#define AUDIO_DEVICE_API_VERSION_0_0 HARDWARE_DEVICE_API_VERSION(0, 0) +#define AUDIO_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0) +#define AUDIO_DEVICE_API_VERSION_CURRENT AUDIO_DEVICE_API_VERSION_1_0 + /** * List of known audio HAL modules. This is the base name of the audio HAL * library composed of the "audio." prefix, one of the base names below and @@ -88,8 +102,18 @@ __BEGIN_DECLS #define AUDIO_PARAMETER_STREAM_INPUT_SOURCE "input_source" // audio_source_t #define AUDIO_PARAMETER_STREAM_SAMPLING_RATE "sampling_rate" // uint32_t + /**************************************/ +/* common audio stream configuration parameters */ +struct audio_config { + uint32_t sample_rate; + audio_channel_mask_t channel_mask; + audio_format_t format; +}; + +typedef struct audio_config audio_config_t; + /* common audio stream parameters and operations */ struct audio_stream { @@ -113,7 +137,7 @@ struct audio_stream { * Return the channel mask - * e.g. AUDIO_CHANNEL_OUT_STEREO or AUDIO_CHANNEL_IN_STEREO */ - uint32_t (*get_channels)(const struct audio_stream *stream); + audio_channel_mask_t (*get_channels)(const struct audio_stream *stream); /** * Return the audio format - e.g. AUDIO_FORMAT_PCM_16_BIT @@ -345,27 +369,28 @@ struct audio_hw_device { * See also get_buffer_size which is for a particular stream. */ size_t (*get_input_buffer_size)(const struct audio_hw_device *dev, - uint32_t sample_rate, audio_format_t format, - int channel_count); + const struct audio_config *config); /** This method creates and opens the audio hardware output stream */ - int (*open_output_stream)(struct audio_hw_device *dev, uint32_t devices, - audio_format_t *format, uint32_t *channels, - uint32_t *sample_rate, - struct audio_stream_out **out); + int (*open_output_stream)(struct audio_hw_device *dev, + audio_io_handle_t handle, + audio_devices_t devices, + audio_output_flags_t flags, + struct audio_config *config, + struct audio_stream_out **stream_out); void (*close_output_stream)(struct audio_hw_device *dev, - struct audio_stream_out* out); + struct audio_stream_out* stream_out); /** This method creates and opens the audio hardware input stream */ - int (*open_input_stream)(struct audio_hw_device *dev, uint32_t devices, - audio_format_t *format, uint32_t *channels, - uint32_t *sample_rate, - audio_in_acoustics_t acoustics, + int (*open_input_stream)(struct audio_hw_device *dev, + audio_io_handle_t handle, + audio_devices_t devices, + struct audio_config *config, struct audio_stream_in **stream_in); void (*close_input_stream)(struct audio_hw_device *dev, - struct audio_stream_in *in); + struct audio_stream_in *stream_in); /** This method dumps the state of the audio hardware */ int (*dump)(const struct audio_hw_device *dev, int fd); diff --git a/modules/audio/audio_hw.c b/modules/audio/audio_hw.c index 4069ace..d860437 100644 --- a/modules/audio/audio_hw.c +++ b/modules/audio/audio_hw.c @@ -214,8 +214,10 @@ static int in_remove_audio_effect(const struct audio_stream *stream, effect_hand } static int adev_open_output_stream(struct audio_hw_device *dev, - uint32_t devices, audio_format_t *format, - uint32_t *channels, uint32_t *sample_rate, + audio_io_handle_t handle, + audio_devices_t devices, + audio_output_flags_t flags, + struct audio_config *config, struct audio_stream_out **stream_out) { struct stub_audio_device *ladev = (struct stub_audio_device *)dev; @@ -307,16 +309,15 @@ static int adev_get_mic_mute(const struct audio_hw_device *dev, bool *state) } static size_t adev_get_input_buffer_size(const struct audio_hw_device *dev, - uint32_t sample_rate, audio_format_t format, - int channel_count) + const struct audio_config *config) { return 320; } -static int adev_open_input_stream(struct audio_hw_device *dev, uint32_t devices, - audio_format_t *format, uint32_t *channels, - uint32_t *sample_rate, - audio_in_acoustics_t acoustics, +static int adev_open_input_stream(struct audio_hw_device *dev, + audio_io_handle_t handle, + audio_devices_t devices, + struct audio_config *config, struct audio_stream_in **stream_in) { struct stub_audio_device *ladev = (struct stub_audio_device *)dev; @@ -406,7 +407,7 @@ static int adev_open(const hw_module_t* module, const char* name, return -ENOMEM; adev->device.common.tag = HARDWARE_DEVICE_TAG; - adev->device.common.version = 0; + adev->device.common.version = AUDIO_DEVICE_API_VERSION_1_0; adev->device.common.module = (struct hw_module_t *) module; adev->device.common.close = adev_close; @@ -439,8 +440,8 @@ static struct hw_module_methods_t hal_module_methods = { struct audio_module HAL_MODULE_INFO_SYM = { .common = { .tag = HARDWARE_MODULE_TAG, - .version_major = 1, - .version_minor = 0, + .module_api_version = AUDIO_MODULE_API_VERSION_0_1, + .hal_api_version = HARDWARE_HAL_API_VERSION, .id = AUDIO_HARDWARE_MODULE_ID, .name = "Default audio HW HAL", .author = "The Android Open Source Project", |