Audio V4: Split system and vendor Audio.h
audio.h and its dependencies (audio-effect.h, sound_trigger.h...)
used to be shared between system and vendor code.
This led to multiple problems:
1) Such sharing contradicts the Treble policy of
strict independence of framework and vendor code.
2) When audio.h was changed, every vendor needed to update
its code in the next release. This meant that audio*.h
headers were mostly changed in backward compatible manner.
Nevertheless, for P the HIDL interface and thus the audio.h
interface are changed in backward incompatible way.
(Some enum are becoming 64 bit long).
3) As the headers were common, some API used only by the framework
needed to be visible to the vendors (mostly enum values).
4) Treble policy is to support at least one previous HAL version
As a result the audio*.h headers are now duplicated,
one set for the framework, and one for the vendor.
Each set will evolve independently. After this split,
the framework-only APIs will be removed from the vendor headers
and vice versa.
The split is implements as such:
+ for system code
- NOT moving the libaudio_system_headers
Eg: system/audio.h and system/audio_effects/effect_equalizer.h
are still in system/media/audio
- the legacy audio HAL API that were in libhardware headers
are now in libaudiohal_legacy_headers
Eg: hardware/audio.h and hardware/audio_effect.h
are now in frameworks/av/media/libaudiohal/legacy/
+ for vendor code
- moving libaudio_system_headers and the legacy audio HAL API
that were in libhardware_headers in
android.hardware.audio.common.legacy@2.0
Note that those headers are now versioned, so migrating to a @4.0
HIDL HAL will mean changing the legacy dependency too.
Eg: system/audio.h, system/audio-effect.h, hardware/audio.h
are now in hardware/interfaces/audio/common/2.0/legacy
- the legacy audio effect HAL API that was in libaudioeffects
is now moved in android.hardware.audio.effect.legacy@2.0
Eg: audio_effects/effect*.h are now in
hardware/interfaces/audio/effect/2.0/legacy
- the legacy sound trigger HAL API that were in libhardware_headers
is now moved in android.hardware.soundtrigger.legacy@2.0
Eg: hardware/sound_trigger.h is now in
hardware/interfaces/audio/effect/2.0/legacy
libaudioutil being used by both system and vendor, had
to be renamed for system to libaudioutil_system.
Vendor libs that now depend on the audio.h of a specific
version and are not extensively referenced in non google code,
append @2.0 to their name.
Note that headers that are not expected to change in the 4.0 HAL are
left in all-versions folder to avoid duplication.
This is an implementation detail as the versioned libraries export
the all-versions headers.
Note that strict vendor-system separation is enforced by the
build-system. The system headers are not available for vendor
libs and vice-versa.
Note that this patch is split between numerous git repository (>10),
all the commits having the same Change-id for searchability.
Note that audio_policy.h is no longer exposed to vendors
as the legacy audio policy HAL API was never officially supported.
As a result the audiopolicy stub implementation has been removed.
Test: compile taimen-userdebug walleye-userdebug
sailfish-userdebug marlin-userdebug
gce_x86_phone-userdebug gce_x86_phone
full-eng aosp_arm aosp_x86-eng
Test: check that the emulator booted and played audio
Test: full QA on sailfish-userdebug and taimen-userdebug
Bug: 38184704
Change-Id: I950f4e0a55613d72e32eba31bd563cb5bafe2d1a
Signed-off-by: Kevin Rocard <krocard@google.com>
diff --git a/audio/README b/audio/README
index 2b81450..f4b8555 100644
--- a/audio/README
+++ b/audio/README
@@ -7,15 +7,18 @@
|-- common <== code common to audio core and effect API
| |-- 2.0
| | |-- default <== code that wraps the legacy API
+| | |-- legacy <== legacy API compatible with 2.0
| | `-- vts <== vts of 2.0 core and effect API common code
| |-- 4.0
| | |-- default
+| | |-- legacy
| | `-- vts
| |-- ... <== The future versions should continue this structure
| | |-- default
| | `-- vts
| `-- all_versions <== code common to all version of both core and effect API
| |-- default
+| | |-- legacy <== legacy API compatible with all versions
| `-- vts <== vts of core and effect API common version independent code
|
|-- core <== code relative to the core API
@@ -35,13 +38,17 @@
`-- effect <== idem for the effect API
|-- 2.0
| |-- default
+ | |-- legacy <== legacy effect API compatible with 2.0
| `-- vts
|-- 4.0
| |-- default
+ | |-- legacy
| `-- vts
|-- ...
| |-- default
+ | |-- default
| `-- vts
`-- all_versions
|-- default
+ |-- legacy
`-- vts
diff --git a/audio/common/2.0/default/Android.bp b/audio/common/2.0/default/Android.bp
index ac66479..123f8b3 100644
--- a/audio/common/2.0/default/Android.bp
+++ b/audio/common/2.0/default/Android.bp
@@ -16,10 +16,7 @@
cc_library_shared {
name: "android.hardware.audio.common@2.0-util",
defaults: ["hidl_defaults"],
- vendor_available: true,
- vndk: {
- enabled: true,
- },
+ vendor: true,
srcs: [
"HidlUtils.cpp",
],
@@ -41,7 +38,7 @@
],
header_libs: [
- "libaudio_system_headers",
+ "android.hardware.audio.common.legacy@2.0",
"libhardware_headers",
],
}
diff --git a/audio/common/2.0/legacy/Android.bp b/audio/common/2.0/legacy/Android.bp
new file mode 100644
index 0000000..2888c96
--- /dev/null
+++ b/audio/common/2.0/legacy/Android.bp
@@ -0,0 +1,15 @@
+cc_library_headers {
+ name: "android.hardware.audio.common.legacy@2.0",
+ vendor: true,
+ header_libs: [
+ "libhardware_headers",
+ "android.hardware.audio.common.legacy@all-versions",
+ ],
+ export_header_lib_headers: [
+ "libhardware_headers",
+ "android.hardware.audio.common.legacy@all-versions",
+ ],
+
+ export_include_dirs: ["include"],
+}
+
diff --git a/audio/common/2.0/legacy/OWNERS b/audio/common/2.0/legacy/OWNERS
new file mode 100644
index 0000000..6fdc97c
--- /dev/null
+++ b/audio/common/2.0/legacy/OWNERS
@@ -0,0 +1,3 @@
+elaurent@google.com
+krocard@google.com
+mnaganov@google.com
diff --git a/audio/common/2.0/legacy/include/hardware/audio.h b/audio/common/2.0/legacy/include/hardware/audio.h
new file mode 100644
index 0000000..1ad3e0e
--- /dev/null
+++ b/audio/common/2.0/legacy/include/hardware/audio.h
@@ -0,0 +1,709 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_AUDIO_HAL_INTERFACE_H
+#define ANDROID_AUDIO_HAL_INTERFACE_H
+
+#include <stdint.h>
+#include <strings.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <time.h>
+
+#include <cutils/bitops.h>
+
+#include <hardware/audio_effect.h>
+#include <hardware/hardware.h>
+#include <system/audio.h>
+
+__BEGIN_DECLS
+
+/**
+ * The id of this module
+ */
+#define AUDIO_HARDWARE_MODULE_ID "audio"
+
+/**
+ * Name of the audio devices to open
+ */
+#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_2_0 HARDWARE_DEVICE_API_VERSION(2, 0)
+#define AUDIO_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0)
+#define AUDIO_DEVICE_API_VERSION_CURRENT AUDIO_DEVICE_API_VERSION_3_0
+/* Minimal audio HAL version supported by the audio framework */
+#define AUDIO_DEVICE_API_VERSION_MIN AUDIO_DEVICE_API_VERSION_2_0
+
+/**************************************/
+
+/**
+ * standard audio parameters that the HAL may need to handle
+ */
+
+/**
+ * audio device parameters
+ */
+
+/* TTY mode selection */
+#define AUDIO_PARAMETER_KEY_TTY_MODE "tty_mode"
+#define AUDIO_PARAMETER_VALUE_TTY_OFF "tty_off"
+#define AUDIO_PARAMETER_VALUE_TTY_VCO "tty_vco"
+#define AUDIO_PARAMETER_VALUE_TTY_HCO "tty_hco"
+#define AUDIO_PARAMETER_VALUE_TTY_FULL "tty_full"
+
+/* Hearing Aid Compatibility - Telecoil (HAC-T) mode on/off */
+#define AUDIO_PARAMETER_KEY_HAC "HACSetting"
+#define AUDIO_PARAMETER_VALUE_HAC_ON "ON"
+#define AUDIO_PARAMETER_VALUE_HAC_OFF "OFF"
+
+/* A2DP sink address set by framework */
+#define AUDIO_PARAMETER_A2DP_SINK_ADDRESS "a2dp_sink_address"
+
+/* A2DP source address set by framework */
+#define AUDIO_PARAMETER_A2DP_SOURCE_ADDRESS "a2dp_source_address"
+
+/* Bluetooth SCO wideband */
+#define AUDIO_PARAMETER_KEY_BT_SCO_WB "bt_wbs"
+
+/**
+ * audio stream parameters
+ */
+
+/* Enable AANC */
+#define AUDIO_PARAMETER_KEY_AANC "aanc_enabled"
+
+/**************************************/
+
+/* common audio stream parameters and operations */
+struct audio_stream {
+ /**
+ * Return the sampling rate in Hz - eg. 44100.
+ */
+ uint32_t (*get_sample_rate)(const struct audio_stream* stream);
+
+ /* currently unused - use set_parameters with key
+ * AUDIO_PARAMETER_STREAM_SAMPLING_RATE
+ */
+ int (*set_sample_rate)(struct audio_stream* stream, uint32_t rate);
+
+ /**
+ * Return size of input/output buffer in bytes for this stream - eg. 4800.
+ * It should be a multiple of the frame size. See also get_input_buffer_size.
+ */
+ size_t (*get_buffer_size)(const struct audio_stream* stream);
+
+ /**
+ * Return the channel mask -
+ * e.g. AUDIO_CHANNEL_OUT_STEREO or AUDIO_CHANNEL_IN_STEREO
+ */
+ audio_channel_mask_t (*get_channels)(const struct audio_stream* stream);
+
+ /**
+ * Return the audio format - e.g. AUDIO_FORMAT_PCM_16_BIT
+ */
+ audio_format_t (*get_format)(const struct audio_stream* stream);
+
+ /* currently unused - use set_parameters with key
+ * AUDIO_PARAMETER_STREAM_FORMAT
+ */
+ int (*set_format)(struct audio_stream* stream, audio_format_t format);
+
+ /**
+ * Put the audio hardware input/output into standby mode.
+ * Driver should exit from standby mode at the next I/O operation.
+ * Returns 0 on success and <0 on failure.
+ */
+ int (*standby)(struct audio_stream* stream);
+
+ /** dump the state of the audio input/output device */
+ int (*dump)(const struct audio_stream* stream, int fd);
+
+ /** Return the set of device(s) which this stream is connected to */
+ audio_devices_t (*get_device)(const struct audio_stream* stream);
+
+ /**
+ * Currently unused - set_device() corresponds to set_parameters() with key
+ * AUDIO_PARAMETER_STREAM_ROUTING for both input and output.
+ * AUDIO_PARAMETER_STREAM_INPUT_SOURCE is an additional information used by
+ * input streams only.
+ */
+ int (*set_device)(struct audio_stream* stream, audio_devices_t device);
+
+ /**
+ * set/get audio stream parameters. The function accepts a list of
+ * parameter key value pairs in the form: key1=value1;key2=value2;...
+ *
+ * Some keys are reserved for standard parameters (See AudioParameter class)
+ *
+ * If the implementation does not accept a parameter change while
+ * the output is active but the parameter is acceptable otherwise, it must
+ * return -ENOSYS.
+ *
+ * The audio flinger will put the stream in standby and then change the
+ * parameter value.
+ */
+ int (*set_parameters)(struct audio_stream* stream, const char* kv_pairs);
+
+ /*
+ * Returns a pointer to a heap allocated string. The caller is responsible
+ * for freeing the memory for it using free().
+ */
+ char* (*get_parameters)(const struct audio_stream* stream, const char* keys);
+ int (*add_audio_effect)(const struct audio_stream* stream, effect_handle_t effect);
+ int (*remove_audio_effect)(const struct audio_stream* stream, effect_handle_t effect);
+};
+typedef struct audio_stream audio_stream_t;
+
+/* type of asynchronous write callback events. Mutually exclusive */
+typedef enum {
+ STREAM_CBK_EVENT_WRITE_READY, /* non blocking write completed */
+ STREAM_CBK_EVENT_DRAIN_READY, /* drain completed */
+ STREAM_CBK_EVENT_ERROR, /* stream hit some error, let AF take action */
+} stream_callback_event_t;
+
+typedef int (*stream_callback_t)(stream_callback_event_t event, void* param, void* cookie);
+
+/* type of drain requested to audio_stream_out->drain(). Mutually exclusive */
+typedef enum {
+ AUDIO_DRAIN_ALL, /* drain() returns when all data has been played */
+ AUDIO_DRAIN_EARLY_NOTIFY /* drain() returns a short time before all data
+ from the current track has been played to
+ give time for gapless track switch */
+} audio_drain_type_t;
+
+/**
+ * audio_stream_out is the abstraction interface for the audio output hardware.
+ *
+ * It provides information about various properties of the audio output
+ * hardware driver.
+ */
+
+struct audio_stream_out {
+ /**
+ * Common methods of the audio stream out. This *must* be the first member of audio_stream_out
+ * as users of this structure will cast a audio_stream to audio_stream_out pointer in contexts
+ * where it's known the audio_stream references an audio_stream_out.
+ */
+ struct audio_stream common;
+
+ /**
+ * Return the audio hardware driver estimated latency in milliseconds.
+ */
+ uint32_t (*get_latency)(const struct audio_stream_out* stream);
+
+ /**
+ * Use this method in situations where audio mixing is done in the
+ * hardware. This method serves as a direct interface with hardware,
+ * allowing you to directly set the volume as apposed to via the framework.
+ * This method might produce multiple PCM outputs or hardware accelerated
+ * codecs, such as MP3 or AAC.
+ */
+ int (*set_volume)(struct audio_stream_out* stream, float left, float right);
+
+ /**
+ * Write audio buffer to driver. Returns number of bytes written, or a
+ * negative status_t. If at least one frame was written successfully prior to the error,
+ * it is suggested that the driver return that successful (short) byte count
+ * and then return an error in the subsequent call.
+ *
+ * If set_callback() has previously been called to enable non-blocking mode
+ * the write() is not allowed to block. It must write only the number of
+ * bytes that currently fit in the driver/hardware buffer and then return
+ * this byte count. If this is less than the requested write size the
+ * callback function must be called when more space is available in the
+ * driver/hardware buffer.
+ */
+ ssize_t (*write)(struct audio_stream_out* stream, const void* buffer, size_t bytes);
+
+ /* return the number of audio frames written by the audio dsp to DAC since
+ * the output has exited standby
+ */
+ int (*get_render_position)(const struct audio_stream_out* stream, uint32_t* dsp_frames);
+
+ /**
+ * get the local time at which the next write to the audio driver will be presented.
+ * The units are microseconds, where the epoch is decided by the local audio HAL.
+ */
+ int (*get_next_write_timestamp)(const struct audio_stream_out* stream, int64_t* timestamp);
+
+ /**
+ * set the callback function for notifying completion of non-blocking
+ * write and drain.
+ * Calling this function implies that all future write() and drain()
+ * must be non-blocking and use the callback to signal completion.
+ */
+ int (*set_callback)(struct audio_stream_out* stream, stream_callback_t callback, void* cookie);
+
+ /**
+ * Notifies to the audio driver to stop playback however the queued buffers are
+ * retained by the hardware. Useful for implementing pause/resume. Empty implementation
+ * if not supported however should be implemented for hardware with non-trivial
+ * latency. In the pause state audio hardware could still be using power. User may
+ * consider calling suspend after a timeout.
+ *
+ * Implementation of this function is mandatory for offloaded playback.
+ */
+ int (*pause)(struct audio_stream_out* stream);
+
+ /**
+ * Notifies to the audio driver to resume playback following a pause.
+ * Returns error if called without matching pause.
+ *
+ * Implementation of this function is mandatory for offloaded playback.
+ */
+ int (*resume)(struct audio_stream_out* stream);
+
+ /**
+ * Requests notification when data buffered by the driver/hardware has
+ * been played. If set_callback() has previously been called to enable
+ * non-blocking mode, the drain() must not block, instead it should return
+ * quickly and completion of the drain is notified through the callback.
+ * If set_callback() has not been called, the drain() must block until
+ * completion.
+ * If type==AUDIO_DRAIN_ALL, the drain completes when all previously written
+ * data has been played.
+ * If type==AUDIO_DRAIN_EARLY_NOTIFY, the drain completes shortly before all
+ * data for the current track has played to allow time for the framework
+ * to perform a gapless track switch.
+ *
+ * Drain must return immediately on stop() and flush() call
+ *
+ * Implementation of this function is mandatory for offloaded playback.
+ */
+ int (*drain)(struct audio_stream_out* stream, audio_drain_type_t type);
+
+ /**
+ * Notifies to the audio driver to flush the queued data. Stream must already
+ * be paused before calling flush().
+ *
+ * Implementation of this function is mandatory for offloaded playback.
+ */
+ int (*flush)(struct audio_stream_out* stream);
+
+ /**
+ * Return a recent count of the number of audio frames presented to an external observer.
+ * This excludes frames which have been written but are still in the pipeline.
+ * The count is not reset to zero when output enters standby.
+ * Also returns the value of CLOCK_MONOTONIC as of this presentation count.
+ * The returned count is expected to be 'recent',
+ * but does not need to be the most recent possible value.
+ * However, the associated time should correspond to whatever count is returned.
+ * Example: assume that N+M frames have been presented, where M is a 'small' number.
+ * Then it is permissible to return N instead of N+M,
+ * and the timestamp should correspond to N rather than N+M.
+ * The terms 'recent' and 'small' are not defined.
+ * They reflect the quality of the implementation.
+ *
+ * 3.0 and higher only.
+ */
+ int (*get_presentation_position)(const struct audio_stream_out* stream, uint64_t* frames,
+ struct timespec* timestamp);
+
+ /**
+ * Called by the framework to start a stream operating in mmap mode.
+ * create_mmap_buffer must be called before calling start()
+ *
+ * \note Function only implemented by streams operating in mmap mode.
+ *
+ * \param[in] stream the stream object.
+ * \return 0 in case of success.
+ * -ENOSYS if called out of sequence or on non mmap stream
+ */
+ int (*start)(const struct audio_stream_out* stream);
+
+ /**
+ * Called by the framework to stop a stream operating in mmap mode.
+ * Must be called after start()
+ *
+ * \note Function only implemented by streams operating in mmap mode.
+ *
+ * \param[in] stream the stream object.
+ * \return 0 in case of success.
+ * -ENOSYS if called out of sequence or on non mmap stream
+ */
+ int (*stop)(const struct audio_stream_out* stream);
+
+ /**
+ * Called by the framework to retrieve information on the mmap buffer used for audio
+ * samples transfer.
+ *
+ * \note Function only implemented by streams operating in mmap mode.
+ *
+ * \param[in] stream the stream object.
+ * \param[in] min_size_frames minimum buffer size requested. The actual buffer
+ * size returned in struct audio_mmap_buffer_info can be larger.
+ * \param[out] info address at which the mmap buffer information should be returned.
+ *
+ * \return 0 if the buffer was allocated.
+ * -ENODEV in case of initialization error
+ * -EINVAL if the requested buffer size is too large
+ * -ENOSYS if called out of sequence (e.g. buffer already allocated)
+ */
+ int (*create_mmap_buffer)(const struct audio_stream_out* stream, int32_t min_size_frames,
+ struct audio_mmap_buffer_info* info);
+
+ /**
+ * Called by the framework to read current read/write position in the mmap buffer
+ * with associated time stamp.
+ *
+ * \note Function only implemented by streams operating in mmap mode.
+ *
+ * \param[in] stream the stream object.
+ * \param[out] position address at which the mmap read/write position should be returned.
+ *
+ * \return 0 if the position is successfully returned.
+ * -ENODATA if the position cannot be retrieved
+ * -ENOSYS if called before create_mmap_buffer()
+ */
+ int (*get_mmap_position)(const struct audio_stream_out* stream,
+ struct audio_mmap_position* position);
+};
+typedef struct audio_stream_out audio_stream_out_t;
+
+struct audio_stream_in {
+ /**
+ * Common methods of the audio stream in. This *must* be the first member of audio_stream_in
+ * as users of this structure will cast a audio_stream to audio_stream_in pointer in contexts
+ * where it's known the audio_stream references an audio_stream_in.
+ */
+ struct audio_stream common;
+
+ /** set the input gain for the audio driver. This method is for
+ * for future use */
+ int (*set_gain)(struct audio_stream_in* stream, float gain);
+
+ /** Read audio buffer in from audio driver. Returns number of bytes read, or a
+ * negative status_t. If at least one frame was read prior to the error,
+ * read should return that byte count and then return an error in the subsequent call.
+ */
+ ssize_t (*read)(struct audio_stream_in* stream, void* buffer, size_t bytes);
+
+ /**
+ * Return the amount of input frames lost in the audio driver since the
+ * last call of this function.
+ * Audio driver is expected to reset the value to 0 and restart counting
+ * upon returning the current value by this function call.
+ * Such loss typically occurs when the user space process is blocked
+ * longer than the capacity of audio driver buffers.
+ *
+ * Unit: the number of input audio frames
+ */
+ uint32_t (*get_input_frames_lost)(struct audio_stream_in* stream);
+
+ /**
+ * Return a recent count of the number of audio frames received and
+ * the clock time associated with that frame count.
+ *
+ * frames is the total frame count received. This should be as early in
+ * the capture pipeline as possible. In general,
+ * frames should be non-negative and should not go "backwards".
+ *
+ * time is the clock MONOTONIC time when frames was measured. In general,
+ * time should be a positive quantity and should not go "backwards".
+ *
+ * The status returned is 0 on success, -ENOSYS if the device is not
+ * ready/available, or -EINVAL if the arguments are null or otherwise invalid.
+ */
+ int (*get_capture_position)(const struct audio_stream_in* stream, int64_t* frames,
+ int64_t* time);
+
+ /**
+ * Called by the framework to start a stream operating in mmap mode.
+ * create_mmap_buffer must be called before calling start()
+ *
+ * \note Function only implemented by streams operating in mmap mode.
+ *
+ * \param[in] stream the stream object.
+ * \return 0 in case off success.
+ * -ENOSYS if called out of sequence or on non mmap stream
+ */
+ int (*start)(const struct audio_stream_in* stream);
+
+ /**
+ * Called by the framework to stop a stream operating in mmap mode.
+ *
+ * \note Function only implemented by streams operating in mmap mode.
+ *
+ * \param[in] stream the stream object.
+ * \return 0 in case of success.
+ * -ENOSYS if called out of sequence or on non mmap stream
+ */
+ int (*stop)(const struct audio_stream_in* stream);
+
+ /**
+ * Called by the framework to retrieve information on the mmap buffer used for audio
+ * samples transfer.
+ *
+ * \note Function only implemented by streams operating in mmap mode.
+ *
+ * \param[in] stream the stream object.
+ * \param[in] min_size_frames minimum buffer size requested. The actual buffer
+ * size returned in struct audio_mmap_buffer_info can be larger.
+ * \param[out] info address at which the mmap buffer information should be returned.
+ *
+ * \return 0 if the buffer was allocated.
+ * -ENODEV in case of initialization error
+ * -EINVAL if the requested buffer size is too large
+ * -ENOSYS if called out of sequence (e.g. buffer already allocated)
+ */
+ int (*create_mmap_buffer)(const struct audio_stream_in* stream, int32_t min_size_frames,
+ struct audio_mmap_buffer_info* info);
+
+ /**
+ * Called by the framework to read current read/write position in the mmap buffer
+ * with associated time stamp.
+ *
+ * \note Function only implemented by streams operating in mmap mode.
+ *
+ * \param[in] stream the stream object.
+ * \param[out] position address at which the mmap read/write position should be returned.
+ *
+ * \return 0 if the position is successfully returned.
+ * -ENODATA if the position cannot be retreived
+ * -ENOSYS if called before mmap_read_position()
+ */
+ int (*get_mmap_position)(const struct audio_stream_in* stream,
+ struct audio_mmap_position* position);
+};
+typedef struct audio_stream_in audio_stream_in_t;
+
+/**
+ * return the frame size (number of bytes per sample).
+ *
+ * Deprecated: use audio_stream_out_frame_size() or audio_stream_in_frame_size() instead.
+ */
+__attribute__((__deprecated__)) static inline size_t audio_stream_frame_size(
+ const struct audio_stream* s) {
+ size_t chan_samp_sz;
+ audio_format_t format = s->get_format(s);
+
+ if (audio_has_proportional_frames(format)) {
+ chan_samp_sz = audio_bytes_per_sample(format);
+ return popcount(s->get_channels(s)) * chan_samp_sz;
+ }
+
+ return sizeof(int8_t);
+}
+
+/**
+ * return the frame size (number of bytes per sample) of an output stream.
+ */
+static inline size_t audio_stream_out_frame_size(const struct audio_stream_out* s) {
+ size_t chan_samp_sz;
+ audio_format_t format = s->common.get_format(&s->common);
+
+ if (audio_has_proportional_frames(format)) {
+ chan_samp_sz = audio_bytes_per_sample(format);
+ return audio_channel_count_from_out_mask(s->common.get_channels(&s->common)) * chan_samp_sz;
+ }
+
+ return sizeof(int8_t);
+}
+
+/**
+ * return the frame size (number of bytes per sample) of an input stream.
+ */
+static inline size_t audio_stream_in_frame_size(const struct audio_stream_in* s) {
+ size_t chan_samp_sz;
+ audio_format_t format = s->common.get_format(&s->common);
+
+ if (audio_has_proportional_frames(format)) {
+ chan_samp_sz = audio_bytes_per_sample(format);
+ return audio_channel_count_from_in_mask(s->common.get_channels(&s->common)) * chan_samp_sz;
+ }
+
+ return sizeof(int8_t);
+}
+
+/**********************************************************************/
+
+/**
+ * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
+ * and the fields of this data structure must begin with hw_module_t
+ * followed by module specific information.
+ */
+struct audio_module {
+ struct hw_module_t common;
+};
+
+struct audio_hw_device {
+ /**
+ * Common methods of the audio device. This *must* be the first member of audio_hw_device
+ * as users of this structure will cast a hw_device_t to audio_hw_device pointer in contexts
+ * where it's known the hw_device_t references an audio_hw_device.
+ */
+ struct hw_device_t common;
+
+ /**
+ * used by audio flinger to enumerate what devices are supported by
+ * each audio_hw_device implementation.
+ *
+ * Return value is a bitmask of 1 or more values of audio_devices_t
+ *
+ * NOTE: audio HAL implementations starting with
+ * AUDIO_DEVICE_API_VERSION_2_0 do not implement this function.
+ * All supported devices should be listed in audio_policy.conf
+ * file and the audio policy manager must choose the appropriate
+ * audio module based on information in this file.
+ */
+ uint32_t (*get_supported_devices)(const struct audio_hw_device* dev);
+
+ /**
+ * check to see if the audio hardware interface has been initialized.
+ * returns 0 on success, -ENODEV on failure.
+ */
+ int (*init_check)(const struct audio_hw_device* dev);
+
+ /** set the audio volume of a voice call. Range is between 0.0 and 1.0 */
+ int (*set_voice_volume)(struct audio_hw_device* dev, float volume);
+
+ /**
+ * set the audio volume for all audio activities other than voice call.
+ * Range between 0.0 and 1.0. If any value other than 0 is returned,
+ * the software mixer will emulate this capability.
+ */
+ int (*set_master_volume)(struct audio_hw_device* dev, float volume);
+
+ /**
+ * Get the current master volume value for the HAL, if the HAL supports
+ * master volume control. AudioFlinger will query this value from the
+ * primary audio HAL when the service starts and use the value for setting
+ * the initial master volume across all HALs. HALs which do not support
+ * this method may leave it set to NULL.
+ */
+ int (*get_master_volume)(struct audio_hw_device* dev, float* volume);
+
+ /**
+ * set_mode is called when the audio mode changes. AUDIO_MODE_NORMAL mode
+ * is for standard audio playback, AUDIO_MODE_RINGTONE when a ringtone is
+ * playing, and AUDIO_MODE_IN_CALL when a call is in progress.
+ */
+ int (*set_mode)(struct audio_hw_device* dev, audio_mode_t mode);
+
+ /* mic mute */
+ int (*set_mic_mute)(struct audio_hw_device* dev, bool state);
+ int (*get_mic_mute)(const struct audio_hw_device* dev, bool* state);
+
+ /* set/get global audio parameters */
+ int (*set_parameters)(struct audio_hw_device* dev, const char* kv_pairs);
+
+ /*
+ * Returns a pointer to a heap allocated string. The caller is responsible
+ * for freeing the memory for it using free().
+ */
+ char* (*get_parameters)(const struct audio_hw_device* dev, const char* keys);
+
+ /* Returns audio input buffer size according to parameters passed or
+ * 0 if one of the parameters is not supported.
+ * See also get_buffer_size which is for a particular stream.
+ */
+ size_t (*get_input_buffer_size)(const struct audio_hw_device* dev,
+ const struct audio_config* config);
+
+ /** This method creates and opens the audio hardware output stream.
+ * The "address" parameter qualifies the "devices" audio device type if needed.
+ * The format format depends on the device type:
+ * - Bluetooth devices use the MAC address of the device in the form "00:11:22:AA:BB:CC"
+ * - USB devices use the ALSA card and device numbers in the form "card=X;device=Y"
+ * - Other devices may use a number or any other string.
+ */
+
+ 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,
+ const char* address);
+
+ void (*close_output_stream)(struct audio_hw_device* dev, 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, audio_io_handle_t handle,
+ audio_devices_t devices, struct audio_config* config,
+ struct audio_stream_in** stream_in, audio_input_flags_t flags,
+ const char* address, audio_source_t source);
+
+ void (*close_input_stream)(struct audio_hw_device* dev, 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);
+
+ /**
+ * set the audio mute status for all audio activities. If any value other
+ * than 0 is returned, the software mixer will emulate this capability.
+ */
+ int (*set_master_mute)(struct audio_hw_device* dev, bool mute);
+
+ /**
+ * Get the current master mute status for the HAL, if the HAL supports
+ * master mute control. AudioFlinger will query this value from the primary
+ * audio HAL when the service starts and use the value for setting the
+ * initial master mute across all HALs. HALs which do not support this
+ * method may leave it set to NULL.
+ */
+ int (*get_master_mute)(struct audio_hw_device* dev, bool* mute);
+
+ /**
+ * Routing control
+ */
+
+ /* Creates an audio patch between several source and sink ports.
+ * The handle is allocated by the HAL and should be unique for this
+ * audio HAL module. */
+ int (*create_audio_patch)(struct audio_hw_device* dev, unsigned int num_sources,
+ const struct audio_port_config* sources, unsigned int num_sinks,
+ const struct audio_port_config* sinks, audio_patch_handle_t* handle);
+
+ /* Release an audio patch */
+ int (*release_audio_patch)(struct audio_hw_device* dev, audio_patch_handle_t handle);
+
+ /* Fills the list of supported attributes for a given audio port.
+ * As input, "port" contains the information (type, role, address etc...)
+ * needed by the HAL to identify the port.
+ * As output, "port" contains possible attributes (sampling rates, formats,
+ * channel masks, gain controllers...) for this port.
+ */
+ int (*get_audio_port)(struct audio_hw_device* dev, struct audio_port* port);
+
+ /* Set audio port configuration */
+ int (*set_audio_port_config)(struct audio_hw_device* dev,
+ const struct audio_port_config* config);
+};
+typedef struct audio_hw_device audio_hw_device_t;
+
+/** convenience API for opening and closing a supported device */
+
+static inline int audio_hw_device_open(const struct hw_module_t* module,
+ struct audio_hw_device** device) {
+ return module->methods->open(module, AUDIO_HARDWARE_INTERFACE, TO_HW_DEVICE_T_OPEN(device));
+}
+
+static inline int audio_hw_device_close(struct audio_hw_device* device) {
+ return device->common.close(&device->common);
+}
+
+__END_DECLS
+
+#endif // ANDROID_AUDIO_INTERFACE_H
diff --git a/audio/common/2.0/legacy/include/system/audio-base.h b/audio/common/2.0/legacy/include/system/audio-base.h
new file mode 100644
index 0000000..53e524b
--- /dev/null
+++ b/audio/common/2.0/legacy/include/system/audio-base.h
@@ -0,0 +1,434 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+// Source: android.hardware.audio.common@2.0
+// Root: android.hardware:hardware/interfaces
+
+#ifndef HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_COMMON_V2_0_EXPORTED_CONSTANTS_H_
+#define HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_COMMON_V2_0_EXPORTED_CONSTANTS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ AUDIO_IO_HANDLE_NONE = 0,
+ AUDIO_MODULE_HANDLE_NONE = 0,
+ AUDIO_PORT_HANDLE_NONE = 0,
+ AUDIO_PATCH_HANDLE_NONE = 0,
+};
+
+typedef enum {
+ AUDIO_STREAM_DEFAULT = -1, // (-1)
+ AUDIO_STREAM_MIN = 0,
+ AUDIO_STREAM_VOICE_CALL = 0,
+ AUDIO_STREAM_SYSTEM = 1,
+ AUDIO_STREAM_RING = 2,
+ AUDIO_STREAM_MUSIC = 3,
+ AUDIO_STREAM_ALARM = 4,
+ AUDIO_STREAM_NOTIFICATION = 5,
+ AUDIO_STREAM_BLUETOOTH_SCO = 6,
+ AUDIO_STREAM_ENFORCED_AUDIBLE = 7,
+ AUDIO_STREAM_DTMF = 8,
+ AUDIO_STREAM_TTS = 9,
+ AUDIO_STREAM_ACCESSIBILITY = 10,
+ AUDIO_STREAM_REROUTING = 11,
+ AUDIO_STREAM_PATCH = 12,
+ AUDIO_STREAM_PUBLIC_CNT = 11, // (ACCESSIBILITY + 1)
+ AUDIO_STREAM_FOR_POLICY_CNT = 12, // PATCH
+ AUDIO_STREAM_CNT = 13, // (PATCH + 1)
+} audio_stream_type_t;
+
+typedef enum {
+ AUDIO_SOURCE_DEFAULT = 0,
+ AUDIO_SOURCE_MIC = 1,
+ AUDIO_SOURCE_VOICE_UPLINK = 2,
+ AUDIO_SOURCE_VOICE_DOWNLINK = 3,
+ AUDIO_SOURCE_VOICE_CALL = 4,
+ AUDIO_SOURCE_CAMCORDER = 5,
+ AUDIO_SOURCE_VOICE_RECOGNITION = 6,
+ AUDIO_SOURCE_VOICE_COMMUNICATION = 7,
+ AUDIO_SOURCE_REMOTE_SUBMIX = 8,
+ AUDIO_SOURCE_UNPROCESSED = 9,
+ AUDIO_SOURCE_CNT = 10,
+ AUDIO_SOURCE_MAX = 9, // (CNT - 1)
+ AUDIO_SOURCE_FM_TUNER = 1998,
+ AUDIO_SOURCE_HOTWORD = 1999,
+} audio_source_t;
+
+typedef enum {
+ AUDIO_SESSION_OUTPUT_STAGE = -1, // (-1)
+ AUDIO_SESSION_OUTPUT_MIX = 0,
+ AUDIO_SESSION_ALLOCATE = 0,
+ AUDIO_SESSION_NONE = 0,
+} audio_session_t;
+
+typedef enum {
+ AUDIO_FORMAT_INVALID = 4294967295u, // 0xFFFFFFFFUL
+ AUDIO_FORMAT_DEFAULT = 0u, // 0
+ AUDIO_FORMAT_PCM = 0u, // 0x00000000UL
+ AUDIO_FORMAT_MP3 = 16777216u, // 0x01000000UL
+ AUDIO_FORMAT_AMR_NB = 33554432u, // 0x02000000UL
+ AUDIO_FORMAT_AMR_WB = 50331648u, // 0x03000000UL
+ AUDIO_FORMAT_AAC = 67108864u, // 0x04000000UL
+ AUDIO_FORMAT_HE_AAC_V1 = 83886080u, // 0x05000000UL
+ AUDIO_FORMAT_HE_AAC_V2 = 100663296u, // 0x06000000UL
+ AUDIO_FORMAT_VORBIS = 117440512u, // 0x07000000UL
+ AUDIO_FORMAT_OPUS = 134217728u, // 0x08000000UL
+ AUDIO_FORMAT_AC3 = 150994944u, // 0x09000000UL
+ AUDIO_FORMAT_E_AC3 = 167772160u, // 0x0A000000UL
+ AUDIO_FORMAT_DTS = 184549376u, // 0x0B000000UL
+ AUDIO_FORMAT_DTS_HD = 201326592u, // 0x0C000000UL
+ AUDIO_FORMAT_IEC61937 = 218103808u, // 0x0D000000UL
+ AUDIO_FORMAT_DOLBY_TRUEHD = 234881024u, // 0x0E000000UL
+ AUDIO_FORMAT_EVRC = 268435456u, // 0x10000000UL
+ AUDIO_FORMAT_EVRCB = 285212672u, // 0x11000000UL
+ AUDIO_FORMAT_EVRCWB = 301989888u, // 0x12000000UL
+ AUDIO_FORMAT_EVRCNW = 318767104u, // 0x13000000UL
+ AUDIO_FORMAT_AAC_ADIF = 335544320u, // 0x14000000UL
+ AUDIO_FORMAT_WMA = 352321536u, // 0x15000000UL
+ AUDIO_FORMAT_WMA_PRO = 369098752u, // 0x16000000UL
+ AUDIO_FORMAT_AMR_WB_PLUS = 385875968u, // 0x17000000UL
+ AUDIO_FORMAT_MP2 = 402653184u, // 0x18000000UL
+ AUDIO_FORMAT_QCELP = 419430400u, // 0x19000000UL
+ AUDIO_FORMAT_DSD = 436207616u, // 0x1A000000UL
+ AUDIO_FORMAT_FLAC = 452984832u, // 0x1B000000UL
+ AUDIO_FORMAT_ALAC = 469762048u, // 0x1C000000UL
+ AUDIO_FORMAT_APE = 486539264u, // 0x1D000000UL
+ AUDIO_FORMAT_AAC_ADTS = 503316480u, // 0x1E000000UL
+ AUDIO_FORMAT_SBC = 520093696u, // 0x1F000000UL
+ AUDIO_FORMAT_APTX = 536870912u, // 0x20000000UL
+ AUDIO_FORMAT_APTX_HD = 553648128u, // 0x21000000UL
+ AUDIO_FORMAT_AC4 = 570425344u, // 0x22000000UL
+ AUDIO_FORMAT_LDAC = 587202560u, // 0x23000000UL
+ AUDIO_FORMAT_MAIN_MASK = 4278190080u, // 0xFF000000UL
+ AUDIO_FORMAT_SUB_MASK = 16777215u, // 0x00FFFFFFUL
+ AUDIO_FORMAT_PCM_SUB_16_BIT = 1u, // 0x1
+ AUDIO_FORMAT_PCM_SUB_8_BIT = 2u, // 0x2
+ AUDIO_FORMAT_PCM_SUB_32_BIT = 3u, // 0x3
+ AUDIO_FORMAT_PCM_SUB_8_24_BIT = 4u, // 0x4
+ AUDIO_FORMAT_PCM_SUB_FLOAT = 5u, // 0x5
+ AUDIO_FORMAT_PCM_SUB_24_BIT_PACKED = 6u, // 0x6
+ AUDIO_FORMAT_MP3_SUB_NONE = 0u, // 0x0
+ AUDIO_FORMAT_AMR_SUB_NONE = 0u, // 0x0
+ AUDIO_FORMAT_AAC_SUB_MAIN = 1u, // 0x1
+ AUDIO_FORMAT_AAC_SUB_LC = 2u, // 0x2
+ AUDIO_FORMAT_AAC_SUB_SSR = 4u, // 0x4
+ AUDIO_FORMAT_AAC_SUB_LTP = 8u, // 0x8
+ AUDIO_FORMAT_AAC_SUB_HE_V1 = 16u, // 0x10
+ AUDIO_FORMAT_AAC_SUB_SCALABLE = 32u, // 0x20
+ AUDIO_FORMAT_AAC_SUB_ERLC = 64u, // 0x40
+ AUDIO_FORMAT_AAC_SUB_LD = 128u, // 0x80
+ AUDIO_FORMAT_AAC_SUB_HE_V2 = 256u, // 0x100
+ AUDIO_FORMAT_AAC_SUB_ELD = 512u, // 0x200
+ AUDIO_FORMAT_VORBIS_SUB_NONE = 0u, // 0x0
+ AUDIO_FORMAT_PCM_16_BIT = 1u, // (PCM | PCM_SUB_16_BIT)
+ AUDIO_FORMAT_PCM_8_BIT = 2u, // (PCM | PCM_SUB_8_BIT)
+ AUDIO_FORMAT_PCM_32_BIT = 3u, // (PCM | PCM_SUB_32_BIT)
+ AUDIO_FORMAT_PCM_8_24_BIT = 4u, // (PCM | PCM_SUB_8_24_BIT)
+ AUDIO_FORMAT_PCM_FLOAT = 5u, // (PCM | PCM_SUB_FLOAT)
+ AUDIO_FORMAT_PCM_24_BIT_PACKED = 6u, // (PCM | PCM_SUB_24_BIT_PACKED)
+ AUDIO_FORMAT_AAC_MAIN = 67108865u, // (AAC | AAC_SUB_MAIN)
+ AUDIO_FORMAT_AAC_LC = 67108866u, // (AAC | AAC_SUB_LC)
+ AUDIO_FORMAT_AAC_SSR = 67108868u, // (AAC | AAC_SUB_SSR)
+ AUDIO_FORMAT_AAC_LTP = 67108872u, // (AAC | AAC_SUB_LTP)
+ AUDIO_FORMAT_AAC_HE_V1 = 67108880u, // (AAC | AAC_SUB_HE_V1)
+ AUDIO_FORMAT_AAC_SCALABLE = 67108896u, // (AAC | AAC_SUB_SCALABLE)
+ AUDIO_FORMAT_AAC_ERLC = 67108928u, // (AAC | AAC_SUB_ERLC)
+ AUDIO_FORMAT_AAC_LD = 67108992u, // (AAC | AAC_SUB_LD)
+ AUDIO_FORMAT_AAC_HE_V2 = 67109120u, // (AAC | AAC_SUB_HE_V2)
+ AUDIO_FORMAT_AAC_ELD = 67109376u, // (AAC | AAC_SUB_ELD)
+ AUDIO_FORMAT_AAC_ADTS_MAIN = 503316481u, // (AAC_ADTS | AAC_SUB_MAIN)
+ AUDIO_FORMAT_AAC_ADTS_LC = 503316482u, // (AAC_ADTS | AAC_SUB_LC)
+ AUDIO_FORMAT_AAC_ADTS_SSR = 503316484u, // (AAC_ADTS | AAC_SUB_SSR)
+ AUDIO_FORMAT_AAC_ADTS_LTP = 503316488u, // (AAC_ADTS | AAC_SUB_LTP)
+ AUDIO_FORMAT_AAC_ADTS_HE_V1 = 503316496u, // (AAC_ADTS | AAC_SUB_HE_V1)
+ AUDIO_FORMAT_AAC_ADTS_SCALABLE = 503316512u, // (AAC_ADTS | AAC_SUB_SCALABLE)
+ AUDIO_FORMAT_AAC_ADTS_ERLC = 503316544u, // (AAC_ADTS | AAC_SUB_ERLC)
+ AUDIO_FORMAT_AAC_ADTS_LD = 503316608u, // (AAC_ADTS | AAC_SUB_LD)
+ AUDIO_FORMAT_AAC_ADTS_HE_V2 = 503316736u, // (AAC_ADTS | AAC_SUB_HE_V2)
+ AUDIO_FORMAT_AAC_ADTS_ELD = 503316992u, // (AAC_ADTS | AAC_SUB_ELD)
+} audio_format_t;
+
+enum {
+ FCC_2 = 2,
+ FCC_8 = 8,
+};
+
+enum {
+ AUDIO_CHANNEL_REPRESENTATION_POSITION = 0u, // 0
+ AUDIO_CHANNEL_REPRESENTATION_INDEX = 2u, // 2
+ AUDIO_CHANNEL_NONE = 0u, // 0x0
+ AUDIO_CHANNEL_INVALID = 3221225472u, // 0xC0000000
+ AUDIO_CHANNEL_OUT_FRONT_LEFT = 1u, // 0x1
+ AUDIO_CHANNEL_OUT_FRONT_RIGHT = 2u, // 0x2
+ AUDIO_CHANNEL_OUT_FRONT_CENTER = 4u, // 0x4
+ AUDIO_CHANNEL_OUT_LOW_FREQUENCY = 8u, // 0x8
+ AUDIO_CHANNEL_OUT_BACK_LEFT = 16u, // 0x10
+ AUDIO_CHANNEL_OUT_BACK_RIGHT = 32u, // 0x20
+ AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER = 64u, // 0x40
+ AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER = 128u, // 0x80
+ AUDIO_CHANNEL_OUT_BACK_CENTER = 256u, // 0x100
+ AUDIO_CHANNEL_OUT_SIDE_LEFT = 512u, // 0x200
+ AUDIO_CHANNEL_OUT_SIDE_RIGHT = 1024u, // 0x400
+ AUDIO_CHANNEL_OUT_TOP_CENTER = 2048u, // 0x800
+ AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT = 4096u, // 0x1000
+ AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER = 8192u, // 0x2000
+ AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT = 16384u, // 0x4000
+ AUDIO_CHANNEL_OUT_TOP_BACK_LEFT = 32768u, // 0x8000
+ AUDIO_CHANNEL_OUT_TOP_BACK_CENTER = 65536u, // 0x10000
+ AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT = 131072u, // 0x20000
+ AUDIO_CHANNEL_OUT_MONO = 1u, // OUT_FRONT_LEFT
+ AUDIO_CHANNEL_OUT_STEREO = 3u, // (OUT_FRONT_LEFT | OUT_FRONT_RIGHT)
+ AUDIO_CHANNEL_OUT_2POINT1 = 11u, // ((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) | OUT_LOW_FREQUENCY)
+ AUDIO_CHANNEL_OUT_QUAD =
+ 51u, // (((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) | OUT_BACK_LEFT) | OUT_BACK_RIGHT)
+ AUDIO_CHANNEL_OUT_QUAD_BACK = 51u, // OUT_QUAD
+ AUDIO_CHANNEL_OUT_QUAD_SIDE =
+ 1539u, // (((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) | OUT_SIDE_LEFT) | OUT_SIDE_RIGHT)
+ AUDIO_CHANNEL_OUT_SURROUND =
+ 263u, // (((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) | OUT_FRONT_CENTER) | OUT_BACK_CENTER)
+ AUDIO_CHANNEL_OUT_PENTA = 55u, // (OUT_QUAD | OUT_FRONT_CENTER)
+ AUDIO_CHANNEL_OUT_5POINT1 = 63u, // (((((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) | OUT_FRONT_CENTER)
+ // | OUT_LOW_FREQUENCY) | OUT_BACK_LEFT) | OUT_BACK_RIGHT)
+ AUDIO_CHANNEL_OUT_5POINT1_BACK = 63u, // OUT_5POINT1
+ AUDIO_CHANNEL_OUT_5POINT1_SIDE = 1551u, // (((((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) |
+ // OUT_FRONT_CENTER) | OUT_LOW_FREQUENCY) |
+ // OUT_SIDE_LEFT) | OUT_SIDE_RIGHT)
+ AUDIO_CHANNEL_OUT_6POINT1 = 319u, // ((((((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) |
+ // OUT_FRONT_CENTER) | OUT_LOW_FREQUENCY) | OUT_BACK_LEFT) |
+ // OUT_BACK_RIGHT) | OUT_BACK_CENTER)
+ AUDIO_CHANNEL_OUT_7POINT1 = 1599u, // (((((((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) |
+ // OUT_FRONT_CENTER) | OUT_LOW_FREQUENCY) | OUT_BACK_LEFT) |
+ // OUT_BACK_RIGHT) | OUT_SIDE_LEFT) | OUT_SIDE_RIGHT)
+ AUDIO_CHANNEL_OUT_ALL =
+ 262143u, // (((((((((((((((((OUT_FRONT_LEFT | OUT_FRONT_RIGHT) | OUT_FRONT_CENTER) |
+ // OUT_LOW_FREQUENCY) | OUT_BACK_LEFT) | OUT_BACK_RIGHT) |
+ // OUT_FRONT_LEFT_OF_CENTER) | OUT_FRONT_RIGHT_OF_CENTER) | OUT_BACK_CENTER) |
+ // OUT_SIDE_LEFT) | OUT_SIDE_RIGHT) | OUT_TOP_CENTER) | OUT_TOP_FRONT_LEFT) |
+ // OUT_TOP_FRONT_CENTER) | OUT_TOP_FRONT_RIGHT) | OUT_TOP_BACK_LEFT) |
+ // OUT_TOP_BACK_CENTER) | OUT_TOP_BACK_RIGHT)
+ AUDIO_CHANNEL_IN_LEFT = 4u, // 0x4
+ AUDIO_CHANNEL_IN_RIGHT = 8u, // 0x8
+ AUDIO_CHANNEL_IN_FRONT = 16u, // 0x10
+ AUDIO_CHANNEL_IN_BACK = 32u, // 0x20
+ AUDIO_CHANNEL_IN_LEFT_PROCESSED = 64u, // 0x40
+ AUDIO_CHANNEL_IN_RIGHT_PROCESSED = 128u, // 0x80
+ AUDIO_CHANNEL_IN_FRONT_PROCESSED = 256u, // 0x100
+ AUDIO_CHANNEL_IN_BACK_PROCESSED = 512u, // 0x200
+ AUDIO_CHANNEL_IN_PRESSURE = 1024u, // 0x400
+ AUDIO_CHANNEL_IN_X_AXIS = 2048u, // 0x800
+ AUDIO_CHANNEL_IN_Y_AXIS = 4096u, // 0x1000
+ AUDIO_CHANNEL_IN_Z_AXIS = 8192u, // 0x2000
+ AUDIO_CHANNEL_IN_VOICE_UPLINK = 16384u, // 0x4000
+ AUDIO_CHANNEL_IN_VOICE_DNLINK = 32768u, // 0x8000
+ AUDIO_CHANNEL_IN_MONO = 16u, // IN_FRONT
+ AUDIO_CHANNEL_IN_STEREO = 12u, // (IN_LEFT | IN_RIGHT)
+ AUDIO_CHANNEL_IN_FRONT_BACK = 48u, // (IN_FRONT | IN_BACK)
+ AUDIO_CHANNEL_IN_6 = 252u, // (((((IN_LEFT | IN_RIGHT) | IN_FRONT) | IN_BACK) |
+ // IN_LEFT_PROCESSED) | IN_RIGHT_PROCESSED)
+ AUDIO_CHANNEL_IN_VOICE_UPLINK_MONO = 16400u, // (IN_VOICE_UPLINK | IN_MONO)
+ AUDIO_CHANNEL_IN_VOICE_DNLINK_MONO = 32784u, // (IN_VOICE_DNLINK | IN_MONO)
+ AUDIO_CHANNEL_IN_VOICE_CALL_MONO = 49168u, // (IN_VOICE_UPLINK_MONO | IN_VOICE_DNLINK_MONO)
+ AUDIO_CHANNEL_IN_ALL =
+ 65532u, // (((((((((((((IN_LEFT | IN_RIGHT) | IN_FRONT) | IN_BACK) | IN_LEFT_PROCESSED) |
+ // IN_RIGHT_PROCESSED) | IN_FRONT_PROCESSED) | IN_BACK_PROCESSED) | IN_PRESSURE) |
+ // IN_X_AXIS) | IN_Y_AXIS) | IN_Z_AXIS) | IN_VOICE_UPLINK) | IN_VOICE_DNLINK)
+ AUDIO_CHANNEL_COUNT_MAX = 30u, // 30
+ AUDIO_CHANNEL_INDEX_HDR = 2147483648u, // (REPRESENTATION_INDEX << COUNT_MAX)
+ AUDIO_CHANNEL_INDEX_MASK_1 = 2147483649u, // (INDEX_HDR | ((1 << 1) - 1))
+ AUDIO_CHANNEL_INDEX_MASK_2 = 2147483651u, // (INDEX_HDR | ((1 << 2) - 1))
+ AUDIO_CHANNEL_INDEX_MASK_3 = 2147483655u, // (INDEX_HDR | ((1 << 3) - 1))
+ AUDIO_CHANNEL_INDEX_MASK_4 = 2147483663u, // (INDEX_HDR | ((1 << 4) - 1))
+ AUDIO_CHANNEL_INDEX_MASK_5 = 2147483679u, // (INDEX_HDR | ((1 << 5) - 1))
+ AUDIO_CHANNEL_INDEX_MASK_6 = 2147483711u, // (INDEX_HDR | ((1 << 6) - 1))
+ AUDIO_CHANNEL_INDEX_MASK_7 = 2147483775u, // (INDEX_HDR | ((1 << 7) - 1))
+ AUDIO_CHANNEL_INDEX_MASK_8 = 2147483903u, // (INDEX_HDR | ((1 << 8) - 1))
+};
+
+enum {
+ AUDIO_INTERLEAVE_LEFT = 0,
+ AUDIO_INTERLEAVE_RIGHT = 1,
+};
+
+typedef enum {
+ AUDIO_MODE_INVALID = -2, // (-2)
+ AUDIO_MODE_CURRENT = -1, // (-1)
+ AUDIO_MODE_NORMAL = 0,
+ AUDIO_MODE_RINGTONE = 1,
+ AUDIO_MODE_IN_CALL = 2,
+ AUDIO_MODE_IN_COMMUNICATION = 3,
+ AUDIO_MODE_CNT = 4,
+ AUDIO_MODE_MAX = 3, // (CNT - 1)
+} audio_mode_t;
+
+enum {
+ AUDIO_DEVICE_NONE = 0u, // 0x0
+ AUDIO_DEVICE_BIT_IN = 2147483648u, // 0x80000000
+ AUDIO_DEVICE_BIT_DEFAULT = 1073741824u, // 0x40000000
+ AUDIO_DEVICE_OUT_EARPIECE = 1u, // 0x1
+ AUDIO_DEVICE_OUT_SPEAKER = 2u, // 0x2
+ AUDIO_DEVICE_OUT_WIRED_HEADSET = 4u, // 0x4
+ AUDIO_DEVICE_OUT_WIRED_HEADPHONE = 8u, // 0x8
+ AUDIO_DEVICE_OUT_BLUETOOTH_SCO = 16u, // 0x10
+ AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET = 32u, // 0x20
+ AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT = 64u, // 0x40
+ AUDIO_DEVICE_OUT_BLUETOOTH_A2DP = 128u, // 0x80
+ AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 256u, // 0x100
+ AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER = 512u, // 0x200
+ AUDIO_DEVICE_OUT_AUX_DIGITAL = 1024u, // 0x400
+ AUDIO_DEVICE_OUT_HDMI = 1024u, // OUT_AUX_DIGITAL
+ AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET = 2048u, // 0x800
+ AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET = 4096u, // 0x1000
+ AUDIO_DEVICE_OUT_USB_ACCESSORY = 8192u, // 0x2000
+ AUDIO_DEVICE_OUT_USB_DEVICE = 16384u, // 0x4000
+ AUDIO_DEVICE_OUT_REMOTE_SUBMIX = 32768u, // 0x8000
+ AUDIO_DEVICE_OUT_TELEPHONY_TX = 65536u, // 0x10000
+ AUDIO_DEVICE_OUT_LINE = 131072u, // 0x20000
+ AUDIO_DEVICE_OUT_HDMI_ARC = 262144u, // 0x40000
+ AUDIO_DEVICE_OUT_SPDIF = 524288u, // 0x80000
+ AUDIO_DEVICE_OUT_FM = 1048576u, // 0x100000
+ AUDIO_DEVICE_OUT_AUX_LINE = 2097152u, // 0x200000
+ AUDIO_DEVICE_OUT_SPEAKER_SAFE = 4194304u, // 0x400000
+ AUDIO_DEVICE_OUT_IP = 8388608u, // 0x800000
+ AUDIO_DEVICE_OUT_BUS = 16777216u, // 0x1000000
+ AUDIO_DEVICE_OUT_PROXY = 33554432u, // 0x2000000
+ AUDIO_DEVICE_OUT_USB_HEADSET = 67108864u, // 0x4000000
+ AUDIO_DEVICE_OUT_DEFAULT = 1073741824u, // BIT_DEFAULT
+ AUDIO_DEVICE_OUT_ALL =
+ 1207959551u, // (((((((((((((((((((((((((((OUT_EARPIECE | OUT_SPEAKER) | OUT_WIRED_HEADSET)
+ // | OUT_WIRED_HEADPHONE) | OUT_BLUETOOTH_SCO) | OUT_BLUETOOTH_SCO_HEADSET) |
+ // OUT_BLUETOOTH_SCO_CARKIT) | OUT_BLUETOOTH_A2DP) |
+ // OUT_BLUETOOTH_A2DP_HEADPHONES) | OUT_BLUETOOTH_A2DP_SPEAKER) | OUT_HDMI) |
+ // OUT_ANLG_DOCK_HEADSET) | OUT_DGTL_DOCK_HEADSET) | OUT_USB_ACCESSORY) |
+ // OUT_USB_DEVICE) | OUT_REMOTE_SUBMIX) | OUT_TELEPHONY_TX) | OUT_LINE) |
+ // OUT_HDMI_ARC) | OUT_SPDIF) | OUT_FM) | OUT_AUX_LINE) | OUT_SPEAKER_SAFE) |
+ // OUT_IP) | OUT_BUS) | OUT_PROXY) | OUT_USB_HEADSET) | OUT_DEFAULT)
+ AUDIO_DEVICE_OUT_ALL_A2DP = 896u, // ((OUT_BLUETOOTH_A2DP | OUT_BLUETOOTH_A2DP_HEADPHONES) |
+ // OUT_BLUETOOTH_A2DP_SPEAKER)
+ AUDIO_DEVICE_OUT_ALL_SCO =
+ 112u, // ((OUT_BLUETOOTH_SCO | OUT_BLUETOOTH_SCO_HEADSET) | OUT_BLUETOOTH_SCO_CARKIT)
+ AUDIO_DEVICE_OUT_ALL_USB =
+ 67133440u, // ((OUT_USB_ACCESSORY | OUT_USB_DEVICE) | OUT_USB_HEADSET)
+ AUDIO_DEVICE_IN_COMMUNICATION = 2147483649u, // (BIT_IN | 0x1)
+ AUDIO_DEVICE_IN_AMBIENT = 2147483650u, // (BIT_IN | 0x2)
+ AUDIO_DEVICE_IN_BUILTIN_MIC = 2147483652u, // (BIT_IN | 0x4)
+ AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET = 2147483656u, // (BIT_IN | 0x8)
+ AUDIO_DEVICE_IN_WIRED_HEADSET = 2147483664u, // (BIT_IN | 0x10)
+ AUDIO_DEVICE_IN_AUX_DIGITAL = 2147483680u, // (BIT_IN | 0x20)
+ AUDIO_DEVICE_IN_HDMI = 2147483680u, // IN_AUX_DIGITAL
+ AUDIO_DEVICE_IN_VOICE_CALL = 2147483712u, // (BIT_IN | 0x40)
+ AUDIO_DEVICE_IN_TELEPHONY_RX = 2147483712u, // IN_VOICE_CALL
+ AUDIO_DEVICE_IN_BACK_MIC = 2147483776u, // (BIT_IN | 0x80)
+ AUDIO_DEVICE_IN_REMOTE_SUBMIX = 2147483904u, // (BIT_IN | 0x100)
+ AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET = 2147484160u, // (BIT_IN | 0x200)
+ AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET = 2147484672u, // (BIT_IN | 0x400)
+ AUDIO_DEVICE_IN_USB_ACCESSORY = 2147485696u, // (BIT_IN | 0x800)
+ AUDIO_DEVICE_IN_USB_DEVICE = 2147487744u, // (BIT_IN | 0x1000)
+ AUDIO_DEVICE_IN_FM_TUNER = 2147491840u, // (BIT_IN | 0x2000)
+ AUDIO_DEVICE_IN_TV_TUNER = 2147500032u, // (BIT_IN | 0x4000)
+ AUDIO_DEVICE_IN_LINE = 2147516416u, // (BIT_IN | 0x8000)
+ AUDIO_DEVICE_IN_SPDIF = 2147549184u, // (BIT_IN | 0x10000)
+ AUDIO_DEVICE_IN_BLUETOOTH_A2DP = 2147614720u, // (BIT_IN | 0x20000)
+ AUDIO_DEVICE_IN_LOOPBACK = 2147745792u, // (BIT_IN | 0x40000)
+ AUDIO_DEVICE_IN_IP = 2148007936u, // (BIT_IN | 0x80000)
+ AUDIO_DEVICE_IN_BUS = 2148532224u, // (BIT_IN | 0x100000)
+ AUDIO_DEVICE_IN_PROXY = 2164260864u, // (BIT_IN | 0x1000000)
+ AUDIO_DEVICE_IN_USB_HEADSET = 2181038080u, // (BIT_IN | 0x2000000)
+ AUDIO_DEVICE_IN_DEFAULT = 3221225472u, // (BIT_IN | BIT_DEFAULT)
+ AUDIO_DEVICE_IN_ALL =
+ 3273654271u, // (((((((((((((((((((((((IN_COMMUNICATION | IN_AMBIENT) | IN_BUILTIN_MIC) |
+ // IN_BLUETOOTH_SCO_HEADSET) | IN_WIRED_HEADSET) | IN_HDMI) | IN_TELEPHONY_RX)
+ // | IN_BACK_MIC) | IN_REMOTE_SUBMIX) | IN_ANLG_DOCK_HEADSET) |
+ // IN_DGTL_DOCK_HEADSET) | IN_USB_ACCESSORY) | IN_USB_DEVICE) | IN_FM_TUNER) |
+ // IN_TV_TUNER) | IN_LINE) | IN_SPDIF) | IN_BLUETOOTH_A2DP) | IN_LOOPBACK) |
+ // IN_IP) | IN_BUS) | IN_PROXY) | IN_USB_HEADSET) | IN_DEFAULT)
+ AUDIO_DEVICE_IN_ALL_SCO = 2147483656u, // IN_BLUETOOTH_SCO_HEADSET
+ AUDIO_DEVICE_IN_ALL_USB = 2181044224u, // ((IN_USB_ACCESSORY | IN_USB_DEVICE) | IN_USB_HEADSET)
+};
+
+typedef enum {
+ AUDIO_OUTPUT_FLAG_NONE = 0, // 0x0
+ AUDIO_OUTPUT_FLAG_DIRECT = 1, // 0x1
+ AUDIO_OUTPUT_FLAG_PRIMARY = 2, // 0x2
+ AUDIO_OUTPUT_FLAG_FAST = 4, // 0x4
+ AUDIO_OUTPUT_FLAG_DEEP_BUFFER = 8, // 0x8
+ AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD = 16, // 0x10
+ AUDIO_OUTPUT_FLAG_NON_BLOCKING = 32, // 0x20
+ AUDIO_OUTPUT_FLAG_HW_AV_SYNC = 64, // 0x40
+ AUDIO_OUTPUT_FLAG_TTS = 128, // 0x80
+ AUDIO_OUTPUT_FLAG_RAW = 256, // 0x100
+ AUDIO_OUTPUT_FLAG_SYNC = 512, // 0x200
+ AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO = 1024, // 0x400
+ AUDIO_OUTPUT_FLAG_DIRECT_PCM = 8192, // 0x2000
+ AUDIO_OUTPUT_FLAG_MMAP_NOIRQ = 16384, // 0x4000
+ AUDIO_OUTPUT_FLAG_VOIP_RX = 32768, // 0x8000
+} audio_output_flags_t;
+
+typedef enum {
+ AUDIO_INPUT_FLAG_NONE = 0, // 0x0
+ AUDIO_INPUT_FLAG_FAST = 1, // 0x1
+ AUDIO_INPUT_FLAG_HW_HOTWORD = 2, // 0x2
+ AUDIO_INPUT_FLAG_RAW = 4, // 0x4
+ AUDIO_INPUT_FLAG_SYNC = 8, // 0x8
+ AUDIO_INPUT_FLAG_MMAP_NOIRQ = 16, // 0x10
+ AUDIO_INPUT_FLAG_VOIP_TX = 32, // 0x20
+} audio_input_flags_t;
+
+typedef enum {
+ AUDIO_USAGE_UNKNOWN = 0,
+ AUDIO_USAGE_MEDIA = 1,
+ AUDIO_USAGE_VOICE_COMMUNICATION = 2,
+ AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING = 3,
+ AUDIO_USAGE_ALARM = 4,
+ AUDIO_USAGE_NOTIFICATION = 5,
+ AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE = 6,
+ AUDIO_USAGE_NOTIFICATION_COMMUNICATION_REQUEST = 7,
+ AUDIO_USAGE_NOTIFICATION_COMMUNICATION_INSTANT = 8,
+ AUDIO_USAGE_NOTIFICATION_COMMUNICATION_DELAYED = 9,
+ AUDIO_USAGE_NOTIFICATION_EVENT = 10,
+ AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY = 11,
+ AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE = 12,
+ AUDIO_USAGE_ASSISTANCE_SONIFICATION = 13,
+ AUDIO_USAGE_GAME = 14,
+ AUDIO_USAGE_VIRTUAL_SOURCE = 15,
+ AUDIO_USAGE_ASSISTANT = 16,
+ AUDIO_USAGE_CNT = 17,
+ AUDIO_USAGE_MAX = 16, // (CNT - 1)
+} audio_usage_t;
+
+enum {
+ AUDIO_GAIN_MODE_JOINT = 1u, // 0x1
+ AUDIO_GAIN_MODE_CHANNELS = 2u, // 0x2
+ AUDIO_GAIN_MODE_RAMP = 4u, // 0x4
+};
+
+typedef enum {
+ AUDIO_PORT_ROLE_NONE = 0,
+ AUDIO_PORT_ROLE_SOURCE = 1,
+ AUDIO_PORT_ROLE_SINK = 2,
+} audio_port_role_t;
+
+typedef enum {
+ AUDIO_PORT_TYPE_NONE = 0,
+ AUDIO_PORT_TYPE_DEVICE = 1,
+ AUDIO_PORT_TYPE_MIX = 2,
+ AUDIO_PORT_TYPE_SESSION = 3,
+} audio_port_type_t;
+
+enum {
+ AUDIO_PORT_CONFIG_SAMPLE_RATE = 1u, // 0x1
+ AUDIO_PORT_CONFIG_CHANNEL_MASK = 2u, // 0x2
+ AUDIO_PORT_CONFIG_FORMAT = 4u, // 0x4
+ AUDIO_PORT_CONFIG_GAIN = 8u, // 0x8
+ AUDIO_PORT_CONFIG_ALL = 15u, // (((SAMPLE_RATE | CHANNEL_MASK) | FORMAT) | GAIN)
+};
+
+typedef enum {
+ AUDIO_LATENCY_LOW = 0,
+ AUDIO_LATENCY_NORMAL = 1,
+} audio_mix_latency_class_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_COMMON_V2_0_EXPORTED_CONSTANTS_H_
diff --git a/audio/common/2.0/legacy/include/system/audio_effect-base.h b/audio/common/2.0/legacy/include/system/audio_effect-base.h
new file mode 100644
index 0000000..cd17f55
--- /dev/null
+++ b/audio/common/2.0/legacy/include/system/audio_effect-base.h
@@ -0,0 +1,101 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+// Source: android.hardware.audio.effect@2.0
+// Root: android.hardware:hardware/interfaces
+
+#ifndef HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EXPORTED_CONSTANTS_H_
+#define HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EXPORTED_CONSTANTS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ EFFECT_FLAG_TYPE_SHIFT = 0,
+ EFFECT_FLAG_TYPE_SIZE = 3,
+ EFFECT_FLAG_TYPE_MASK = 7, // (((1 << TYPE_SIZE) - 1) << TYPE_SHIFT)
+ EFFECT_FLAG_TYPE_INSERT = 0, // (0 << TYPE_SHIFT)
+ EFFECT_FLAG_TYPE_AUXILIARY = 1, // (1 << TYPE_SHIFT)
+ EFFECT_FLAG_TYPE_REPLACE = 2, // (2 << TYPE_SHIFT)
+ EFFECT_FLAG_TYPE_PRE_PROC = 3, // (3 << TYPE_SHIFT)
+ EFFECT_FLAG_TYPE_POST_PROC = 4, // (4 << TYPE_SHIFT)
+ EFFECT_FLAG_INSERT_SHIFT = 3, // (TYPE_SHIFT + TYPE_SIZE)
+ EFFECT_FLAG_INSERT_SIZE = 3,
+ EFFECT_FLAG_INSERT_MASK = 56, // (((1 << INSERT_SIZE) - 1) << INSERT_SHIFT)
+ EFFECT_FLAG_INSERT_ANY = 0, // (0 << INSERT_SHIFT)
+ EFFECT_FLAG_INSERT_FIRST = 8, // (1 << INSERT_SHIFT)
+ EFFECT_FLAG_INSERT_LAST = 16, // (2 << INSERT_SHIFT)
+ EFFECT_FLAG_INSERT_EXCLUSIVE = 24, // (3 << INSERT_SHIFT)
+ EFFECT_FLAG_VOLUME_SHIFT = 6, // (INSERT_SHIFT + INSERT_SIZE)
+ EFFECT_FLAG_VOLUME_SIZE = 3,
+ EFFECT_FLAG_VOLUME_MASK = 448, // (((1 << VOLUME_SIZE) - 1) << VOLUME_SHIFT)
+ EFFECT_FLAG_VOLUME_CTRL = 64, // (1 << VOLUME_SHIFT)
+ EFFECT_FLAG_VOLUME_IND = 128, // (2 << VOLUME_SHIFT)
+ EFFECT_FLAG_VOLUME_NONE = 0, // (0 << VOLUME_SHIFT)
+ EFFECT_FLAG_DEVICE_SHIFT = 9, // (VOLUME_SHIFT + VOLUME_SIZE)
+ EFFECT_FLAG_DEVICE_SIZE = 3,
+ EFFECT_FLAG_DEVICE_MASK = 3584, // (((1 << DEVICE_SIZE) - 1) << DEVICE_SHIFT)
+ EFFECT_FLAG_DEVICE_IND = 512, // (1 << DEVICE_SHIFT)
+ EFFECT_FLAG_DEVICE_NONE = 0, // (0 << DEVICE_SHIFT)
+ EFFECT_FLAG_INPUT_SHIFT = 12, // (DEVICE_SHIFT + DEVICE_SIZE)
+ EFFECT_FLAG_INPUT_SIZE = 2,
+ EFFECT_FLAG_INPUT_MASK = 12288, // (((1 << INPUT_SIZE) - 1) << INPUT_SHIFT)
+ EFFECT_FLAG_INPUT_DIRECT = 4096, // (1 << INPUT_SHIFT)
+ EFFECT_FLAG_INPUT_PROVIDER = 8192, // (2 << INPUT_SHIFT)
+ EFFECT_FLAG_INPUT_BOTH = 12288, // (3 << INPUT_SHIFT)
+ EFFECT_FLAG_OUTPUT_SHIFT = 14, // (INPUT_SHIFT + INPUT_SIZE)
+ EFFECT_FLAG_OUTPUT_SIZE = 2,
+ EFFECT_FLAG_OUTPUT_MASK = 49152, // (((1 << OUTPUT_SIZE) - 1) << OUTPUT_SHIFT)
+ EFFECT_FLAG_OUTPUT_DIRECT = 16384, // (1 << OUTPUT_SHIFT)
+ EFFECT_FLAG_OUTPUT_PROVIDER = 32768, // (2 << OUTPUT_SHIFT)
+ EFFECT_FLAG_OUTPUT_BOTH = 49152, // (3 << OUTPUT_SHIFT)
+ EFFECT_FLAG_HW_ACC_SHIFT = 16, // (OUTPUT_SHIFT + OUTPUT_SIZE)
+ EFFECT_FLAG_HW_ACC_SIZE = 2,
+ EFFECT_FLAG_HW_ACC_MASK = 196608, // (((1 << HW_ACC_SIZE) - 1) << HW_ACC_SHIFT)
+ EFFECT_FLAG_HW_ACC_SIMPLE = 65536, // (1 << HW_ACC_SHIFT)
+ EFFECT_FLAG_HW_ACC_TUNNEL = 131072, // (2 << HW_ACC_SHIFT)
+ EFFECT_FLAG_AUDIO_MODE_SHIFT = 18, // (HW_ACC_SHIFT + HW_ACC_SIZE)
+ EFFECT_FLAG_AUDIO_MODE_SIZE = 2,
+ EFFECT_FLAG_AUDIO_MODE_MASK = 786432, // (((1 << AUDIO_MODE_SIZE) - 1) << AUDIO_MODE_SHIFT)
+ EFFECT_FLAG_AUDIO_MODE_IND = 262144, // (1 << AUDIO_MODE_SHIFT)
+ EFFECT_FLAG_AUDIO_MODE_NONE = 0, // (0 << AUDIO_MODE_SHIFT)
+ EFFECT_FLAG_AUDIO_SOURCE_SHIFT = 20, // (AUDIO_MODE_SHIFT + AUDIO_MODE_SIZE)
+ EFFECT_FLAG_AUDIO_SOURCE_SIZE = 2,
+ EFFECT_FLAG_AUDIO_SOURCE_MASK =
+ 3145728, // (((1 << AUDIO_SOURCE_SIZE) - 1) << AUDIO_SOURCE_SHIFT)
+ EFFECT_FLAG_AUDIO_SOURCE_IND = 1048576, // (1 << AUDIO_SOURCE_SHIFT)
+ EFFECT_FLAG_AUDIO_SOURCE_NONE = 0, // (0 << AUDIO_SOURCE_SHIFT)
+ EFFECT_FLAG_OFFLOAD_SHIFT = 22, // (AUDIO_SOURCE_SHIFT + AUDIO_SOURCE_SIZE)
+ EFFECT_FLAG_OFFLOAD_SIZE = 1,
+ EFFECT_FLAG_OFFLOAD_MASK = 4194304, // (((1 << OFFLOAD_SIZE) - 1) << OFFLOAD_SHIFT)
+ EFFECT_FLAG_OFFLOAD_SUPPORTED = 4194304, // (1 << OFFLOAD_SHIFT)
+ EFFECT_FLAG_NO_PROCESS_SHIFT = 23, // (OFFLOAD_SHIFT + OFFLOAD_SIZE)
+ EFFECT_FLAG_NO_PROCESS_SIZE = 1,
+ EFFECT_FLAG_NO_PROCESS_MASK = 8388608, // (((1 << NO_PROCESS_SIZE) - 1) << NO_PROCESS_SHIFT)
+ EFFECT_FLAG_NO_PROCESS = 8388608, // (1 << NO_PROCESS_SHIFT)
+};
+
+typedef enum {
+ EFFECT_BUFFER_ACCESS_WRITE = 0,
+ EFFECT_BUFFER_ACCESS_READ = 1,
+ EFFECT_BUFFER_ACCESS_ACCUMULATE = 2,
+} effect_buffer_access_e;
+
+enum {
+ EFFECT_CONFIG_BUFFER = 1, // 0x0001
+ EFFECT_CONFIG_SMP_RATE = 2, // 0x0002
+ EFFECT_CONFIG_CHANNELS = 4, // 0x0004
+ EFFECT_CONFIG_FORMAT = 8, // 0x0008
+ EFFECT_CONFIG_ACC_MODE = 16, // 0x0010
+ EFFECT_CONFIG_ALL = 31, // ((((BUFFER | SMP_RATE) | CHANNELS) | FORMAT) | ACC_MODE)
+};
+
+typedef enum {
+ EFFECT_FEATURE_AUX_CHANNELS = 0,
+ EFFECT_FEATURE_CNT = 1,
+} effect_feature_e;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EXPORTED_CONSTANTS_H_
diff --git a/audio/common/all-versions/default/Android.bp b/audio/common/all-versions/default/Android.bp
index 8f6b74c..9b82f05 100644
--- a/audio/common/all-versions/default/Android.bp
+++ b/audio/common/all-versions/default/Android.bp
@@ -16,10 +16,7 @@
cc_library_shared {
name: "android.hardware.audio.common-util",
defaults: ["hidl_defaults"],
- vendor_available: true,
- vndk: {
- enabled: true,
- },
+ vendor: true,
srcs: [
"EffectMap.cpp",
],
@@ -33,7 +30,7 @@
],
header_libs: [
- "libaudio_system_headers",
+ "android.hardware.audio.common.legacy@2.0",
"libhardware_headers",
],
}
diff --git a/audio/common/all-versions/legacy/Android.bp b/audio/common/all-versions/legacy/Android.bp
new file mode 100644
index 0000000..2fb01dd
--- /dev/null
+++ b/audio/common/all-versions/legacy/Android.bp
@@ -0,0 +1,8 @@
+cc_library_headers {
+ name: "android.hardware.audio.common.legacy@all-versions",
+ vendor: true,
+ export_include_dirs: ["include"],
+ header_libs: ["libcutils_headers"],
+ export_header_lib_headers: ["libcutils_headers"],
+}
+
diff --git a/audio/common/all-versions/legacy/OWNERS b/audio/common/all-versions/legacy/OWNERS
new file mode 100644
index 0000000..6fdc97c
--- /dev/null
+++ b/audio/common/all-versions/legacy/OWNERS
@@ -0,0 +1,3 @@
+elaurent@google.com
+krocard@google.com
+mnaganov@google.com
diff --git a/audio/common/all-versions/legacy/include/hardware/audio.h b/audio/common/all-versions/legacy/include/hardware/audio.h
new file mode 100644
index 0000000..1ad3e0e
--- /dev/null
+++ b/audio/common/all-versions/legacy/include/hardware/audio.h
@@ -0,0 +1,709 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_AUDIO_HAL_INTERFACE_H
+#define ANDROID_AUDIO_HAL_INTERFACE_H
+
+#include <stdint.h>
+#include <strings.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <time.h>
+
+#include <cutils/bitops.h>
+
+#include <hardware/audio_effect.h>
+#include <hardware/hardware.h>
+#include <system/audio.h>
+
+__BEGIN_DECLS
+
+/**
+ * The id of this module
+ */
+#define AUDIO_HARDWARE_MODULE_ID "audio"
+
+/**
+ * Name of the audio devices to open
+ */
+#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_2_0 HARDWARE_DEVICE_API_VERSION(2, 0)
+#define AUDIO_DEVICE_API_VERSION_3_0 HARDWARE_DEVICE_API_VERSION(3, 0)
+#define AUDIO_DEVICE_API_VERSION_CURRENT AUDIO_DEVICE_API_VERSION_3_0
+/* Minimal audio HAL version supported by the audio framework */
+#define AUDIO_DEVICE_API_VERSION_MIN AUDIO_DEVICE_API_VERSION_2_0
+
+/**************************************/
+
+/**
+ * standard audio parameters that the HAL may need to handle
+ */
+
+/**
+ * audio device parameters
+ */
+
+/* TTY mode selection */
+#define AUDIO_PARAMETER_KEY_TTY_MODE "tty_mode"
+#define AUDIO_PARAMETER_VALUE_TTY_OFF "tty_off"
+#define AUDIO_PARAMETER_VALUE_TTY_VCO "tty_vco"
+#define AUDIO_PARAMETER_VALUE_TTY_HCO "tty_hco"
+#define AUDIO_PARAMETER_VALUE_TTY_FULL "tty_full"
+
+/* Hearing Aid Compatibility - Telecoil (HAC-T) mode on/off */
+#define AUDIO_PARAMETER_KEY_HAC "HACSetting"
+#define AUDIO_PARAMETER_VALUE_HAC_ON "ON"
+#define AUDIO_PARAMETER_VALUE_HAC_OFF "OFF"
+
+/* A2DP sink address set by framework */
+#define AUDIO_PARAMETER_A2DP_SINK_ADDRESS "a2dp_sink_address"
+
+/* A2DP source address set by framework */
+#define AUDIO_PARAMETER_A2DP_SOURCE_ADDRESS "a2dp_source_address"
+
+/* Bluetooth SCO wideband */
+#define AUDIO_PARAMETER_KEY_BT_SCO_WB "bt_wbs"
+
+/**
+ * audio stream parameters
+ */
+
+/* Enable AANC */
+#define AUDIO_PARAMETER_KEY_AANC "aanc_enabled"
+
+/**************************************/
+
+/* common audio stream parameters and operations */
+struct audio_stream {
+ /**
+ * Return the sampling rate in Hz - eg. 44100.
+ */
+ uint32_t (*get_sample_rate)(const struct audio_stream* stream);
+
+ /* currently unused - use set_parameters with key
+ * AUDIO_PARAMETER_STREAM_SAMPLING_RATE
+ */
+ int (*set_sample_rate)(struct audio_stream* stream, uint32_t rate);
+
+ /**
+ * Return size of input/output buffer in bytes for this stream - eg. 4800.
+ * It should be a multiple of the frame size. See also get_input_buffer_size.
+ */
+ size_t (*get_buffer_size)(const struct audio_stream* stream);
+
+ /**
+ * Return the channel mask -
+ * e.g. AUDIO_CHANNEL_OUT_STEREO or AUDIO_CHANNEL_IN_STEREO
+ */
+ audio_channel_mask_t (*get_channels)(const struct audio_stream* stream);
+
+ /**
+ * Return the audio format - e.g. AUDIO_FORMAT_PCM_16_BIT
+ */
+ audio_format_t (*get_format)(const struct audio_stream* stream);
+
+ /* currently unused - use set_parameters with key
+ * AUDIO_PARAMETER_STREAM_FORMAT
+ */
+ int (*set_format)(struct audio_stream* stream, audio_format_t format);
+
+ /**
+ * Put the audio hardware input/output into standby mode.
+ * Driver should exit from standby mode at the next I/O operation.
+ * Returns 0 on success and <0 on failure.
+ */
+ int (*standby)(struct audio_stream* stream);
+
+ /** dump the state of the audio input/output device */
+ int (*dump)(const struct audio_stream* stream, int fd);
+
+ /** Return the set of device(s) which this stream is connected to */
+ audio_devices_t (*get_device)(const struct audio_stream* stream);
+
+ /**
+ * Currently unused - set_device() corresponds to set_parameters() with key
+ * AUDIO_PARAMETER_STREAM_ROUTING for both input and output.
+ * AUDIO_PARAMETER_STREAM_INPUT_SOURCE is an additional information used by
+ * input streams only.
+ */
+ int (*set_device)(struct audio_stream* stream, audio_devices_t device);
+
+ /**
+ * set/get audio stream parameters. The function accepts a list of
+ * parameter key value pairs in the form: key1=value1;key2=value2;...
+ *
+ * Some keys are reserved for standard parameters (See AudioParameter class)
+ *
+ * If the implementation does not accept a parameter change while
+ * the output is active but the parameter is acceptable otherwise, it must
+ * return -ENOSYS.
+ *
+ * The audio flinger will put the stream in standby and then change the
+ * parameter value.
+ */
+ int (*set_parameters)(struct audio_stream* stream, const char* kv_pairs);
+
+ /*
+ * Returns a pointer to a heap allocated string. The caller is responsible
+ * for freeing the memory for it using free().
+ */
+ char* (*get_parameters)(const struct audio_stream* stream, const char* keys);
+ int (*add_audio_effect)(const struct audio_stream* stream, effect_handle_t effect);
+ int (*remove_audio_effect)(const struct audio_stream* stream, effect_handle_t effect);
+};
+typedef struct audio_stream audio_stream_t;
+
+/* type of asynchronous write callback events. Mutually exclusive */
+typedef enum {
+ STREAM_CBK_EVENT_WRITE_READY, /* non blocking write completed */
+ STREAM_CBK_EVENT_DRAIN_READY, /* drain completed */
+ STREAM_CBK_EVENT_ERROR, /* stream hit some error, let AF take action */
+} stream_callback_event_t;
+
+typedef int (*stream_callback_t)(stream_callback_event_t event, void* param, void* cookie);
+
+/* type of drain requested to audio_stream_out->drain(). Mutually exclusive */
+typedef enum {
+ AUDIO_DRAIN_ALL, /* drain() returns when all data has been played */
+ AUDIO_DRAIN_EARLY_NOTIFY /* drain() returns a short time before all data
+ from the current track has been played to
+ give time for gapless track switch */
+} audio_drain_type_t;
+
+/**
+ * audio_stream_out is the abstraction interface for the audio output hardware.
+ *
+ * It provides information about various properties of the audio output
+ * hardware driver.
+ */
+
+struct audio_stream_out {
+ /**
+ * Common methods of the audio stream out. This *must* be the first member of audio_stream_out
+ * as users of this structure will cast a audio_stream to audio_stream_out pointer in contexts
+ * where it's known the audio_stream references an audio_stream_out.
+ */
+ struct audio_stream common;
+
+ /**
+ * Return the audio hardware driver estimated latency in milliseconds.
+ */
+ uint32_t (*get_latency)(const struct audio_stream_out* stream);
+
+ /**
+ * Use this method in situations where audio mixing is done in the
+ * hardware. This method serves as a direct interface with hardware,
+ * allowing you to directly set the volume as apposed to via the framework.
+ * This method might produce multiple PCM outputs or hardware accelerated
+ * codecs, such as MP3 or AAC.
+ */
+ int (*set_volume)(struct audio_stream_out* stream, float left, float right);
+
+ /**
+ * Write audio buffer to driver. Returns number of bytes written, or a
+ * negative status_t. If at least one frame was written successfully prior to the error,
+ * it is suggested that the driver return that successful (short) byte count
+ * and then return an error in the subsequent call.
+ *
+ * If set_callback() has previously been called to enable non-blocking mode
+ * the write() is not allowed to block. It must write only the number of
+ * bytes that currently fit in the driver/hardware buffer and then return
+ * this byte count. If this is less than the requested write size the
+ * callback function must be called when more space is available in the
+ * driver/hardware buffer.
+ */
+ ssize_t (*write)(struct audio_stream_out* stream, const void* buffer, size_t bytes);
+
+ /* return the number of audio frames written by the audio dsp to DAC since
+ * the output has exited standby
+ */
+ int (*get_render_position)(const struct audio_stream_out* stream, uint32_t* dsp_frames);
+
+ /**
+ * get the local time at which the next write to the audio driver will be presented.
+ * The units are microseconds, where the epoch is decided by the local audio HAL.
+ */
+ int (*get_next_write_timestamp)(const struct audio_stream_out* stream, int64_t* timestamp);
+
+ /**
+ * set the callback function for notifying completion of non-blocking
+ * write and drain.
+ * Calling this function implies that all future write() and drain()
+ * must be non-blocking and use the callback to signal completion.
+ */
+ int (*set_callback)(struct audio_stream_out* stream, stream_callback_t callback, void* cookie);
+
+ /**
+ * Notifies to the audio driver to stop playback however the queued buffers are
+ * retained by the hardware. Useful for implementing pause/resume. Empty implementation
+ * if not supported however should be implemented for hardware with non-trivial
+ * latency. In the pause state audio hardware could still be using power. User may
+ * consider calling suspend after a timeout.
+ *
+ * Implementation of this function is mandatory for offloaded playback.
+ */
+ int (*pause)(struct audio_stream_out* stream);
+
+ /**
+ * Notifies to the audio driver to resume playback following a pause.
+ * Returns error if called without matching pause.
+ *
+ * Implementation of this function is mandatory for offloaded playback.
+ */
+ int (*resume)(struct audio_stream_out* stream);
+
+ /**
+ * Requests notification when data buffered by the driver/hardware has
+ * been played. If set_callback() has previously been called to enable
+ * non-blocking mode, the drain() must not block, instead it should return
+ * quickly and completion of the drain is notified through the callback.
+ * If set_callback() has not been called, the drain() must block until
+ * completion.
+ * If type==AUDIO_DRAIN_ALL, the drain completes when all previously written
+ * data has been played.
+ * If type==AUDIO_DRAIN_EARLY_NOTIFY, the drain completes shortly before all
+ * data for the current track has played to allow time for the framework
+ * to perform a gapless track switch.
+ *
+ * Drain must return immediately on stop() and flush() call
+ *
+ * Implementation of this function is mandatory for offloaded playback.
+ */
+ int (*drain)(struct audio_stream_out* stream, audio_drain_type_t type);
+
+ /**
+ * Notifies to the audio driver to flush the queued data. Stream must already
+ * be paused before calling flush().
+ *
+ * Implementation of this function is mandatory for offloaded playback.
+ */
+ int (*flush)(struct audio_stream_out* stream);
+
+ /**
+ * Return a recent count of the number of audio frames presented to an external observer.
+ * This excludes frames which have been written but are still in the pipeline.
+ * The count is not reset to zero when output enters standby.
+ * Also returns the value of CLOCK_MONOTONIC as of this presentation count.
+ * The returned count is expected to be 'recent',
+ * but does not need to be the most recent possible value.
+ * However, the associated time should correspond to whatever count is returned.
+ * Example: assume that N+M frames have been presented, where M is a 'small' number.
+ * Then it is permissible to return N instead of N+M,
+ * and the timestamp should correspond to N rather than N+M.
+ * The terms 'recent' and 'small' are not defined.
+ * They reflect the quality of the implementation.
+ *
+ * 3.0 and higher only.
+ */
+ int (*get_presentation_position)(const struct audio_stream_out* stream, uint64_t* frames,
+ struct timespec* timestamp);
+
+ /**
+ * Called by the framework to start a stream operating in mmap mode.
+ * create_mmap_buffer must be called before calling start()
+ *
+ * \note Function only implemented by streams operating in mmap mode.
+ *
+ * \param[in] stream the stream object.
+ * \return 0 in case of success.
+ * -ENOSYS if called out of sequence or on non mmap stream
+ */
+ int (*start)(const struct audio_stream_out* stream);
+
+ /**
+ * Called by the framework to stop a stream operating in mmap mode.
+ * Must be called after start()
+ *
+ * \note Function only implemented by streams operating in mmap mode.
+ *
+ * \param[in] stream the stream object.
+ * \return 0 in case of success.
+ * -ENOSYS if called out of sequence or on non mmap stream
+ */
+ int (*stop)(const struct audio_stream_out* stream);
+
+ /**
+ * Called by the framework to retrieve information on the mmap buffer used for audio
+ * samples transfer.
+ *
+ * \note Function only implemented by streams operating in mmap mode.
+ *
+ * \param[in] stream the stream object.
+ * \param[in] min_size_frames minimum buffer size requested. The actual buffer
+ * size returned in struct audio_mmap_buffer_info can be larger.
+ * \param[out] info address at which the mmap buffer information should be returned.
+ *
+ * \return 0 if the buffer was allocated.
+ * -ENODEV in case of initialization error
+ * -EINVAL if the requested buffer size is too large
+ * -ENOSYS if called out of sequence (e.g. buffer already allocated)
+ */
+ int (*create_mmap_buffer)(const struct audio_stream_out* stream, int32_t min_size_frames,
+ struct audio_mmap_buffer_info* info);
+
+ /**
+ * Called by the framework to read current read/write position in the mmap buffer
+ * with associated time stamp.
+ *
+ * \note Function only implemented by streams operating in mmap mode.
+ *
+ * \param[in] stream the stream object.
+ * \param[out] position address at which the mmap read/write position should be returned.
+ *
+ * \return 0 if the position is successfully returned.
+ * -ENODATA if the position cannot be retrieved
+ * -ENOSYS if called before create_mmap_buffer()
+ */
+ int (*get_mmap_position)(const struct audio_stream_out* stream,
+ struct audio_mmap_position* position);
+};
+typedef struct audio_stream_out audio_stream_out_t;
+
+struct audio_stream_in {
+ /**
+ * Common methods of the audio stream in. This *must* be the first member of audio_stream_in
+ * as users of this structure will cast a audio_stream to audio_stream_in pointer in contexts
+ * where it's known the audio_stream references an audio_stream_in.
+ */
+ struct audio_stream common;
+
+ /** set the input gain for the audio driver. This method is for
+ * for future use */
+ int (*set_gain)(struct audio_stream_in* stream, float gain);
+
+ /** Read audio buffer in from audio driver. Returns number of bytes read, or a
+ * negative status_t. If at least one frame was read prior to the error,
+ * read should return that byte count and then return an error in the subsequent call.
+ */
+ ssize_t (*read)(struct audio_stream_in* stream, void* buffer, size_t bytes);
+
+ /**
+ * Return the amount of input frames lost in the audio driver since the
+ * last call of this function.
+ * Audio driver is expected to reset the value to 0 and restart counting
+ * upon returning the current value by this function call.
+ * Such loss typically occurs when the user space process is blocked
+ * longer than the capacity of audio driver buffers.
+ *
+ * Unit: the number of input audio frames
+ */
+ uint32_t (*get_input_frames_lost)(struct audio_stream_in* stream);
+
+ /**
+ * Return a recent count of the number of audio frames received and
+ * the clock time associated with that frame count.
+ *
+ * frames is the total frame count received. This should be as early in
+ * the capture pipeline as possible. In general,
+ * frames should be non-negative and should not go "backwards".
+ *
+ * time is the clock MONOTONIC time when frames was measured. In general,
+ * time should be a positive quantity and should not go "backwards".
+ *
+ * The status returned is 0 on success, -ENOSYS if the device is not
+ * ready/available, or -EINVAL if the arguments are null or otherwise invalid.
+ */
+ int (*get_capture_position)(const struct audio_stream_in* stream, int64_t* frames,
+ int64_t* time);
+
+ /**
+ * Called by the framework to start a stream operating in mmap mode.
+ * create_mmap_buffer must be called before calling start()
+ *
+ * \note Function only implemented by streams operating in mmap mode.
+ *
+ * \param[in] stream the stream object.
+ * \return 0 in case off success.
+ * -ENOSYS if called out of sequence or on non mmap stream
+ */
+ int (*start)(const struct audio_stream_in* stream);
+
+ /**
+ * Called by the framework to stop a stream operating in mmap mode.
+ *
+ * \note Function only implemented by streams operating in mmap mode.
+ *
+ * \param[in] stream the stream object.
+ * \return 0 in case of success.
+ * -ENOSYS if called out of sequence or on non mmap stream
+ */
+ int (*stop)(const struct audio_stream_in* stream);
+
+ /**
+ * Called by the framework to retrieve information on the mmap buffer used for audio
+ * samples transfer.
+ *
+ * \note Function only implemented by streams operating in mmap mode.
+ *
+ * \param[in] stream the stream object.
+ * \param[in] min_size_frames minimum buffer size requested. The actual buffer
+ * size returned in struct audio_mmap_buffer_info can be larger.
+ * \param[out] info address at which the mmap buffer information should be returned.
+ *
+ * \return 0 if the buffer was allocated.
+ * -ENODEV in case of initialization error
+ * -EINVAL if the requested buffer size is too large
+ * -ENOSYS if called out of sequence (e.g. buffer already allocated)
+ */
+ int (*create_mmap_buffer)(const struct audio_stream_in* stream, int32_t min_size_frames,
+ struct audio_mmap_buffer_info* info);
+
+ /**
+ * Called by the framework to read current read/write position in the mmap buffer
+ * with associated time stamp.
+ *
+ * \note Function only implemented by streams operating in mmap mode.
+ *
+ * \param[in] stream the stream object.
+ * \param[out] position address at which the mmap read/write position should be returned.
+ *
+ * \return 0 if the position is successfully returned.
+ * -ENODATA if the position cannot be retreived
+ * -ENOSYS if called before mmap_read_position()
+ */
+ int (*get_mmap_position)(const struct audio_stream_in* stream,
+ struct audio_mmap_position* position);
+};
+typedef struct audio_stream_in audio_stream_in_t;
+
+/**
+ * return the frame size (number of bytes per sample).
+ *
+ * Deprecated: use audio_stream_out_frame_size() or audio_stream_in_frame_size() instead.
+ */
+__attribute__((__deprecated__)) static inline size_t audio_stream_frame_size(
+ const struct audio_stream* s) {
+ size_t chan_samp_sz;
+ audio_format_t format = s->get_format(s);
+
+ if (audio_has_proportional_frames(format)) {
+ chan_samp_sz = audio_bytes_per_sample(format);
+ return popcount(s->get_channels(s)) * chan_samp_sz;
+ }
+
+ return sizeof(int8_t);
+}
+
+/**
+ * return the frame size (number of bytes per sample) of an output stream.
+ */
+static inline size_t audio_stream_out_frame_size(const struct audio_stream_out* s) {
+ size_t chan_samp_sz;
+ audio_format_t format = s->common.get_format(&s->common);
+
+ if (audio_has_proportional_frames(format)) {
+ chan_samp_sz = audio_bytes_per_sample(format);
+ return audio_channel_count_from_out_mask(s->common.get_channels(&s->common)) * chan_samp_sz;
+ }
+
+ return sizeof(int8_t);
+}
+
+/**
+ * return the frame size (number of bytes per sample) of an input stream.
+ */
+static inline size_t audio_stream_in_frame_size(const struct audio_stream_in* s) {
+ size_t chan_samp_sz;
+ audio_format_t format = s->common.get_format(&s->common);
+
+ if (audio_has_proportional_frames(format)) {
+ chan_samp_sz = audio_bytes_per_sample(format);
+ return audio_channel_count_from_in_mask(s->common.get_channels(&s->common)) * chan_samp_sz;
+ }
+
+ return sizeof(int8_t);
+}
+
+/**********************************************************************/
+
+/**
+ * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
+ * and the fields of this data structure must begin with hw_module_t
+ * followed by module specific information.
+ */
+struct audio_module {
+ struct hw_module_t common;
+};
+
+struct audio_hw_device {
+ /**
+ * Common methods of the audio device. This *must* be the first member of audio_hw_device
+ * as users of this structure will cast a hw_device_t to audio_hw_device pointer in contexts
+ * where it's known the hw_device_t references an audio_hw_device.
+ */
+ struct hw_device_t common;
+
+ /**
+ * used by audio flinger to enumerate what devices are supported by
+ * each audio_hw_device implementation.
+ *
+ * Return value is a bitmask of 1 or more values of audio_devices_t
+ *
+ * NOTE: audio HAL implementations starting with
+ * AUDIO_DEVICE_API_VERSION_2_0 do not implement this function.
+ * All supported devices should be listed in audio_policy.conf
+ * file and the audio policy manager must choose the appropriate
+ * audio module based on information in this file.
+ */
+ uint32_t (*get_supported_devices)(const struct audio_hw_device* dev);
+
+ /**
+ * check to see if the audio hardware interface has been initialized.
+ * returns 0 on success, -ENODEV on failure.
+ */
+ int (*init_check)(const struct audio_hw_device* dev);
+
+ /** set the audio volume of a voice call. Range is between 0.0 and 1.0 */
+ int (*set_voice_volume)(struct audio_hw_device* dev, float volume);
+
+ /**
+ * set the audio volume for all audio activities other than voice call.
+ * Range between 0.0 and 1.0. If any value other than 0 is returned,
+ * the software mixer will emulate this capability.
+ */
+ int (*set_master_volume)(struct audio_hw_device* dev, float volume);
+
+ /**
+ * Get the current master volume value for the HAL, if the HAL supports
+ * master volume control. AudioFlinger will query this value from the
+ * primary audio HAL when the service starts and use the value for setting
+ * the initial master volume across all HALs. HALs which do not support
+ * this method may leave it set to NULL.
+ */
+ int (*get_master_volume)(struct audio_hw_device* dev, float* volume);
+
+ /**
+ * set_mode is called when the audio mode changes. AUDIO_MODE_NORMAL mode
+ * is for standard audio playback, AUDIO_MODE_RINGTONE when a ringtone is
+ * playing, and AUDIO_MODE_IN_CALL when a call is in progress.
+ */
+ int (*set_mode)(struct audio_hw_device* dev, audio_mode_t mode);
+
+ /* mic mute */
+ int (*set_mic_mute)(struct audio_hw_device* dev, bool state);
+ int (*get_mic_mute)(const struct audio_hw_device* dev, bool* state);
+
+ /* set/get global audio parameters */
+ int (*set_parameters)(struct audio_hw_device* dev, const char* kv_pairs);
+
+ /*
+ * Returns a pointer to a heap allocated string. The caller is responsible
+ * for freeing the memory for it using free().
+ */
+ char* (*get_parameters)(const struct audio_hw_device* dev, const char* keys);
+
+ /* Returns audio input buffer size according to parameters passed or
+ * 0 if one of the parameters is not supported.
+ * See also get_buffer_size which is for a particular stream.
+ */
+ size_t (*get_input_buffer_size)(const struct audio_hw_device* dev,
+ const struct audio_config* config);
+
+ /** This method creates and opens the audio hardware output stream.
+ * The "address" parameter qualifies the "devices" audio device type if needed.
+ * The format format depends on the device type:
+ * - Bluetooth devices use the MAC address of the device in the form "00:11:22:AA:BB:CC"
+ * - USB devices use the ALSA card and device numbers in the form "card=X;device=Y"
+ * - Other devices may use a number or any other string.
+ */
+
+ 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,
+ const char* address);
+
+ void (*close_output_stream)(struct audio_hw_device* dev, 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, audio_io_handle_t handle,
+ audio_devices_t devices, struct audio_config* config,
+ struct audio_stream_in** stream_in, audio_input_flags_t flags,
+ const char* address, audio_source_t source);
+
+ void (*close_input_stream)(struct audio_hw_device* dev, 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);
+
+ /**
+ * set the audio mute status for all audio activities. If any value other
+ * than 0 is returned, the software mixer will emulate this capability.
+ */
+ int (*set_master_mute)(struct audio_hw_device* dev, bool mute);
+
+ /**
+ * Get the current master mute status for the HAL, if the HAL supports
+ * master mute control. AudioFlinger will query this value from the primary
+ * audio HAL when the service starts and use the value for setting the
+ * initial master mute across all HALs. HALs which do not support this
+ * method may leave it set to NULL.
+ */
+ int (*get_master_mute)(struct audio_hw_device* dev, bool* mute);
+
+ /**
+ * Routing control
+ */
+
+ /* Creates an audio patch between several source and sink ports.
+ * The handle is allocated by the HAL and should be unique for this
+ * audio HAL module. */
+ int (*create_audio_patch)(struct audio_hw_device* dev, unsigned int num_sources,
+ const struct audio_port_config* sources, unsigned int num_sinks,
+ const struct audio_port_config* sinks, audio_patch_handle_t* handle);
+
+ /* Release an audio patch */
+ int (*release_audio_patch)(struct audio_hw_device* dev, audio_patch_handle_t handle);
+
+ /* Fills the list of supported attributes for a given audio port.
+ * As input, "port" contains the information (type, role, address etc...)
+ * needed by the HAL to identify the port.
+ * As output, "port" contains possible attributes (sampling rates, formats,
+ * channel masks, gain controllers...) for this port.
+ */
+ int (*get_audio_port)(struct audio_hw_device* dev, struct audio_port* port);
+
+ /* Set audio port configuration */
+ int (*set_audio_port_config)(struct audio_hw_device* dev,
+ const struct audio_port_config* config);
+};
+typedef struct audio_hw_device audio_hw_device_t;
+
+/** convenience API for opening and closing a supported device */
+
+static inline int audio_hw_device_open(const struct hw_module_t* module,
+ struct audio_hw_device** device) {
+ return module->methods->open(module, AUDIO_HARDWARE_INTERFACE, TO_HW_DEVICE_T_OPEN(device));
+}
+
+static inline int audio_hw_device_close(struct audio_hw_device* device) {
+ return device->common.close(&device->common);
+}
+
+__END_DECLS
+
+#endif // ANDROID_AUDIO_INTERFACE_H
diff --git a/audio/common/all-versions/legacy/include/hardware/audio_alsaops.h b/audio/common/all-versions/legacy/include/hardware/audio_alsaops.h
new file mode 100644
index 0000000..aa16654
--- /dev/null
+++ b/audio/common/all-versions/legacy/include/hardware/audio_alsaops.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* This file contains shared utility functions to handle the tinyalsa
+ * implementation for Android internal audio, generally in the hardware layer.
+ * Some routines may log a fatal error on failure, as noted.
+ */
+
+#ifndef ANDROID_AUDIO_ALSAOPS_H
+#define ANDROID_AUDIO_ALSAOPS_H
+
+#include <log/log.h>
+
+#include <system/audio.h>
+#include <tinyalsa/asoundlib.h>
+
+__BEGIN_DECLS
+
+/* Converts audio_format to pcm_format.
+ * Parameters:
+ * format the audio_format_t to convert
+ *
+ * Logs a fatal error if format is not a valid convertible audio_format_t.
+ */
+static inline enum pcm_format pcm_format_from_audio_format(audio_format_t format) {
+ switch (format) {
+#if HAVE_BIG_ENDIAN
+ case AUDIO_FORMAT_PCM_16_BIT:
+ return PCM_FORMAT_S16_BE;
+ case AUDIO_FORMAT_PCM_24_BIT_PACKED:
+ return PCM_FORMAT_S24_3BE;
+ case AUDIO_FORMAT_PCM_32_BIT:
+ return PCM_FORMAT_S32_BE;
+ case AUDIO_FORMAT_PCM_8_24_BIT:
+ return PCM_FORMAT_S24_BE;
+#else
+ case AUDIO_FORMAT_PCM_16_BIT:
+ return PCM_FORMAT_S16_LE;
+ case AUDIO_FORMAT_PCM_24_BIT_PACKED:
+ return PCM_FORMAT_S24_3LE;
+ case AUDIO_FORMAT_PCM_32_BIT:
+ return PCM_FORMAT_S32_LE;
+ case AUDIO_FORMAT_PCM_8_24_BIT:
+ return PCM_FORMAT_S24_LE;
+#endif
+ case AUDIO_FORMAT_PCM_FLOAT: /* there is no equivalent for float */
+ default:
+ LOG_ALWAYS_FATAL("pcm_format_from_audio_format: invalid audio format %#x", format);
+ return 0;
+ }
+}
+
+/* Converts pcm_format to audio_format.
+ * Parameters:
+ * format the pcm_format to convert
+ *
+ * Logs a fatal error if format is not a valid convertible pcm_format.
+ */
+static inline audio_format_t audio_format_from_pcm_format(enum pcm_format format) {
+ switch (format) {
+#if HAVE_BIG_ENDIAN
+ case PCM_FORMAT_S16_BE:
+ return AUDIO_FORMAT_PCM_16_BIT;
+ case PCM_FORMAT_S24_3BE:
+ return AUDIO_FORMAT_PCM_24_BIT_PACKED;
+ case PCM_FORMAT_S24_BE:
+ return AUDIO_FORMAT_PCM_8_24_BIT;
+ case PCM_FORMAT_S32_BE:
+ return AUDIO_FORMAT_PCM_32_BIT;
+#else
+ case PCM_FORMAT_S16_LE:
+ return AUDIO_FORMAT_PCM_16_BIT;
+ case PCM_FORMAT_S24_3LE:
+ return AUDIO_FORMAT_PCM_24_BIT_PACKED;
+ case PCM_FORMAT_S24_LE:
+ return AUDIO_FORMAT_PCM_8_24_BIT;
+ case PCM_FORMAT_S32_LE:
+ return AUDIO_FORMAT_PCM_32_BIT;
+#endif
+ default:
+ LOG_ALWAYS_FATAL("audio_format_from_pcm_format: invalid pcm format %#x", format);
+ return 0;
+ }
+}
+
+__END_DECLS
+
+#endif /* ANDROID_AUDIO_ALSAOPS_H */
diff --git a/audio/common/all-versions/legacy/include/hardware/audio_effect.h b/audio/common/all-versions/legacy/include/hardware/audio_effect.h
new file mode 100644
index 0000000..b91c60a
--- /dev/null
+++ b/audio/common/all-versions/legacy/include/hardware/audio_effect.h
@@ -0,0 +1,295 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_AUDIO_EFFECT_H
+#define ANDROID_AUDIO_EFFECT_H
+
+#include <errno.h>
+#include <stdint.h>
+#include <strings.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#include <cutils/bitops.h>
+
+#include <system/audio_effect.h>
+
+__BEGIN_DECLS
+
+/////////////////////////////////////////////////
+// Common Definitions
+/////////////////////////////////////////////////
+
+#define EFFECT_MAKE_API_VERSION(M, m) (((M) << 16) | ((m)&0xFFFF))
+#define EFFECT_API_VERSION_MAJOR(v) ((v) >> 16)
+#define EFFECT_API_VERSION_MINOR(v) ((m)&0xFFFF)
+
+/////////////////////////////////////////////////
+// Effect control interface
+/////////////////////////////////////////////////
+
+// Effect control interface version 2.0
+#define EFFECT_CONTROL_API_VERSION EFFECT_MAKE_API_VERSION(2, 0)
+
+// Effect control interface structure: effect_interface_s
+// The effect control interface is exposed by each effect engine implementation. It consists of
+// a set of functions controlling the configuration, activation and process of the engine.
+// The functions are grouped in a structure of type effect_interface_s.
+//
+// Effect control interface handle: effect_handle_t
+// The effect_handle_t serves two purposes regarding the implementation of the effect engine:
+// - 1 it is the address of a pointer to an effect_interface_s structure where the functions
+// of the effect control API for a particular effect are located.
+// - 2 it is the address of the context of a particular effect instance.
+// A typical implementation in the effect library would define a structure as follows:
+// struct effect_module_s {
+// const struct effect_interface_s *itfe;
+// effect_config_t config;
+// effect_context_t context;
+// }
+// The implementation of EffectCreate() function would then allocate a structure of this
+// type and return its address as effect_handle_t
+typedef struct effect_interface_s** effect_handle_t;
+
+// Effect control interface definition
+struct effect_interface_s {
+ ////////////////////////////////////////////////////////////////////////////////
+ //
+ // Function: process
+ //
+ // Description: Effect process function. Takes input samples as specified
+ // (count and location) in input buffer descriptor and output processed
+ // samples as specified in output buffer descriptor. If the buffer descriptor
+ // is not specified the function must use either the buffer or the
+ // buffer provider function installed by the EFFECT_CMD_SET_CONFIG command.
+ // The effect framework will call the process() function after the EFFECT_CMD_ENABLE
+ // command is received and until the EFFECT_CMD_DISABLE is received. When the engine
+ // receives the EFFECT_CMD_DISABLE command it should turn off the effect gracefully
+ // and when done indicate that it is OK to stop calling the process() function by
+ // returning the -ENODATA status.
+ //
+ // NOTE: the process() function implementation should be "real-time safe" that is
+ // it should not perform blocking calls: malloc/free, sleep, read/write/open/close,
+ // pthread_cond_wait/pthread_mutex_lock...
+ //
+ // Input:
+ // self: handle to the effect interface this function
+ // is called on.
+ // inBuffer: buffer descriptor indicating where to read samples to process.
+ // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command.
+ //
+ // outBuffer: buffer descriptor indicating where to write processed samples.
+ // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG command.
+ //
+ // Output:
+ // returned value: 0 successful operation
+ // -ENODATA the engine has finished the disable phase and the framework
+ // can stop calling process()
+ // -EINVAL invalid interface handle or
+ // invalid input/output buffer description
+ ////////////////////////////////////////////////////////////////////////////////
+ int32_t (*process)(effect_handle_t self, audio_buffer_t* inBuffer, audio_buffer_t* outBuffer);
+ ////////////////////////////////////////////////////////////////////////////////
+ //
+ // Function: command
+ //
+ // Description: Send a command and receive a response to/from effect engine.
+ //
+ // Input:
+ // self: handle to the effect interface this function
+ // is called on.
+ // cmdCode: command code: the command can be a standardized command defined in
+ // effect_command_e (see below) or a proprietary command.
+ // cmdSize: size of command in bytes
+ // pCmdData: pointer to command data
+ // pReplyData: pointer to reply data
+ //
+ // Input/Output:
+ // replySize: maximum size of reply data as input
+ // actual size of reply data as output
+ //
+ // Output:
+ // returned value: 0 successful operation
+ // -EINVAL invalid interface handle or
+ // invalid command/reply size or format according to
+ // command code
+ // The return code should be restricted to indicate problems related to this API
+ // specification. Status related to the execution of a particular command should be
+ // indicated as part of the reply field.
+ //
+ // *pReplyData updated with command response
+ //
+ ////////////////////////////////////////////////////////////////////////////////
+ int32_t (*command)(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize, void* pCmdData,
+ uint32_t* replySize, void* pReplyData);
+ ////////////////////////////////////////////////////////////////////////////////
+ //
+ // Function: get_descriptor
+ //
+ // Description: Returns the effect descriptor
+ //
+ // Input:
+ // self: handle to the effect interface this function
+ // is called on.
+ //
+ // Input/Output:
+ // pDescriptor: address where to return the effect descriptor.
+ //
+ // Output:
+ // returned value: 0 successful operation.
+ // -EINVAL invalid interface handle or invalid pDescriptor
+ // *pDescriptor: updated with the effect descriptor.
+ //
+ ////////////////////////////////////////////////////////////////////////////////
+ int32_t (*get_descriptor)(effect_handle_t self, effect_descriptor_t* pDescriptor);
+ ////////////////////////////////////////////////////////////////////////////////
+ //
+ // Function: process_reverse
+ //
+ // Description: Process reverse stream function. This function is used to pass
+ // a reference stream to the effect engine. If the engine does not need a reference
+ // stream, this function pointer can be set to NULL.
+ // This function would typically implemented by an Echo Canceler.
+ //
+ // Input:
+ // self: handle to the effect interface this function
+ // is called on.
+ // inBuffer: buffer descriptor indicating where to read samples to process.
+ // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command.
+ //
+ // outBuffer: buffer descriptor indicating where to write processed samples.
+ // If NULL, use the configuration passed by EFFECT_CMD_SET_CONFIG_REVERSE command.
+ // If the buffer and buffer provider in the configuration received by
+ // EFFECT_CMD_SET_CONFIG_REVERSE are also NULL, do not return modified reverse
+ // stream data
+ //
+ // Output:
+ // returned value: 0 successful operation
+ // -ENODATA the engine has finished the disable phase and the framework
+ // can stop calling process_reverse()
+ // -EINVAL invalid interface handle or
+ // invalid input/output buffer description
+ ////////////////////////////////////////////////////////////////////////////////
+ int32_t (*process_reverse)(effect_handle_t self, audio_buffer_t* inBuffer,
+ audio_buffer_t* outBuffer);
+};
+
+/////////////////////////////////////////////////
+// Effect library interface
+/////////////////////////////////////////////////
+
+// Effect library interface version 3.0
+// Note that EffectsFactory.c only checks the major version component, so changes to the minor
+// number can only be used for fully backwards compatible changes
+#define EFFECT_LIBRARY_API_VERSION EFFECT_MAKE_API_VERSION(3, 0)
+
+#define AUDIO_EFFECT_LIBRARY_TAG ((('A') << 24) | (('E') << 16) | (('L') << 8) | ('T'))
+
+// Every effect library must have a data structure named AUDIO_EFFECT_LIBRARY_INFO_SYM
+// and the fields of this data structure must begin with audio_effect_library_t
+
+typedef struct audio_effect_library_s {
+ // tag must be initialized to AUDIO_EFFECT_LIBRARY_TAG
+ uint32_t tag;
+ // Version of the effect library API : 0xMMMMmmmm MMMM: Major, mmmm: minor
+ uint32_t version;
+ // Name of this library
+ const char* name;
+ // Author/owner/implementor of the library
+ const char* implementor;
+
+ ////////////////////////////////////////////////////////////////////////////////
+ //
+ // Function: create_effect
+ //
+ // Description: Creates an effect engine of the specified implementation uuid and
+ // returns an effect control interface on this engine. The function will allocate the
+ // resources for an instance of the requested effect engine and return
+ // a handle on the effect control interface.
+ //
+ // Input:
+ // uuid: pointer to the effect uuid.
+ // sessionId: audio session to which this effect instance will be attached.
+ // All effects created with the same session ID are connected in series and process
+ // the same signal stream. Knowing that two effects are part of the same effect
+ // chain can help the library implement some kind of optimizations.
+ // ioId: identifies the output or input stream this effect is directed to in
+ // audio HAL.
+ // For future use especially with tunneled HW accelerated effects
+ //
+ // Input/Output:
+ // pHandle: address where to return the effect interface handle.
+ //
+ // Output:
+ // returned value: 0 successful operation.
+ // -ENODEV library failed to initialize
+ // -EINVAL invalid pEffectUuid or pHandle
+ // -ENOENT no effect with this uuid found
+ // *pHandle: updated with the effect interface handle.
+ //
+ ////////////////////////////////////////////////////////////////////////////////
+ int32_t (*create_effect)(const effect_uuid_t* uuid, int32_t sessionId, int32_t ioId,
+ effect_handle_t* pHandle);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ //
+ // Function: release_effect
+ //
+ // Description: Releases the effect engine whose handle is given as argument.
+ // All resources allocated to this particular instance of the effect are
+ // released.
+ //
+ // Input:
+ // handle: handle on the effect interface to be released.
+ //
+ // Output:
+ // returned value: 0 successful operation.
+ // -ENODEV library failed to initialize
+ // -EINVAL invalid interface handle
+ //
+ ////////////////////////////////////////////////////////////////////////////////
+ int32_t (*release_effect)(effect_handle_t handle);
+
+ ////////////////////////////////////////////////////////////////////////////////
+ //
+ // Function: get_descriptor
+ //
+ // Description: Returns the descriptor of the effect engine which implementation UUID is
+ // given as argument.
+ //
+ // Input/Output:
+ // uuid: pointer to the effect uuid.
+ // pDescriptor: address where to return the effect descriptor.
+ //
+ // Output:
+ // returned value: 0 successful operation.
+ // -ENODEV library failed to initialize
+ // -EINVAL invalid pDescriptor or uuid
+ // *pDescriptor: updated with the effect descriptor.
+ //
+ ////////////////////////////////////////////////////////////////////////////////
+ int32_t (*get_descriptor)(const effect_uuid_t* uuid, effect_descriptor_t* pDescriptor);
+} audio_effect_library_t;
+
+// Name of the hal_module_info
+#define AUDIO_EFFECT_LIBRARY_INFO_SYM AELI
+
+// Name of the hal_module_info as a string
+#define AUDIO_EFFECT_LIBRARY_INFO_SYM_AS_STR "AELI"
+
+__END_DECLS
+
+#endif // ANDROID_AUDIO_EFFECT_H
diff --git a/audio/common/all-versions/legacy/include/hardware/audio_policy.h b/audio/common/all-versions/legacy/include/hardware/audio_policy.h
new file mode 100644
index 0000000..8cc79df
--- /dev/null
+++ b/audio/common/all-versions/legacy/include/hardware/audio_policy.h
@@ -0,0 +1,391 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_AUDIO_POLICY_INTERFACE_H
+#define ANDROID_AUDIO_POLICY_INTERFACE_H
+
+#include <stdint.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#include <hardware/hardware.h>
+
+#include <system/audio.h>
+#include <system/audio_policy.h>
+
+__BEGIN_DECLS
+
+/**
+ * The id of this module
+ */
+#define AUDIO_POLICY_HARDWARE_MODULE_ID "audio_policy"
+
+/**
+ * Name of the audio devices to open
+ */
+#define AUDIO_POLICY_INTERFACE "policy"
+
+/* ---------------------------------------------------------------------------- */
+
+/*
+ * The audio_policy and audio_policy_service_ops structs define the
+ * communication interfaces between the platform specific audio policy manager
+ * and Android generic audio policy manager.
+ * The platform specific audio policy manager must implement methods of the
+ * audio_policy struct.
+ * This implementation makes use of the audio_policy_service_ops to control
+ * the activity and configuration of audio input and output streams.
+ *
+ * The platform specific audio policy manager is in charge of the audio
+ * routing and volume control policies for a given platform.
+ * The main roles of this module are:
+ * - keep track of current system state (removable device connections, phone
+ * state, user requests...).
+ * System state changes and user actions are notified to audio policy
+ * manager with methods of the audio_policy.
+ *
+ * - process get_output() queries received when AudioTrack objects are
+ * created: Those queries return a handler on an output that has been
+ * selected, configured and opened by the audio policy manager and that
+ * must be used by the AudioTrack when registering to the AudioFlinger
+ * with the createTrack() method.
+ * When the AudioTrack object is released, a release_output() query
+ * is received and the audio policy manager can decide to close or
+ * reconfigure the output depending on other streams using this output and
+ * current system state.
+ *
+ * - similarly process get_input() and release_input() queries received from
+ * AudioRecord objects and configure audio inputs.
+ * - process volume control requests: the stream volume is converted from
+ * an index value (received from UI) to a float value applicable to each
+ * output as a function of platform specific settings and current output
+ * route (destination device). It also make sure that streams are not
+ * muted if not allowed (e.g. camera shutter sound in some countries).
+ */
+
+/* XXX: this should be defined OUTSIDE of frameworks/base */
+struct effect_descriptor_s;
+
+struct audio_policy {
+ /*
+ * configuration functions
+ */
+
+ /* indicate a change in device connection status */
+ int (*set_device_connection_state)(struct audio_policy* pol, audio_devices_t device,
+ audio_policy_dev_state_t state, const char* device_address);
+
+ /* retrieve a device connection status */
+ audio_policy_dev_state_t (*get_device_connection_state)(const struct audio_policy* pol,
+ audio_devices_t device,
+ const char* device_address);
+
+ /* indicate a change in phone state. Valid phones states are defined
+ * by audio_mode_t */
+ void (*set_phone_state)(struct audio_policy* pol, audio_mode_t state);
+
+ /* deprecated, never called (was "indicate a change in ringer mode") */
+ void (*set_ringer_mode)(struct audio_policy* pol, uint32_t mode, uint32_t mask);
+
+ /* force using a specific device category for the specified usage */
+ void (*set_force_use)(struct audio_policy* pol, audio_policy_force_use_t usage,
+ audio_policy_forced_cfg_t config);
+
+ /* retrieve current device category forced for a given usage */
+ audio_policy_forced_cfg_t (*get_force_use)(const struct audio_policy* pol,
+ audio_policy_force_use_t usage);
+
+ /* if can_mute is true, then audio streams that are marked ENFORCED_AUDIBLE
+ * can still be muted. */
+ void (*set_can_mute_enforced_audible)(struct audio_policy* pol, bool can_mute);
+
+ /* check proper initialization */
+ int (*init_check)(const struct audio_policy* pol);
+
+ /*
+ * Audio routing query functions
+ */
+
+ /* request an output appropriate for playback of the supplied stream type and
+ * parameters */
+ audio_io_handle_t (*get_output)(struct audio_policy* pol, audio_stream_type_t stream,
+ uint32_t samplingRate, audio_format_t format,
+ audio_channel_mask_t channelMask, audio_output_flags_t flags,
+ const audio_offload_info_t* offloadInfo);
+
+ /* indicates to the audio policy manager that the output starts being used
+ * by corresponding stream. */
+ int (*start_output)(struct audio_policy* pol, audio_io_handle_t output,
+ audio_stream_type_t stream, audio_session_t session);
+
+ /* indicates to the audio policy manager that the output stops being used
+ * by corresponding stream. */
+ int (*stop_output)(struct audio_policy* pol, audio_io_handle_t output,
+ audio_stream_type_t stream, audio_session_t session);
+
+ /* releases the output. */
+ void (*release_output)(struct audio_policy* pol, audio_io_handle_t output);
+
+ /* request an input appropriate for record from the supplied device with
+ * supplied parameters. */
+ audio_io_handle_t (*get_input)(struct audio_policy* pol, audio_source_t inputSource,
+ uint32_t samplingRate, audio_format_t format,
+ audio_channel_mask_t channelMask,
+ audio_in_acoustics_t acoustics);
+
+ /* indicates to the audio policy manager that the input starts being used */
+ int (*start_input)(struct audio_policy* pol, audio_io_handle_t input);
+
+ /* indicates to the audio policy manager that the input stops being used. */
+ int (*stop_input)(struct audio_policy* pol, audio_io_handle_t input);
+
+ /* releases the input. */
+ void (*release_input)(struct audio_policy* pol, audio_io_handle_t input);
+
+ /*
+ * volume control functions
+ */
+
+ /* initialises stream volume conversion parameters by specifying volume
+ * index range. The index range for each stream is defined by AudioService. */
+ void (*init_stream_volume)(struct audio_policy* pol, audio_stream_type_t stream, int index_min,
+ int index_max);
+
+ /* sets the new stream volume at a level corresponding to the supplied
+ * index. The index is within the range specified by init_stream_volume() */
+ int (*set_stream_volume_index)(struct audio_policy* pol, audio_stream_type_t stream, int index);
+
+ /* retrieve current volume index for the specified stream */
+ int (*get_stream_volume_index)(const struct audio_policy* pol, audio_stream_type_t stream,
+ int* index);
+
+ /* sets the new stream volume at a level corresponding to the supplied
+ * index for the specified device.
+ * The index is within the range specified by init_stream_volume() */
+ int (*set_stream_volume_index_for_device)(struct audio_policy* pol, audio_stream_type_t stream,
+ int index, audio_devices_t device);
+
+ /* retrieve current volume index for the specified stream for the specified device */
+ int (*get_stream_volume_index_for_device)(const struct audio_policy* pol,
+ audio_stream_type_t stream, int* index,
+ audio_devices_t device);
+
+ /* return the strategy corresponding to a given stream type */
+ uint32_t (*get_strategy_for_stream)(const struct audio_policy* pol, audio_stream_type_t stream);
+
+ /* return the enabled output devices for the given stream type */
+ audio_devices_t (*get_devices_for_stream)(const struct audio_policy* pol,
+ audio_stream_type_t stream);
+
+ /* Audio effect management */
+ audio_io_handle_t (*get_output_for_effect)(struct audio_policy* pol,
+ const struct effect_descriptor_s* desc);
+
+ int (*register_effect)(struct audio_policy* pol, const struct effect_descriptor_s* desc,
+ audio_io_handle_t output, uint32_t strategy, audio_session_t session,
+ int id);
+
+ int (*unregister_effect)(struct audio_policy* pol, int id);
+
+ int (*set_effect_enabled)(struct audio_policy* pol, int id, bool enabled);
+
+ bool (*is_stream_active)(const struct audio_policy* pol, audio_stream_type_t stream,
+ uint32_t in_past_ms);
+
+ bool (*is_stream_active_remotely)(const struct audio_policy* pol, audio_stream_type_t stream,
+ uint32_t in_past_ms);
+
+ bool (*is_source_active)(const struct audio_policy* pol, audio_source_t source);
+
+ /* dump state */
+ int (*dump)(const struct audio_policy* pol, int fd);
+
+ /* check if offload is possible for given sample rate, bitrate, duration, ... */
+ bool (*is_offload_supported)(const struct audio_policy* pol, const audio_offload_info_t* info);
+};
+
+struct audio_policy_service_ops {
+ /*
+ * Audio output Control functions
+ */
+
+ /* Opens an audio output with the requested parameters.
+ *
+ * The parameter values can indicate to use the default values in case the
+ * audio policy manager has no specific requirements for the output being
+ * opened.
+ *
+ * When the function returns, the parameter values reflect the actual
+ * values used by the audio hardware output stream.
+ *
+ * The audio policy manager can check if the proposed parameters are
+ * suitable or not and act accordingly.
+ */
+ audio_io_handle_t (*open_output)(void* service, audio_devices_t* pDevices,
+ uint32_t* pSamplingRate, audio_format_t* pFormat,
+ audio_channel_mask_t* pChannelMask, uint32_t* pLatencyMs,
+ audio_output_flags_t flags);
+
+ /* creates a special output that is duplicated to the two outputs passed as
+ * arguments. The duplication is performed by
+ * a special mixer thread in the AudioFlinger.
+ */
+ audio_io_handle_t (*open_duplicate_output)(void* service, audio_io_handle_t output1,
+ audio_io_handle_t output2);
+
+ /* closes the output stream */
+ int (*close_output)(void* service, audio_io_handle_t output);
+
+ /* suspends the output.
+ *
+ * When an output is suspended, the corresponding audio hardware output
+ * stream is placed in standby and the AudioTracks attached to the mixer
+ * thread are still processed but the output mix is discarded.
+ */
+ int (*suspend_output)(void* service, audio_io_handle_t output);
+
+ /* restores a suspended output. */
+ int (*restore_output)(void* service, audio_io_handle_t output);
+
+ /* */
+ /* Audio input Control functions */
+ /* */
+
+ /* opens an audio input
+ * deprecated - new implementations should use open_input_on_module,
+ * and the acoustics parameter is ignored
+ */
+ audio_io_handle_t (*open_input)(void* service, audio_devices_t* pDevices,
+ uint32_t* pSamplingRate, audio_format_t* pFormat,
+ audio_channel_mask_t* pChannelMask,
+ audio_in_acoustics_t acoustics);
+
+ /* closes an audio input */
+ int (*close_input)(void* service, audio_io_handle_t input);
+
+ /* */
+ /* misc control functions */
+ /* */
+
+ /* set a stream volume for a particular output.
+ *
+ * For the same user setting, a given stream type can have different
+ * volumes for each output (destination device) it is attached to.
+ */
+ int (*set_stream_volume)(void* service, audio_stream_type_t stream, float volume,
+ audio_io_handle_t output, int delay_ms);
+
+ /* invalidate a stream type, causing a reroute to an unspecified new output */
+ int (*invalidate_stream)(void* service, audio_stream_type_t stream);
+
+ /* function enabling to send proprietary informations directly from audio
+ * policy manager to audio hardware interface. */
+ void (*set_parameters)(void* service, audio_io_handle_t io_handle, const char* kv_pairs,
+ int delay_ms);
+
+ /* function enabling to receive proprietary informations directly from
+ * audio hardware interface to audio policy manager.
+ *
+ * Returns a pointer to a heap allocated string. The caller is responsible
+ * for freeing the memory for it using free().
+ */
+
+ char* (*get_parameters)(void* service, audio_io_handle_t io_handle, const char* keys);
+
+ /* request the playback of a tone on the specified stream.
+ * used for instance to replace notification sounds when playing over a
+ * telephony device during a phone call.
+ */
+ int (*start_tone)(void* service, audio_policy_tone_t tone, audio_stream_type_t stream);
+
+ int (*stop_tone)(void* service);
+
+ /* set down link audio volume. */
+ int (*set_voice_volume)(void* service, float volume, int delay_ms);
+
+ /* move effect to the specified output */
+ int (*move_effects)(void* service, audio_session_t session, audio_io_handle_t src_output,
+ audio_io_handle_t dst_output);
+
+ /* loads an audio hw module.
+ *
+ * The module name passed is the base name of the HW module library, e.g "primary" or "a2dp".
+ * The function returns a handle on the module that will be used to specify a particular
+ * module when calling open_output_on_module() or open_input_on_module()
+ */
+ audio_module_handle_t (*load_hw_module)(void* service, const char* name);
+
+ /* Opens an audio output on a particular HW module.
+ *
+ * Same as open_output() but specifying a specific HW module on which the output must be opened.
+ */
+ audio_io_handle_t (*open_output_on_module)(void* service, audio_module_handle_t module,
+ audio_devices_t* pDevices, uint32_t* pSamplingRate,
+ audio_format_t* pFormat,
+ audio_channel_mask_t* pChannelMask,
+ uint32_t* pLatencyMs, audio_output_flags_t flags,
+ const audio_offload_info_t* offloadInfo);
+
+ /* Opens an audio input on a particular HW module.
+ *
+ * Same as open_input() but specifying a specific HW module on which the input must be opened.
+ * Also removed deprecated acoustics parameter
+ */
+ audio_io_handle_t (*open_input_on_module)(void* service, audio_module_handle_t module,
+ audio_devices_t* pDevices, uint32_t* pSamplingRate,
+ audio_format_t* pFormat,
+ audio_channel_mask_t* pChannelMask);
+};
+
+/**********************************************************************/
+
+/**
+ * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
+ * and the fields of this data structure must begin with hw_module_t
+ * followed by module specific information.
+ */
+typedef struct audio_policy_module { struct hw_module_t common; } audio_policy_module_t;
+
+struct audio_policy_device {
+ /**
+ * Common methods of the audio policy device. This *must* be the first member of
+ * audio_policy_device as users of this structure will cast a hw_device_t to
+ * audio_policy_device pointer in contexts where it's known the hw_device_t references an
+ * audio_policy_device.
+ */
+ struct hw_device_t common;
+
+ int (*create_audio_policy)(const struct audio_policy_device* device,
+ struct audio_policy_service_ops* aps_ops, void* service,
+ struct audio_policy** ap);
+
+ int (*destroy_audio_policy)(const struct audio_policy_device* device, struct audio_policy* ap);
+};
+
+/** convenience API for opening and closing a supported device */
+
+static inline int audio_policy_dev_open(const hw_module_t* module,
+ struct audio_policy_device** device) {
+ return module->methods->open(module, AUDIO_POLICY_INTERFACE, (hw_device_t**)device);
+}
+
+static inline int audio_policy_dev_close(struct audio_policy_device* device) {
+ return device->common.close(&device->common);
+}
+
+__END_DECLS
+
+#endif // ANDROID_AUDIO_POLICY_INTERFACE_H
diff --git a/audio/common/all-versions/legacy/include/system/audio.h b/audio/common/all-versions/legacy/include/system/audio.h
new file mode 100644
index 0000000..7afa6c4
--- /dev/null
+++ b/audio/common/all-versions/legacy/include/system/audio.h
@@ -0,0 +1,1038 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_AUDIO_CORE_H
+#define ANDROID_AUDIO_CORE_H
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#include <cutils/bitops.h>
+
+#include "system/audio-base.h"
+
+__BEGIN_DECLS
+
+/* The enums were moved here mostly from
+ * frameworks/base/include/media/AudioSystem.h
+ */
+
+/* represents an invalid uid for tracks; the calling or client uid is often substituted. */
+#define AUDIO_UID_INVALID ((uid_t)-1)
+
+/* device address used to refer to the standard remote submix */
+#define AUDIO_REMOTE_SUBMIX_DEVICE_ADDRESS "0"
+
+/* AudioFlinger and AudioPolicy services use I/O handles to identify audio sources and sinks */
+typedef int audio_io_handle_t;
+
+/* Do not change these values without updating their counterparts
+ * in frameworks/base/media/java/android/media/AudioAttributes.java
+ */
+typedef enum {
+ AUDIO_CONTENT_TYPE_UNKNOWN = 0,
+ AUDIO_CONTENT_TYPE_SPEECH = 1,
+ AUDIO_CONTENT_TYPE_MUSIC = 2,
+ AUDIO_CONTENT_TYPE_MOVIE = 3,
+ AUDIO_CONTENT_TYPE_SONIFICATION = 4,
+
+ AUDIO_CONTENT_TYPE_CNT,
+ AUDIO_CONTENT_TYPE_MAX = AUDIO_CONTENT_TYPE_CNT - 1,
+} audio_content_type_t;
+
+typedef uint32_t audio_flags_mask_t;
+
+/* Do not change these values without updating their counterparts
+ * in frameworks/base/media/java/android/media/AudioAttributes.java
+ */
+enum {
+ AUDIO_FLAG_NONE = 0x0,
+ AUDIO_FLAG_AUDIBILITY_ENFORCED = 0x1,
+ AUDIO_FLAG_SECURE = 0x2,
+ AUDIO_FLAG_SCO = 0x4,
+ AUDIO_FLAG_BEACON = 0x8,
+ AUDIO_FLAG_HW_AV_SYNC = 0x10,
+ AUDIO_FLAG_HW_HOTWORD = 0x20,
+ AUDIO_FLAG_BYPASS_INTERRUPTION_POLICY = 0x40,
+ AUDIO_FLAG_BYPASS_MUTE = 0x80,
+ AUDIO_FLAG_LOW_LATENCY = 0x100,
+ AUDIO_FLAG_DEEP_BUFFER = 0x200,
+};
+
+/* Audio attributes */
+#define AUDIO_ATTRIBUTES_TAGS_MAX_SIZE 256
+typedef struct {
+ audio_content_type_t content_type;
+ audio_usage_t usage;
+ audio_source_t source;
+ audio_flags_mask_t flags;
+ char tags[AUDIO_ATTRIBUTES_TAGS_MAX_SIZE]; /* UTF8 */
+} __attribute__((packed)) audio_attributes_t; // sent through Binder;
+
+/* a unique ID allocated by AudioFlinger for use as an audio_io_handle_t, audio_session_t,
+ * effect ID (int), audio_module_handle_t, and audio_patch_handle_t.
+ * Audio port IDs (audio_port_handle_t) are allocated by AudioPolicy
+ * in a different namespace than AudioFlinger unique IDs.
+ */
+typedef int audio_unique_id_t;
+
+/* Possible uses for an audio_unique_id_t */
+typedef enum {
+ AUDIO_UNIQUE_ID_USE_UNSPECIFIED = 0,
+ AUDIO_UNIQUE_ID_USE_SESSION = 1, // for allocated sessions, not special AUDIO_SESSION_*
+ AUDIO_UNIQUE_ID_USE_MODULE = 2,
+ AUDIO_UNIQUE_ID_USE_EFFECT = 3,
+ AUDIO_UNIQUE_ID_USE_PATCH = 4,
+ AUDIO_UNIQUE_ID_USE_OUTPUT = 5,
+ AUDIO_UNIQUE_ID_USE_INPUT = 6,
+ AUDIO_UNIQUE_ID_USE_PLAYER = 7,
+ AUDIO_UNIQUE_ID_USE_MAX = 8, // must be a power-of-two
+ AUDIO_UNIQUE_ID_USE_MASK = AUDIO_UNIQUE_ID_USE_MAX - 1
+} audio_unique_id_use_t;
+
+/* Return the use of an audio_unique_id_t */
+static inline audio_unique_id_use_t audio_unique_id_get_use(audio_unique_id_t id) {
+ return (audio_unique_id_use_t)(id & AUDIO_UNIQUE_ID_USE_MASK);
+}
+
+/* Reserved audio_unique_id_t values. FIXME: not a complete list. */
+#define AUDIO_UNIQUE_ID_ALLOCATE AUDIO_SESSION_ALLOCATE
+
+/* A channel mask per se only defines the presence or absence of a channel, not the order.
+ * But see AUDIO_INTERLEAVE_* below for the platform convention of order.
+ *
+ * audio_channel_mask_t is an opaque type and its internal layout should not
+ * be assumed as it may change in the future.
+ * Instead, always use the functions declared in this header to examine.
+ *
+ * These are the current representations:
+ *
+ * AUDIO_CHANNEL_REPRESENTATION_POSITION
+ * is a channel mask representation for position assignment.
+ * Each low-order bit corresponds to the spatial position of a transducer (output),
+ * or interpretation of channel (input).
+ * The user of a channel mask needs to know the context of whether it is for output or input.
+ * The constants AUDIO_CHANNEL_OUT_* or AUDIO_CHANNEL_IN_* apply to the bits portion.
+ * It is not permitted for no bits to be set.
+ *
+ * AUDIO_CHANNEL_REPRESENTATION_INDEX
+ * is a channel mask representation for index assignment.
+ * Each low-order bit corresponds to a selected channel.
+ * There is no platform interpretation of the various bits.
+ * There is no concept of output or input.
+ * It is not permitted for no bits to be set.
+ *
+ * All other representations are reserved for future use.
+ *
+ * Warning: current representation distinguishes between input and output, but this will not the be
+ * case in future revisions of the platform. Wherever there is an ambiguity between input and output
+ * that is currently resolved by checking the channel mask, the implementer should look for ways to
+ * fix it with additional information outside of the mask.
+ */
+typedef uint32_t audio_channel_mask_t;
+
+/* log(2) of maximum number of representations, not part of public API */
+#define AUDIO_CHANNEL_REPRESENTATION_LOG2 2
+
+/* The return value is undefined if the channel mask is invalid. */
+static inline uint32_t audio_channel_mask_get_bits(audio_channel_mask_t channel) {
+ return channel & ((1 << AUDIO_CHANNEL_COUNT_MAX) - 1);
+}
+
+typedef uint32_t audio_channel_representation_t;
+
+/* The return value is undefined if the channel mask is invalid. */
+static inline audio_channel_representation_t audio_channel_mask_get_representation(
+ audio_channel_mask_t channel) {
+ // The right shift should be sufficient, but also "and" for safety in case mask is not 32 bits
+ return (audio_channel_representation_t)((channel >> AUDIO_CHANNEL_COUNT_MAX) &
+ ((1 << AUDIO_CHANNEL_REPRESENTATION_LOG2) - 1));
+}
+
+/* Returns true if the channel mask is valid,
+ * or returns false for AUDIO_CHANNEL_NONE, AUDIO_CHANNEL_INVALID, and other invalid values.
+ * This function is unable to determine whether a channel mask for position assignment
+ * is invalid because an output mask has an invalid output bit set,
+ * or because an input mask has an invalid input bit set.
+ * All other APIs that take a channel mask assume that it is valid.
+ */
+static inline bool audio_channel_mask_is_valid(audio_channel_mask_t channel) {
+ uint32_t bits = audio_channel_mask_get_bits(channel);
+ audio_channel_representation_t representation = audio_channel_mask_get_representation(channel);
+ switch (representation) {
+ case AUDIO_CHANNEL_REPRESENTATION_POSITION:
+ case AUDIO_CHANNEL_REPRESENTATION_INDEX:
+ break;
+ default:
+ bits = 0;
+ break;
+ }
+ return bits != 0;
+}
+
+/* Not part of public API */
+static inline audio_channel_mask_t audio_channel_mask_from_representation_and_bits(
+ audio_channel_representation_t representation, uint32_t bits) {
+ return (audio_channel_mask_t)((representation << AUDIO_CHANNEL_COUNT_MAX) | bits);
+}
+
+/* This enum is deprecated */
+typedef enum {
+ AUDIO_IN_ACOUSTICS_NONE = 0,
+ AUDIO_IN_ACOUSTICS_AGC_ENABLE = 0x0001,
+ AUDIO_IN_ACOUSTICS_AGC_DISABLE = 0,
+ AUDIO_IN_ACOUSTICS_NS_ENABLE = 0x0002,
+ AUDIO_IN_ACOUSTICS_NS_DISABLE = 0,
+ AUDIO_IN_ACOUSTICS_TX_IIR_ENABLE = 0x0004,
+ AUDIO_IN_ACOUSTICS_TX_DISABLE = 0,
+} audio_in_acoustics_t;
+
+typedef uint32_t audio_devices_t;
+/**
+ * Stub audio output device. Used in policy configuration file on platforms without audio outputs.
+ * This alias value to AUDIO_DEVICE_OUT_DEFAULT is only used in the audio policy context.
+ */
+#define AUDIO_DEVICE_OUT_STUB AUDIO_DEVICE_OUT_DEFAULT
+/**
+ * Stub audio input device. Used in policy configuration file on platforms without audio inputs.
+ * This alias value to AUDIO_DEVICE_IN_DEFAULT is only used in the audio policy context.
+ */
+#define AUDIO_DEVICE_IN_STUB AUDIO_DEVICE_IN_DEFAULT
+
+/* Additional information about compressed streams offloaded to
+ * hardware playback
+ * The version and size fields must be initialized by the caller by using
+ * one of the constants defined here.
+ * Must be aligned to transmit as raw memory through Binder.
+ */
+typedef struct {
+ uint16_t version; // version of the info structure
+ uint16_t size; // total size of the structure including version and size
+ uint32_t sample_rate; // sample rate in Hz
+ audio_channel_mask_t channel_mask; // channel mask
+ audio_format_t format; // audio format
+ audio_stream_type_t stream_type; // stream type
+ uint32_t bit_rate; // bit rate in bits per second
+ int64_t duration_us; // duration in microseconds, -1 if unknown
+ bool has_video; // true if stream is tied to a video stream
+ bool is_streaming; // true if streaming, false if local playback
+ uint32_t bit_width;
+ uint32_t offload_buffer_size; // offload fragment size
+ audio_usage_t usage;
+} __attribute__((aligned(8))) audio_offload_info_t;
+
+#define AUDIO_MAKE_OFFLOAD_INFO_VERSION(maj, min) ((((maj)&0xff) << 8) | ((min)&0xff))
+
+#define AUDIO_OFFLOAD_INFO_VERSION_0_1 AUDIO_MAKE_OFFLOAD_INFO_VERSION(0, 1)
+#define AUDIO_OFFLOAD_INFO_VERSION_CURRENT AUDIO_OFFLOAD_INFO_VERSION_0_1
+
+static const audio_offload_info_t AUDIO_INFO_INITIALIZER = {
+ /* .version = */ AUDIO_OFFLOAD_INFO_VERSION_CURRENT,
+ /* .size = */ sizeof(audio_offload_info_t),
+ /* .sample_rate = */ 0,
+ /* .channel_mask = */ 0,
+ /* .format = */ AUDIO_FORMAT_DEFAULT,
+ /* .stream_type = */ AUDIO_STREAM_VOICE_CALL,
+ /* .bit_rate = */ 0,
+ /* .duration_us = */ 0,
+ /* .has_video = */ false,
+ /* .is_streaming = */ false,
+ /* .bit_width = */ 16,
+ /* .offload_buffer_size = */ 0,
+ /* .usage = */ AUDIO_USAGE_UNKNOWN};
+
+/* common audio stream configuration parameters
+ * You should memset() the entire structure to zero before use to
+ * ensure forward compatibility
+ * Must be aligned to transmit as raw memory through Binder.
+ */
+struct __attribute__((aligned(8))) audio_config {
+ uint32_t sample_rate;
+ audio_channel_mask_t channel_mask;
+ audio_format_t format;
+ audio_offload_info_t offload_info;
+ uint32_t frame_count;
+};
+typedef struct audio_config audio_config_t;
+
+static const audio_config_t AUDIO_CONFIG_INITIALIZER = {
+ /* .sample_rate = */ 0,
+ /* .channel_mask = */ AUDIO_CHANNEL_NONE,
+ /* .format = */ AUDIO_FORMAT_DEFAULT,
+ /* .offload_info = */
+ {/* .version = */ AUDIO_OFFLOAD_INFO_VERSION_CURRENT,
+ /* .size = */ sizeof(audio_offload_info_t),
+ /* .sample_rate = */ 0,
+ /* .channel_mask = */ 0,
+ /* .format = */ AUDIO_FORMAT_DEFAULT,
+ /* .stream_type = */ AUDIO_STREAM_VOICE_CALL,
+ /* .bit_rate = */ 0,
+ /* .duration_us = */ 0,
+ /* .has_video = */ false,
+ /* .is_streaming = */ false,
+ /* .bit_width = */ 16,
+ /* .offload_buffer_size = */ 0,
+ /* .usage = */ AUDIO_USAGE_UNKNOWN},
+ /* .frame_count = */ 0,
+};
+
+struct audio_config_base {
+ uint32_t sample_rate;
+ audio_channel_mask_t channel_mask;
+ audio_format_t format;
+};
+
+typedef struct audio_config_base audio_config_base_t;
+
+static const audio_config_base_t AUDIO_CONFIG_BASE_INITIALIZER = {
+ /* .sample_rate = */ 0,
+ /* .channel_mask = */ AUDIO_CHANNEL_NONE,
+ /* .format = */ AUDIO_FORMAT_DEFAULT};
+
+/* audio hw module handle functions or structures referencing a module */
+typedef int audio_module_handle_t;
+
+/******************************
+ * Volume control
+ *****************************/
+
+/** 3 dB headroom are allowed on float samples (3db = 10^(3/20) = 1.412538).
+ * See: https://developer.android.com/reference/android/media/AudioTrack.html#write(float[], int,
+ * int, int)
+ */
+#define FLOAT_NOMINAL_RANGE_HEADROOM 1.412538
+
+/* If the audio hardware supports gain control on some audio paths,
+ * the platform can expose them in the audio_policy.conf file. The audio HAL
+ * will then implement gain control functions that will use the following data
+ * structures. */
+
+typedef uint32_t audio_gain_mode_t;
+
+/* An audio_gain struct is a representation of a gain stage.
+ * A gain stage is always attached to an audio port. */
+struct audio_gain {
+ audio_gain_mode_t mode; /* e.g. AUDIO_GAIN_MODE_JOINT */
+ audio_channel_mask_t channel_mask; /* channels which gain an be controlled.
+ N/A if AUDIO_GAIN_MODE_CHANNELS is not supported */
+ int min_value; /* minimum gain value in millibels */
+ int max_value; /* maximum gain value in millibels */
+ int default_value; /* default gain value in millibels */
+ unsigned int step_value; /* gain step in millibels */
+ unsigned int min_ramp_ms; /* minimum ramp duration in ms */
+ unsigned int max_ramp_ms; /* maximum ramp duration in ms */
+};
+
+/* The gain configuration structure is used to get or set the gain values of a
+ * given port */
+struct audio_gain_config {
+ int index; /* index of the corresponding audio_gain in the
+ audio_port gains[] table */
+ audio_gain_mode_t mode; /* mode requested for this command */
+ audio_channel_mask_t channel_mask; /* channels which gain value follows.
+ N/A in joint mode */
+
+ // note this "8" is not FCC_8, so it won't need to be changed for > 8 channels
+ int values[sizeof(audio_channel_mask_t) * 8]; /* gain values in millibels
+ for each channel ordered from LSb to MSb in
+ channel mask. The number of values is 1 in joint
+ mode or popcount(channel_mask) */
+ unsigned int ramp_duration_ms; /* ramp duration in ms */
+};
+
+/******************************
+ * Routing control
+ *****************************/
+
+/* Types defined here are used to describe an audio source or sink at internal
+ * framework interfaces (audio policy, patch panel) or at the audio HAL.
+ * Sink and sources are grouped in a concept of “audio port” representing an
+ * audio end point at the edge of the system managed by the module exposing
+ * the interface. */
+
+/* Each port has a unique ID or handle allocated by policy manager */
+typedef int audio_port_handle_t;
+
+/* the maximum length for the human-readable device name */
+#define AUDIO_PORT_MAX_NAME_LEN 128
+
+/* maximum audio device address length */
+#define AUDIO_DEVICE_MAX_ADDRESS_LEN 32
+
+/* extension for audio port configuration structure when the audio port is a
+ * hardware device */
+struct audio_port_config_device_ext {
+ audio_module_handle_t hw_module; /* module the device is attached to */
+ audio_devices_t type; /* device type (e.g AUDIO_DEVICE_OUT_SPEAKER) */
+ char address[AUDIO_DEVICE_MAX_ADDRESS_LEN]; /* device address. "" if N/A */
+};
+
+/* extension for audio port configuration structure when the audio port is a
+ * sub mix */
+struct audio_port_config_mix_ext {
+ audio_module_handle_t hw_module; /* module the stream is attached to */
+ audio_io_handle_t handle; /* I/O handle of the input/output stream */
+ union {
+ // TODO: change use case for output streams: use strategy and mixer attributes
+ audio_stream_type_t stream;
+ audio_source_t source;
+ } usecase;
+};
+
+/* extension for audio port configuration structure when the audio port is an
+ * audio session */
+struct audio_port_config_session_ext {
+ audio_session_t session; /* audio session */
+};
+
+/* audio port configuration structure used to specify a particular configuration of
+ * an audio port */
+struct audio_port_config {
+ audio_port_handle_t id; /* port unique ID */
+ audio_port_role_t role; /* sink or source */
+ audio_port_type_t type; /* device, mix ... */
+ unsigned int config_mask; /* e.g AUDIO_PORT_CONFIG_ALL */
+ unsigned int sample_rate; /* sampling rate in Hz */
+ audio_channel_mask_t channel_mask; /* channel mask if applicable */
+ audio_format_t format; /* format if applicable */
+ struct audio_gain_config gain; /* gain to apply if applicable */
+ union {
+ struct audio_port_config_device_ext device; /* device specific info */
+ struct audio_port_config_mix_ext mix; /* mix specific info */
+ struct audio_port_config_session_ext session; /* session specific info */
+ } ext;
+};
+
+/* max number of sampling rates in audio port */
+#define AUDIO_PORT_MAX_SAMPLING_RATES 32
+/* max number of channel masks in audio port */
+#define AUDIO_PORT_MAX_CHANNEL_MASKS 32
+/* max number of audio formats in audio port */
+#define AUDIO_PORT_MAX_FORMATS 32
+/* max number of gain controls in audio port */
+#define AUDIO_PORT_MAX_GAINS 16
+
+/* extension for audio port structure when the audio port is a hardware device */
+struct audio_port_device_ext {
+ audio_module_handle_t hw_module; /* module the device is attached to */
+ audio_devices_t type; /* device type (e.g AUDIO_DEVICE_OUT_SPEAKER) */
+ char address[AUDIO_DEVICE_MAX_ADDRESS_LEN];
+};
+
+/* extension for audio port structure when the audio port is a sub mix */
+struct audio_port_mix_ext {
+ audio_module_handle_t hw_module; /* module the stream is attached to */
+ audio_io_handle_t handle; /* I/O handle of the input.output stream */
+ audio_mix_latency_class_t latency_class; /* latency class */
+ // other attributes: routing strategies
+};
+
+/* extension for audio port structure when the audio port is an audio session */
+struct audio_port_session_ext {
+ audio_session_t session; /* audio session */
+};
+
+struct audio_port {
+ audio_port_handle_t id; /* port unique ID */
+ audio_port_role_t role; /* sink or source */
+ audio_port_type_t type; /* device, mix ... */
+ char name[AUDIO_PORT_MAX_NAME_LEN];
+ unsigned int num_sample_rates; /* number of sampling rates in following array */
+ unsigned int sample_rates[AUDIO_PORT_MAX_SAMPLING_RATES];
+ unsigned int num_channel_masks; /* number of channel masks in following array */
+ audio_channel_mask_t channel_masks[AUDIO_PORT_MAX_CHANNEL_MASKS];
+ unsigned int num_formats; /* number of formats in following array */
+ audio_format_t formats[AUDIO_PORT_MAX_FORMATS];
+ unsigned int num_gains; /* number of gains in following array */
+ struct audio_gain gains[AUDIO_PORT_MAX_GAINS];
+ struct audio_port_config active_config; /* current audio port configuration */
+ union {
+ struct audio_port_device_ext device;
+ struct audio_port_mix_ext mix;
+ struct audio_port_session_ext session;
+ } ext;
+};
+
+/* An audio patch represents a connection between one or more source ports and
+ * one or more sink ports. Patches are connected and disconnected by audio policy manager or by
+ * applications via framework APIs.
+ * Each patch is identified by a handle at the interface used to create that patch. For instance,
+ * when a patch is created by the audio HAL, the HAL allocates and returns a handle.
+ * This handle is unique to a given audio HAL hardware module.
+ * But the same patch receives another system wide unique handle allocated by the framework.
+ * This unique handle is used for all transactions inside the framework.
+ */
+typedef int audio_patch_handle_t;
+
+#define AUDIO_PATCH_PORTS_MAX 16
+
+struct audio_patch {
+ audio_patch_handle_t id; /* patch unique ID */
+ unsigned int num_sources; /* number of sources in following array */
+ struct audio_port_config sources[AUDIO_PATCH_PORTS_MAX];
+ unsigned int num_sinks; /* number of sinks in following array */
+ struct audio_port_config sinks[AUDIO_PATCH_PORTS_MAX];
+};
+
+/* a HW synchronization source returned by the audio HAL */
+typedef uint32_t audio_hw_sync_t;
+
+/* an invalid HW synchronization source indicating an error */
+#define AUDIO_HW_SYNC_INVALID 0
+
+/**
+ * Mmap buffer descriptor returned by audio_stream->create_mmap_buffer().
+ * note\ Used by streams opened in mmap mode.
+ */
+struct audio_mmap_buffer_info {
+ void* shared_memory_address; /**< base address of mmap memory buffer.
+ For use by local process only */
+ int32_t shared_memory_fd; /**< FD for mmap memory buffer */
+ int32_t buffer_size_frames; /**< total buffer size in frames */
+ int32_t burst_size_frames; /**< transfer size granularity in frames */
+};
+
+/**
+ * Mmap buffer read/write position returned by audio_stream->get_mmap_position().
+ * note\ Used by streams opened in mmap mode.
+ */
+struct audio_mmap_position {
+ int64_t time_nanoseconds; /**< timestamp in ns, CLOCK_MONOTONIC */
+ int32_t position_frames; /**< increasing 32 bit frame count reset when stream->stop()
+ is called */
+};
+
+static inline bool audio_is_output_device(audio_devices_t device) {
+ if (((device & AUDIO_DEVICE_BIT_IN) == 0) && (popcount(device) == 1) &&
+ ((device & ~AUDIO_DEVICE_OUT_ALL) == 0))
+ return true;
+ else
+ return false;
+}
+
+static inline bool audio_is_input_device(audio_devices_t device) {
+ if ((device & AUDIO_DEVICE_BIT_IN) != 0) {
+ device &= ~AUDIO_DEVICE_BIT_IN;
+ if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_ALL) == 0)) return true;
+ }
+ return false;
+}
+
+static inline bool audio_is_output_devices(audio_devices_t device) {
+ return (device & AUDIO_DEVICE_BIT_IN) == 0;
+}
+
+static inline bool audio_is_a2dp_in_device(audio_devices_t device) {
+ if ((device & AUDIO_DEVICE_BIT_IN) != 0) {
+ device &= ~AUDIO_DEVICE_BIT_IN;
+ if ((popcount(device) == 1) && (device & AUDIO_DEVICE_IN_BLUETOOTH_A2DP)) return true;
+ }
+ return false;
+}
+
+static inline bool audio_is_a2dp_out_device(audio_devices_t device) {
+ if ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_A2DP))
+ return true;
+ else
+ return false;
+}
+
+// Deprecated - use audio_is_a2dp_out_device() instead
+static inline bool audio_is_a2dp_device(audio_devices_t device) {
+ return audio_is_a2dp_out_device(device);
+}
+
+static inline bool audio_is_bluetooth_sco_device(audio_devices_t device) {
+ if ((device & AUDIO_DEVICE_BIT_IN) == 0) {
+ if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_OUT_ALL_SCO) == 0)) return true;
+ } else {
+ device &= ~AUDIO_DEVICE_BIT_IN;
+ if ((popcount(device) == 1) && ((device & ~AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) == 0))
+ return true;
+ }
+
+ return false;
+}
+
+static inline bool audio_is_usb_out_device(audio_devices_t device) {
+ return ((popcount(device) == 1) && (device & AUDIO_DEVICE_OUT_ALL_USB));
+}
+
+static inline bool audio_is_usb_in_device(audio_devices_t device) {
+ if ((device & AUDIO_DEVICE_BIT_IN) != 0) {
+ device &= ~AUDIO_DEVICE_BIT_IN;
+ if (popcount(device) == 1 && (device & AUDIO_DEVICE_IN_ALL_USB) != 0) return true;
+ }
+ return false;
+}
+
+/* OBSOLETE - use audio_is_usb_out_device() instead. */
+static inline bool audio_is_usb_device(audio_devices_t device) {
+ return audio_is_usb_out_device(device);
+}
+
+static inline bool audio_is_remote_submix_device(audio_devices_t device) {
+ if ((audio_is_output_devices(device) &&
+ (device & AUDIO_DEVICE_OUT_REMOTE_SUBMIX) == AUDIO_DEVICE_OUT_REMOTE_SUBMIX) ||
+ (!audio_is_output_devices(device) &&
+ (device & AUDIO_DEVICE_IN_REMOTE_SUBMIX) == AUDIO_DEVICE_IN_REMOTE_SUBMIX))
+ return true;
+ else
+ return false;
+}
+
+/* Returns true if:
+ * representation is valid, and
+ * there is at least one channel bit set which _could_ correspond to an input channel, and
+ * there are no channel bits set which could _not_ correspond to an input channel.
+ * Otherwise returns false.
+ */
+static inline bool audio_is_input_channel(audio_channel_mask_t channel) {
+ uint32_t bits = audio_channel_mask_get_bits(channel);
+ switch (audio_channel_mask_get_representation(channel)) {
+ case AUDIO_CHANNEL_REPRESENTATION_POSITION:
+ if (bits & ~AUDIO_CHANNEL_IN_ALL) {
+ bits = 0;
+ }
+ // fall through
+ case AUDIO_CHANNEL_REPRESENTATION_INDEX:
+ return bits != 0;
+ default:
+ return false;
+ }
+}
+
+/* Returns true if:
+ * representation is valid, and
+ * there is at least one channel bit set which _could_ correspond to an output channel, and
+ * there are no channel bits set which could _not_ correspond to an output channel.
+ * Otherwise returns false.
+ */
+static inline bool audio_is_output_channel(audio_channel_mask_t channel) {
+ uint32_t bits = audio_channel_mask_get_bits(channel);
+ switch (audio_channel_mask_get_representation(channel)) {
+ case AUDIO_CHANNEL_REPRESENTATION_POSITION:
+ if (bits & ~AUDIO_CHANNEL_OUT_ALL) {
+ bits = 0;
+ }
+ // fall through
+ case AUDIO_CHANNEL_REPRESENTATION_INDEX:
+ return bits != 0;
+ default:
+ return false;
+ }
+}
+
+/* Returns the number of channels from an input channel mask,
+ * used in the context of audio input or recording.
+ * If a channel bit is set which could _not_ correspond to an input channel,
+ * it is excluded from the count.
+ * Returns zero if the representation is invalid.
+ */
+static inline uint32_t audio_channel_count_from_in_mask(audio_channel_mask_t channel) {
+ uint32_t bits = audio_channel_mask_get_bits(channel);
+ switch (audio_channel_mask_get_representation(channel)) {
+ case AUDIO_CHANNEL_REPRESENTATION_POSITION:
+ // TODO: We can now merge with from_out_mask and remove anding
+ bits &= AUDIO_CHANNEL_IN_ALL;
+ // fall through
+ case AUDIO_CHANNEL_REPRESENTATION_INDEX:
+ return popcount(bits);
+ default:
+ return 0;
+ }
+}
+
+/* Returns the number of channels from an output channel mask,
+ * used in the context of audio output or playback.
+ * If a channel bit is set which could _not_ correspond to an output channel,
+ * it is excluded from the count.
+ * Returns zero if the representation is invalid.
+ */
+static inline uint32_t audio_channel_count_from_out_mask(audio_channel_mask_t channel) {
+ uint32_t bits = audio_channel_mask_get_bits(channel);
+ switch (audio_channel_mask_get_representation(channel)) {
+ case AUDIO_CHANNEL_REPRESENTATION_POSITION:
+ // TODO: We can now merge with from_in_mask and remove anding
+ bits &= AUDIO_CHANNEL_OUT_ALL;
+ // fall through
+ case AUDIO_CHANNEL_REPRESENTATION_INDEX:
+ return popcount(bits);
+ default:
+ return 0;
+ }
+}
+
+/* Derive a channel mask for index assignment from a channel count.
+ * Returns the matching channel mask,
+ * or AUDIO_CHANNEL_NONE if the channel count is zero,
+ * or AUDIO_CHANNEL_INVALID if the channel count exceeds AUDIO_CHANNEL_COUNT_MAX.
+ */
+static inline audio_channel_mask_t audio_channel_mask_for_index_assignment_from_count(
+ uint32_t channel_count) {
+ if (channel_count == 0) {
+ return AUDIO_CHANNEL_NONE;
+ }
+ if (channel_count > AUDIO_CHANNEL_COUNT_MAX) {
+ return AUDIO_CHANNEL_INVALID;
+ }
+ uint32_t bits = (1 << channel_count) - 1;
+ return audio_channel_mask_from_representation_and_bits(AUDIO_CHANNEL_REPRESENTATION_INDEX,
+ bits);
+}
+
+/* Derive an output channel mask for position assignment from a channel count.
+ * This is to be used when the content channel mask is unknown. The 1, 2, 4, 5, 6, 7 and 8 channel
+ * cases are mapped to the standard game/home-theater layouts, but note that 4 is mapped to quad,
+ * and not stereo + FC + mono surround. A channel count of 3 is arbitrarily mapped to stereo + FC
+ * for continuity with stereo.
+ * Returns the matching channel mask,
+ * or AUDIO_CHANNEL_NONE if the channel count is zero,
+ * or AUDIO_CHANNEL_INVALID if the channel count exceeds that of the
+ * configurations for which a default output channel mask is defined.
+ */
+static inline audio_channel_mask_t audio_channel_out_mask_from_count(uint32_t channel_count) {
+ uint32_t bits;
+ switch (channel_count) {
+ case 0:
+ return AUDIO_CHANNEL_NONE;
+ case 1:
+ bits = AUDIO_CHANNEL_OUT_MONO;
+ break;
+ case 2:
+ bits = AUDIO_CHANNEL_OUT_STEREO;
+ break;
+ case 3:
+ bits = AUDIO_CHANNEL_OUT_STEREO | AUDIO_CHANNEL_OUT_FRONT_CENTER;
+ break;
+ case 4: // 4.0
+ bits = AUDIO_CHANNEL_OUT_QUAD;
+ break;
+ case 5: // 5.0
+ bits = AUDIO_CHANNEL_OUT_QUAD | AUDIO_CHANNEL_OUT_FRONT_CENTER;
+ break;
+ case 6: // 5.1
+ bits = AUDIO_CHANNEL_OUT_5POINT1;
+ break;
+ case 7: // 6.1
+ bits = AUDIO_CHANNEL_OUT_5POINT1 | AUDIO_CHANNEL_OUT_BACK_CENTER;
+ break;
+ case 8:
+ bits = AUDIO_CHANNEL_OUT_7POINT1;
+ break;
+ // FIXME FCC_8
+ default:
+ return AUDIO_CHANNEL_INVALID;
+ }
+ return audio_channel_mask_from_representation_and_bits(AUDIO_CHANNEL_REPRESENTATION_POSITION,
+ bits);
+}
+
+/* Derive a default input channel mask from a channel count.
+ * Assumes a position mask for mono and stereo, or an index mask for channel counts > 2.
+ * Returns the matching channel mask,
+ * or AUDIO_CHANNEL_NONE if the channel count is zero,
+ * or AUDIO_CHANNEL_INVALID if the channel count exceeds that of the
+ * configurations for which a default input channel mask is defined.
+ */
+static inline audio_channel_mask_t audio_channel_in_mask_from_count(uint32_t channel_count) {
+ uint32_t bits;
+ switch (channel_count) {
+ case 0:
+ return AUDIO_CHANNEL_NONE;
+ case 1:
+ bits = AUDIO_CHANNEL_IN_MONO;
+ break;
+ case 2:
+ bits = AUDIO_CHANNEL_IN_STEREO;
+ break;
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ // FIXME FCC_8
+ return audio_channel_mask_for_index_assignment_from_count(channel_count);
+ default:
+ return AUDIO_CHANNEL_INVALID;
+ }
+ return audio_channel_mask_from_representation_and_bits(AUDIO_CHANNEL_REPRESENTATION_POSITION,
+ bits);
+}
+
+static inline bool audio_is_valid_format(audio_format_t format) {
+ switch (format & AUDIO_FORMAT_MAIN_MASK) {
+ case AUDIO_FORMAT_PCM:
+ switch (format) {
+ case AUDIO_FORMAT_PCM_16_BIT:
+ case AUDIO_FORMAT_PCM_8_BIT:
+ case AUDIO_FORMAT_PCM_32_BIT:
+ case AUDIO_FORMAT_PCM_8_24_BIT:
+ case AUDIO_FORMAT_PCM_FLOAT:
+ case AUDIO_FORMAT_PCM_24_BIT_PACKED:
+ return true;
+ default:
+ return false;
+ }
+ /* not reached */
+ case AUDIO_FORMAT_MP3:
+ case AUDIO_FORMAT_AMR_NB:
+ case AUDIO_FORMAT_AMR_WB:
+ case AUDIO_FORMAT_AAC:
+ case AUDIO_FORMAT_AAC_ADTS:
+ case AUDIO_FORMAT_HE_AAC_V1:
+ case AUDIO_FORMAT_HE_AAC_V2:
+ case AUDIO_FORMAT_VORBIS:
+ case AUDIO_FORMAT_OPUS:
+ case AUDIO_FORMAT_AC3:
+ case AUDIO_FORMAT_E_AC3:
+ case AUDIO_FORMAT_DTS:
+ case AUDIO_FORMAT_DTS_HD:
+ case AUDIO_FORMAT_IEC61937:
+ case AUDIO_FORMAT_DOLBY_TRUEHD:
+ case AUDIO_FORMAT_QCELP:
+ case AUDIO_FORMAT_EVRC:
+ case AUDIO_FORMAT_EVRCB:
+ case AUDIO_FORMAT_EVRCWB:
+ case AUDIO_FORMAT_AAC_ADIF:
+ case AUDIO_FORMAT_AMR_WB_PLUS:
+ case AUDIO_FORMAT_MP2:
+ case AUDIO_FORMAT_EVRCNW:
+ case AUDIO_FORMAT_FLAC:
+ case AUDIO_FORMAT_ALAC:
+ case AUDIO_FORMAT_APE:
+ case AUDIO_FORMAT_WMA:
+ case AUDIO_FORMAT_WMA_PRO:
+ case AUDIO_FORMAT_DSD:
+ case AUDIO_FORMAT_AC4:
+ case AUDIO_FORMAT_LDAC:
+ return true;
+ default:
+ return false;
+ }
+}
+
+/**
+ * Extract the primary format, eg. PCM, AC3, etc.
+ */
+static inline audio_format_t audio_get_main_format(audio_format_t format) {
+ return (audio_format_t)(format & AUDIO_FORMAT_MAIN_MASK);
+}
+
+/**
+ * Is the data plain PCM samples that can be scaled and mixed?
+ */
+static inline bool audio_is_linear_pcm(audio_format_t format) {
+ return (audio_get_main_format(format) == AUDIO_FORMAT_PCM);
+}
+
+/**
+ * For this format, is the number of PCM audio frames directly proportional
+ * to the number of data bytes?
+ *
+ * In other words, is the format transported as PCM audio samples,
+ * but not necessarily scalable or mixable.
+ * This returns true for real PCM, but also for AUDIO_FORMAT_IEC61937,
+ * which is transported as 16 bit PCM audio, but where the encoded data
+ * cannot be mixed or scaled.
+ */
+static inline bool audio_has_proportional_frames(audio_format_t format) {
+ audio_format_t mainFormat = audio_get_main_format(format);
+ return (mainFormat == AUDIO_FORMAT_PCM || mainFormat == AUDIO_FORMAT_IEC61937);
+}
+
+static inline size_t audio_bytes_per_sample(audio_format_t format) {
+ size_t size = 0;
+
+ switch (format) {
+ case AUDIO_FORMAT_PCM_32_BIT:
+ case AUDIO_FORMAT_PCM_8_24_BIT:
+ size = sizeof(int32_t);
+ break;
+ case AUDIO_FORMAT_PCM_24_BIT_PACKED:
+ size = sizeof(uint8_t) * 3;
+ break;
+ case AUDIO_FORMAT_PCM_16_BIT:
+ case AUDIO_FORMAT_IEC61937:
+ size = sizeof(int16_t);
+ break;
+ case AUDIO_FORMAT_PCM_8_BIT:
+ size = sizeof(uint8_t);
+ break;
+ case AUDIO_FORMAT_PCM_FLOAT:
+ size = sizeof(float);
+ break;
+ default:
+ break;
+ }
+ return size;
+}
+
+/* converts device address to string sent to audio HAL via set_parameters */
+static inline char* audio_device_address_to_parameter(audio_devices_t device, const char* address) {
+ const size_t kSize = AUDIO_DEVICE_MAX_ADDRESS_LEN + sizeof("a2dp_sink_address=");
+ char param[kSize];
+
+ if (device & AUDIO_DEVICE_OUT_ALL_A2DP)
+ snprintf(param, kSize, "%s=%s", "a2dp_sink_address", address);
+ else if (device & AUDIO_DEVICE_OUT_REMOTE_SUBMIX)
+ snprintf(param, kSize, "%s=%s", "mix", address);
+ else
+ snprintf(param, kSize, "%s", address);
+
+ return strdup(param);
+}
+
+static inline bool audio_device_is_digital(audio_devices_t device) {
+ if ((device & AUDIO_DEVICE_BIT_IN) != 0) {
+ // input
+ return (~AUDIO_DEVICE_BIT_IN & device &
+ (AUDIO_DEVICE_IN_ALL_USB | AUDIO_DEVICE_IN_HDMI | AUDIO_DEVICE_IN_SPDIF |
+ AUDIO_DEVICE_IN_IP | AUDIO_DEVICE_IN_BUS)) != 0;
+ } else {
+ // output
+ return (device &
+ (AUDIO_DEVICE_OUT_ALL_USB | AUDIO_DEVICE_OUT_HDMI | AUDIO_DEVICE_OUT_HDMI_ARC |
+ AUDIO_DEVICE_OUT_SPDIF | AUDIO_DEVICE_OUT_IP | AUDIO_DEVICE_OUT_BUS)) != 0;
+ }
+}
+
+// Unique effect ID (can be generated from the following site:
+// http://www.itu.int/ITU-T/asn1/uuid.html)
+// This struct is used for effects identification and in soundtrigger.
+typedef struct audio_uuid_s {
+ uint32_t timeLow;
+ uint16_t timeMid;
+ uint16_t timeHiAndVersion;
+ uint16_t clockSeq;
+ uint8_t node[6];
+} audio_uuid_t;
+
+__END_DECLS
+
+/**
+ * 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
+ * a suffix specific to the device.
+ * e.g: audio.primary.goldfish.so or audio.a2dp.default.so
+ *
+ * The same module names are used in audio policy configuration files.
+ */
+
+#define AUDIO_HARDWARE_MODULE_ID_PRIMARY "primary"
+#define AUDIO_HARDWARE_MODULE_ID_A2DP "a2dp"
+#define AUDIO_HARDWARE_MODULE_ID_USB "usb"
+#define AUDIO_HARDWARE_MODULE_ID_REMOTE_SUBMIX "r_submix"
+#define AUDIO_HARDWARE_MODULE_ID_CODEC_OFFLOAD "codec_offload"
+#define AUDIO_HARDWARE_MODULE_ID_STUB "stub"
+
+/**
+ * Multi-Stream Decoder (MSD) HAL service name. MSD HAL is used to mix
+ * encoded streams together with PCM streams, producing re-encoded
+ * streams or PCM streams.
+ *
+ * The service must register itself using this name, and audioserver
+ * tries to instantiate a device factory using this name as well.
+ * Note that the HIDL implementation library file name *must* have the
+ * suffix "msd" in order to be picked up by HIDL that is:
+ *
+ * android.hardware.audio@x.x-implmsd.so
+ */
+#define AUDIO_HAL_SERVICE_NAME_MSD "msd"
+
+/**
+ * Parameter definitions.
+ * Note that in the framework code it's recommended to use AudioParameter.h
+ * instead of these preprocessor defines, and for sure avoid just copying
+ * the constant values.
+ */
+
+#define AUDIO_PARAMETER_VALUE_ON "on"
+#define AUDIO_PARAMETER_VALUE_OFF "off"
+
+/**
+ * audio device parameters
+ */
+
+/* BT SCO Noise Reduction + Echo Cancellation parameters */
+#define AUDIO_PARAMETER_KEY_BT_NREC "bt_headset_nrec"
+
+/* Get a new HW synchronization source identifier.
+ * Return a valid source (positive integer) or AUDIO_HW_SYNC_INVALID if an error occurs
+ * or no HW sync is available. */
+#define AUDIO_PARAMETER_HW_AV_SYNC "hw_av_sync"
+
+/* Screen state */
+#define AUDIO_PARAMETER_KEY_SCREEN_STATE "screen_state"
+
+/**
+ * audio stream parameters
+ */
+
+#define AUDIO_PARAMETER_STREAM_ROUTING "routing" /* audio_devices_t */
+#define AUDIO_PARAMETER_STREAM_FORMAT "format" /* audio_format_t */
+#define AUDIO_PARAMETER_STREAM_CHANNELS "channels" /* audio_channel_mask_t */
+#define AUDIO_PARAMETER_STREAM_FRAME_COUNT "frame_count" /* size_t */
+#define AUDIO_PARAMETER_STREAM_INPUT_SOURCE "input_source" /* audio_source_t */
+#define AUDIO_PARAMETER_STREAM_SAMPLING_RATE "sampling_rate" /* uint32_t */
+
+#define AUDIO_PARAMETER_DEVICE_CONNECT "connect" /* audio_devices_t */
+#define AUDIO_PARAMETER_DEVICE_DISCONNECT "disconnect" /* audio_devices_t */
+
+/* Enable mono audio playback if 1, else should be 0. */
+#define AUDIO_PARAMETER_MONO_OUTPUT "mono_output"
+
+/* Set the HW synchronization source for an output stream. */
+#define AUDIO_PARAMETER_STREAM_HW_AV_SYNC "hw_av_sync"
+
+/* Query supported formats. The response is a '|' separated list of strings from
+ * audio_format_t enum e.g: "sup_formats=AUDIO_FORMAT_PCM_16_BIT" */
+#define AUDIO_PARAMETER_STREAM_SUP_FORMATS "sup_formats"
+/* Query supported channel masks. The response is a '|' separated list of strings from
+ * audio_channel_mask_t enum e.g: "sup_channels=AUDIO_CHANNEL_OUT_STEREO|AUDIO_CHANNEL_OUT_MONO" */
+#define AUDIO_PARAMETER_STREAM_SUP_CHANNELS "sup_channels"
+/* Query supported sampling rates. The response is a '|' separated list of integer values e.g:
+ * "sup_sampling_rates=44100|48000" */
+#define AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES "sup_sampling_rates"
+
+#define AUDIO_PARAMETER_VALUE_LIST_SEPARATOR "|"
+
+/**
+ * audio codec parameters
+ */
+
+#define AUDIO_OFFLOAD_CODEC_PARAMS "music_offload_codec_param"
+#define AUDIO_OFFLOAD_CODEC_BIT_PER_SAMPLE "music_offload_bit_per_sample"
+#define AUDIO_OFFLOAD_CODEC_BIT_RATE "music_offload_bit_rate"
+#define AUDIO_OFFLOAD_CODEC_AVG_BIT_RATE "music_offload_avg_bit_rate"
+#define AUDIO_OFFLOAD_CODEC_ID "music_offload_codec_id"
+#define AUDIO_OFFLOAD_CODEC_BLOCK_ALIGN "music_offload_block_align"
+#define AUDIO_OFFLOAD_CODEC_SAMPLE_RATE "music_offload_sample_rate"
+#define AUDIO_OFFLOAD_CODEC_ENCODE_OPTION "music_offload_encode_option"
+#define AUDIO_OFFLOAD_CODEC_NUM_CHANNEL "music_offload_num_channels"
+#define AUDIO_OFFLOAD_CODEC_DOWN_SAMPLING "music_offload_down_sampling"
+#define AUDIO_OFFLOAD_CODEC_DELAY_SAMPLES "delay_samples"
+#define AUDIO_OFFLOAD_CODEC_PADDING_SAMPLES "padding_samples"
+
+// FIXME: a temporary declaration for the incall music flag, will be removed when
+// declared in types.hal for audio HAL V4.0 and auto imported to audio-base.h
+#define AUDIO_OUTPUT_FLAG_INCALL_MUSIC 0x10000
+
+#endif // ANDROID_AUDIO_CORE_H
diff --git a/audio/common/all-versions/legacy/include/system/audio_effect.h b/audio/common/all-versions/legacy/include/system/audio_effect.h
new file mode 100644
index 0000000..f99f604
--- /dev/null
+++ b/audio/common/all-versions/legacy/include/system/audio_effect.h
@@ -0,0 +1,528 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_AUDIO_EFFECT_CORE_H
+#define ANDROID_AUDIO_EFFECT_CORE_H
+
+#include "system/audio.h"
+#include "system/audio_effect-base.h"
+
+__BEGIN_DECLS
+
+/////////////////////////////////////////////////
+// Common Definitions
+/////////////////////////////////////////////////
+
+//
+//--- Effect descriptor structure effect_descriptor_t
+//
+
+// This format is used for both "type" and "uuid" fields of the effect descriptor structure.
+// - When used for effect type and the engine is implementing and effect corresponding to a standard
+// OpenSL ES interface, this ID must be the one defined in OpenSLES_IID.h for that interface.
+// - When used as uuid, it should be a unique UUID for this particular implementation.
+typedef audio_uuid_t effect_uuid_t;
+
+// Maximum length of character strings in structures defines by this API.
+#define EFFECT_STRING_LEN_MAX 64
+
+// NULL UUID definition (matches SL_IID_NULL_)
+#define EFFECT_UUID_INITIALIZER \
+ { \
+ 0xec7178ec, 0xe5e1, 0x4432, 0xa3f4, { 0x46, 0x57, 0xe6, 0x79, 0x52, 0x10 } \
+ }
+static const effect_uuid_t EFFECT_UUID_NULL_ = EFFECT_UUID_INITIALIZER;
+static const effect_uuid_t* const EFFECT_UUID_NULL = &EFFECT_UUID_NULL_;
+static const char* const EFFECT_UUID_NULL_STR = "ec7178ec-e5e1-4432-a3f4-4657e6795210";
+
+// The effect descriptor contains necessary information to facilitate the enumeration of the effect
+// engines present in a library.
+typedef struct effect_descriptor_s {
+ effect_uuid_t type; // UUID of to the OpenSL ES interface implemented by this effect
+ effect_uuid_t uuid; // UUID for this particular implementation
+ uint32_t apiVersion; // Version of the effect control API implemented
+ uint32_t flags; // effect engine capabilities/requirements flags (see below)
+ uint16_t cpuLoad; // CPU load indication (see below)
+ uint16_t memoryUsage; // Data Memory usage (see below)
+ char name[EFFECT_STRING_LEN_MAX]; // human readable effect name
+ char implementor[EFFECT_STRING_LEN_MAX]; // human readable effect implementor name
+} effect_descriptor_t;
+
+/////////////////////////////////////////////////
+// Effect control interface
+/////////////////////////////////////////////////
+
+//
+//--- Standardized command codes for command() function
+//
+enum effect_command_e {
+ EFFECT_CMD_INIT, // initialize effect engine
+ EFFECT_CMD_SET_CONFIG, // configure effect engine (see effect_config_t)
+ EFFECT_CMD_RESET, // reset effect engine
+ EFFECT_CMD_ENABLE, // enable effect process
+ EFFECT_CMD_DISABLE, // disable effect process
+ EFFECT_CMD_SET_PARAM, // set parameter immediately (see effect_param_t)
+ EFFECT_CMD_SET_PARAM_DEFERRED, // set parameter deferred
+ EFFECT_CMD_SET_PARAM_COMMIT, // commit previous set parameter deferred
+ EFFECT_CMD_GET_PARAM, // get parameter
+ EFFECT_CMD_SET_DEVICE, // set audio device (see audio.h, audio_devices_t)
+ EFFECT_CMD_SET_VOLUME, // set volume
+ EFFECT_CMD_SET_AUDIO_MODE, // set the audio mode (normal, ring, ...)
+ EFFECT_CMD_SET_CONFIG_REVERSE, // configure effect engine reverse stream(see effect_config_t)
+ EFFECT_CMD_SET_INPUT_DEVICE, // set capture device (see audio.h, audio_devices_t)
+ EFFECT_CMD_GET_CONFIG, // read effect engine configuration
+ EFFECT_CMD_GET_CONFIG_REVERSE, // read configure effect engine reverse stream configuration
+ EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS, // get all supported configurations for a feature.
+ EFFECT_CMD_GET_FEATURE_CONFIG, // get current feature configuration
+ EFFECT_CMD_SET_FEATURE_CONFIG, // set current feature configuration
+ EFFECT_CMD_SET_AUDIO_SOURCE, // set the audio source (see audio.h, audio_source_t)
+ EFFECT_CMD_OFFLOAD, // set if effect thread is an offload one,
+ // send the ioHandle of the effect thread
+ EFFECT_CMD_FIRST_PROPRIETARY = 0x10000 // first proprietary command code
+};
+
+//==================================================================================================
+// command: EFFECT_CMD_INIT
+//--------------------------------------------------------------------------------------------------
+// description:
+// Initialize effect engine: All configurations return to default
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: 0
+// data: N/A
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: sizeof(int)
+// data: status
+//==================================================================================================
+// command: EFFECT_CMD_SET_CONFIG
+//--------------------------------------------------------------------------------------------------
+// description:
+// Apply new audio parameters configurations for input and output buffers
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: sizeof(effect_config_t)
+// data: effect_config_t
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: sizeof(int)
+// data: status
+//==================================================================================================
+// command: EFFECT_CMD_RESET
+//--------------------------------------------------------------------------------------------------
+// description:
+// Reset the effect engine. Keep configuration but resets state and buffer content
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: 0
+// data: N/A
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: 0
+// data: N/A
+//==================================================================================================
+// command: EFFECT_CMD_ENABLE
+//--------------------------------------------------------------------------------------------------
+// description:
+// Enable the process. Called by the framework before the first call to process()
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: 0
+// data: N/A
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: sizeof(int)
+// data: status
+//==================================================================================================
+// command: EFFECT_CMD_DISABLE
+//--------------------------------------------------------------------------------------------------
+// description:
+// Disable the process. Called by the framework after the last call to process()
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: 0
+// data: N/A
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: sizeof(int)
+// data: status
+//==================================================================================================
+// command: EFFECT_CMD_SET_PARAM
+//--------------------------------------------------------------------------------------------------
+// description:
+// Set a parameter and apply it immediately
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: sizeof(effect_param_t) + size of param and value
+// data: effect_param_t + param + value. See effect_param_t definition below for value offset
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: sizeof(int)
+// data: status
+//==================================================================================================
+// command: EFFECT_CMD_SET_PARAM_DEFERRED
+//--------------------------------------------------------------------------------------------------
+// description:
+// Set a parameter but apply it only when receiving EFFECT_CMD_SET_PARAM_COMMIT command
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: sizeof(effect_param_t) + size of param and value
+// data: effect_param_t + param + value. See effect_param_t definition below for value offset
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: 0
+// data: N/A
+//==================================================================================================
+// command: EFFECT_CMD_SET_PARAM_COMMIT
+//--------------------------------------------------------------------------------------------------
+// description:
+// Apply all previously received EFFECT_CMD_SET_PARAM_DEFERRED commands
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: 0
+// data: N/A
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: sizeof(int)
+// data: status
+//==================================================================================================
+// command: EFFECT_CMD_GET_PARAM
+//--------------------------------------------------------------------------------------------------
+// description:
+// Get a parameter value
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: sizeof(effect_param_t) + size of param
+// data: effect_param_t + param
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: sizeof(effect_param_t) + size of param and value
+// data: effect_param_t + param + value. See effect_param_t definition below for value offset
+//==================================================================================================
+// command: EFFECT_CMD_SET_DEVICE
+//--------------------------------------------------------------------------------------------------
+// description:
+// Set the rendering device the audio output path is connected to. See audio.h, audio_devices_t
+// for device values.
+// The effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to receive this
+// command when the device changes
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: sizeof(uint32_t)
+// data: uint32_t
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: 0
+// data: N/A
+//==================================================================================================
+// command: EFFECT_CMD_SET_VOLUME
+//--------------------------------------------------------------------------------------------------
+// description:
+// Set and get volume. Used by audio framework to delegate volume control to effect engine.
+// The effect implementation must set EFFECT_FLAG_VOLUME_IND or EFFECT_FLAG_VOLUME_CTRL flag in
+// its descriptor to receive this command before every call to process() function
+// If EFFECT_FLAG_VOLUME_CTRL flag is set in the effect descriptor, the effect engine must return
+// the volume that should be applied before the effect is processed. The overall volume (the volume
+// actually applied by the effect engine multiplied by the returned value) should match the value
+// indicated in the command.
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: n * sizeof(uint32_t)
+// data: volume for each channel defined in effect_config_t for output buffer expressed in
+// 8.24 fixed point format
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: n * sizeof(uint32_t) / 0
+// data: - if EFFECT_FLAG_VOLUME_CTRL is set in effect descriptor:
+// volume for each channel defined in effect_config_t for output buffer expressed in
+// 8.24 fixed point format
+// - if EFFECT_FLAG_VOLUME_CTRL is not set in effect descriptor:
+// N/A
+// It is legal to receive a null pointer as pReplyData in which case the effect framework has
+// delegated volume control to another effect
+//==================================================================================================
+// command: EFFECT_CMD_SET_AUDIO_MODE
+//--------------------------------------------------------------------------------------------------
+// description:
+// Set the audio mode. The effect implementation must set EFFECT_FLAG_AUDIO_MODE_IND flag in its
+// descriptor to receive this command when the audio mode changes.
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: sizeof(uint32_t)
+// data: audio_mode_t
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: 0
+// data: N/A
+//==================================================================================================
+// command: EFFECT_CMD_SET_CONFIG_REVERSE
+//--------------------------------------------------------------------------------------------------
+// description:
+// Apply new audio parameters configurations for input and output buffers of reverse stream.
+// An example of reverse stream is the echo reference supplied to an Acoustic Echo Canceler.
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: sizeof(effect_config_t)
+// data: effect_config_t
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: sizeof(int)
+// data: status
+//==================================================================================================
+// command: EFFECT_CMD_SET_INPUT_DEVICE
+//--------------------------------------------------------------------------------------------------
+// description:
+// Set the capture device the audio input path is connected to. See audio.h, audio_devices_t
+// for device values.
+// The effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to receive this
+// command when the device changes
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: sizeof(uint32_t)
+// data: uint32_t
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: 0
+// data: N/A
+//==================================================================================================
+// command: EFFECT_CMD_GET_CONFIG
+//--------------------------------------------------------------------------------------------------
+// description:
+// Read audio parameters configurations for input and output buffers
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: 0
+// data: N/A
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: sizeof(effect_config_t)
+// data: effect_config_t
+//==================================================================================================
+// command: EFFECT_CMD_GET_CONFIG_REVERSE
+//--------------------------------------------------------------------------------------------------
+// description:
+// Read audio parameters configurations for input and output buffers of reverse stream
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: 0
+// data: N/A
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: sizeof(effect_config_t)
+// data: effect_config_t
+//==================================================================================================
+// command: EFFECT_CMD_GET_FEATURE_SUPPORTED_CONFIGS
+//--------------------------------------------------------------------------------------------------
+// description:
+// Queries for supported configurations for a particular feature (e.g. get the supported
+// combinations of main and auxiliary channels for a noise suppressor).
+// The command parameter is the feature identifier (See effect_feature_e for a list of defined
+// features) followed by the maximum number of configuration descriptor to return.
+// The reply is composed of:
+// - status (uint32_t):
+// - 0 if feature is supported
+// - -ENOSYS if the feature is not supported,
+// - -ENOMEM if the feature is supported but the total number of supported configurations
+// exceeds the maximum number indicated by the caller.
+// - total number of supported configurations (uint32_t)
+// - an array of configuration descriptors.
+// The actual number of descriptors returned must not exceed the maximum number indicated by
+// the caller.
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: 2 x sizeof(uint32_t)
+// data: effect_feature_e + maximum number of configurations to return
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: 2 x sizeof(uint32_t) + n x sizeof (<config descriptor>)
+// data: status + total number of configurations supported + array of n config descriptors
+//==================================================================================================
+// command: EFFECT_CMD_GET_FEATURE_CONFIG
+//--------------------------------------------------------------------------------------------------
+// description:
+// Retrieves current configuration for a given feature.
+// The reply status is:
+// - 0 if feature is supported
+// - -ENOSYS if the feature is not supported,
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: sizeof(uint32_t)
+// data: effect_feature_e
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: sizeof(uint32_t) + sizeof (<config descriptor>)
+// data: status + config descriptor
+//==================================================================================================
+// command: EFFECT_CMD_SET_FEATURE_CONFIG
+//--------------------------------------------------------------------------------------------------
+// description:
+// Sets current configuration for a given feature.
+// The reply status is:
+// - 0 if feature is supported
+// - -ENOSYS if the feature is not supported,
+// - -EINVAL if the configuration is invalid
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: sizeof(uint32_t) + sizeof (<config descriptor>)
+// data: effect_feature_e + config descriptor
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: sizeof(uint32_t)
+// data: status
+//==================================================================================================
+// command: EFFECT_CMD_SET_AUDIO_SOURCE
+//--------------------------------------------------------------------------------------------------
+// description:
+// Set the audio source the capture path is configured for (Camcorder, voice recognition...).
+// See audio.h, audio_source_t for values.
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: sizeof(uint32_t)
+// data: uint32_t
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: 0
+// data: N/A
+//==================================================================================================
+// command: EFFECT_CMD_OFFLOAD
+//--------------------------------------------------------------------------------------------------
+// description:
+// 1.indicate if the playback thread the effect is attached to is offloaded or not
+// 2.update the io handle of the playback thread the effect is attached to
+//--------------------------------------------------------------------------------------------------
+// command format:
+// size: sizeof(effect_offload_param_t)
+// data: effect_offload_param_t
+//--------------------------------------------------------------------------------------------------
+// reply format:
+// size: sizeof(uint32_t)
+// data: uint32_t
+//--------------------------------------------------------------------------------------------------
+// command: EFFECT_CMD_FIRST_PROPRIETARY
+//--------------------------------------------------------------------------------------------------
+// description:
+// All proprietary effect commands must use command codes above this value. The size and format of
+// command and response fields is free in this case
+//==================================================================================================
+
+// Audio buffer descriptor used by process(), bufferProvider() functions and buffer_config_t
+// structure. Multi-channel audio is always interleaved. The channel order is from LSB to MSB with
+// regard to the channel mask definition in audio.h, audio_channel_mask_t e.g :
+// Stereo: left, right
+// 5 point 1: front left, front right, front center, low frequency, back left, back right
+// The buffer size is expressed in frame count, a frame being composed of samples for all
+// channels at a given time. Frame size for unspecified format (AUDIO_FORMAT_OTHER) is 8 bit by
+// definition
+typedef struct audio_buffer_s {
+ size_t frameCount; // number of frames in buffer
+ union {
+ void* raw; // raw pointer to start of buffer
+ float* f32; // pointer to float 32 bit data at start of buffer
+ int32_t* s32; // pointer to signed 32 bit data at start of buffer
+ int16_t* s16; // pointer to signed 16 bit data at start of buffer
+ uint8_t* u8; // pointer to unsigned 8 bit data at start of buffer
+ };
+} audio_buffer_t;
+
+// The buffer_provider_s structure contains functions that can be used
+// by the effect engine process() function to query and release input
+// or output audio buffer.
+// The getBuffer() function is called to retrieve a buffer where data
+// should read from or written to by process() function.
+// The releaseBuffer() function MUST be called when the buffer retrieved
+// with getBuffer() is not needed anymore.
+// The process function should use the buffer provider mechanism to retrieve
+// input or output buffer if the inBuffer or outBuffer passed as argument is NULL
+// and the buffer configuration (buffer_config_t) given by the EFFECT_CMD_SET_CONFIG
+// command did not specify an audio buffer.
+
+typedef int32_t (*buffer_function_t)(void* cookie, audio_buffer_t* buffer);
+
+typedef struct buffer_provider_s {
+ buffer_function_t getBuffer; // retrieve next buffer
+ buffer_function_t releaseBuffer; // release used buffer
+ void* cookie; // for use by client of buffer provider functions
+} buffer_provider_t;
+
+// The buffer_config_s structure specifies the input or output audio format
+// to be used by the effect engine.
+typedef struct buffer_config_s {
+ audio_buffer_t buffer; // buffer for use by process() function if not passed explicitly
+ uint32_t samplingRate; // sampling rate
+ uint32_t channels; // channel mask (see audio_channel_mask_t in audio.h)
+ buffer_provider_t bufferProvider; // buffer provider
+ uint8_t format; // Audio format (see audio_format_t in audio.h)
+ uint8_t accessMode; // read/write or accumulate in buffer (effect_buffer_access_e)
+ uint16_t mask; // indicates which of the above fields is valid
+} buffer_config_t;
+
+// EFFECT_FEATURE_AUX_CHANNELS feature configuration descriptor. Describe a combination
+// of main and auxiliary channels supported
+typedef struct channel_config_s {
+ audio_channel_mask_t main_channels; // channel mask for main channels
+ audio_channel_mask_t aux_channels; // channel mask for auxiliary channels
+} channel_config_t;
+
+// effect_config_s structure is used to configure audio parameters and buffers for effect engine
+// input and output.
+typedef struct effect_config_s {
+ buffer_config_t inputCfg;
+ buffer_config_t outputCfg;
+} effect_config_t;
+
+// effect_param_s structure describes the format of the pCmdData argument of EFFECT_CMD_SET_PARAM
+// command and pCmdData and pReplyData of EFFECT_CMD_GET_PARAM command.
+// psize and vsize represent the actual size of parameter and value.
+//
+// NOTE: the start of value field inside the data field is always on a 32 bit boundary:
+//
+// +-----------+
+// | status | sizeof(int)
+// +-----------+
+// | psize | sizeof(int)
+// +-----------+
+// | vsize | sizeof(int)
+// +-----------+
+// | | | |
+// ~ parameter ~ > psize |
+// | | | > ((psize - 1)/sizeof(int) + 1) * sizeof(int)
+// +-----------+ |
+// | padding | |
+// +-----------+
+// | | |
+// ~ value ~ > vsize
+// | | |
+// +-----------+
+
+typedef struct effect_param_s {
+ int32_t status; // Transaction status (unused for command, used for reply)
+ uint32_t psize; // Parameter size
+ uint32_t vsize; // Value size
+ char data[]; // Start of Parameter + Value data
+} effect_param_t;
+
+// Maximum effect_param_t size
+#define EFFECT_PARAM_SIZE_MAX 65536
+
+// structure used by EFFECT_CMD_OFFLOAD command
+typedef struct effect_offload_param_s {
+ bool isOffload; // true if the playback thread the effect is attached to is offloaded
+ int ioHandle; // io handle of the playback thread the effect is attached to
+} effect_offload_param_t;
+
+__END_DECLS
+
+#endif // ANDROID_AUDIO_EFFECT_CORE_H
diff --git a/audio/common/all-versions/util/Android.bp b/audio/common/all-versions/util/Android.bp
index 5d33a3a..7132667 100644
--- a/audio/common/all-versions/util/Android.bp
+++ b/audio/common/all-versions/util/Android.bp
@@ -1,10 +1,7 @@
cc_library_headers {
name: "android.hardware.audio.common.util@all-versions",
defaults: ["hidl_defaults"],
- vendor_available: true,
- vndk: {
- enabled: true,
- },
+ vendor: true,
export_include_dirs: ["include"],
}
diff --git a/audio/core/2.0/default/Android.bp b/audio/core/2.0/default/Android.bp
index 9847886..87e6a9a 100644
--- a/audio/core/2.0/default/Android.bp
+++ b/audio/core/2.0/default/Android.bp
@@ -37,13 +37,13 @@
"android.hardware.audio.common.util@all-versions",
"android.hardware.audio.core@all-versions-impl",
"libaudioclient_headers",
- "libaudio_system_headers",
+ "android.hardware.audio.common.legacy@2.0",
"libhardware_headers",
"libmedia_headers",
],
whole_static_libs: [
- "libmedia_helper",
+ "libmedia_helper@2.0",
],
}
diff --git a/audio/core/all-versions/default/Android.bp b/audio/core/all-versions/default/Android.bp
index 214b8d5..a02a6bb 100644
--- a/audio/core/all-versions/default/Android.bp
+++ b/audio/core/all-versions/default/Android.bp
@@ -22,7 +22,7 @@
header_libs: [
"libaudioclient_headers",
- "libaudio_system_headers",
+ "android.hardware.audio.common.legacy@2.0",
"libhardware_headers",
"libmedia_headers",
"android.hardware.audio.common.util@all-versions",
diff --git a/audio/effect/2.0/default/Android.bp b/audio/effect/2.0/default/Android.bp
index db00988..d32a9d9 100644
--- a/audio/effect/2.0/default/Android.bp
+++ b/audio/effect/2.0/default/Android.bp
@@ -41,9 +41,9 @@
header_libs: [
"android.hardware.audio.common.util@all-versions",
"android.hardware.audio.effect@all-versions-impl",
- "libaudio_system_headers",
+ "android.hardware.audio.common.legacy@2.0",
+ "android.hardware.audio.effect.legacy@2.0",
"libaudioclient_headers",
- "libeffects_headers",
"libhardware_headers",
"libmedia_headers",
],
diff --git a/audio/effect/2.0/legacy/Android.bp b/audio/effect/2.0/legacy/Android.bp
new file mode 100644
index 0000000..68de70e
--- /dev/null
+++ b/audio/effect/2.0/legacy/Android.bp
@@ -0,0 +1,12 @@
+cc_library_headers {
+ name: "android.hardware.audio.effect.legacy@2.0",
+ vendor: true,
+ header_libs: [
+ "android.hardware.audio.common.legacy@2.0",
+ "android.hardware.audio.effect.legacy@all-versions",
+ ],
+ export_header_lib_headers: [
+ "android.hardware.audio.common.legacy@2.0",
+ "android.hardware.audio.effect.legacy@all-versions",
+ ],
+}
diff --git a/audio/effect/2.0/legacy/OWNERS b/audio/effect/2.0/legacy/OWNERS
new file mode 100644
index 0000000..6fdc97c
--- /dev/null
+++ b/audio/effect/2.0/legacy/OWNERS
@@ -0,0 +1,3 @@
+elaurent@google.com
+krocard@google.com
+mnaganov@google.com
diff --git a/audio/effect/all-versions/default/Android.bp b/audio/effect/all-versions/default/Android.bp
index ed2a093..47d74a8 100644
--- a/audio/effect/all-versions/default/Android.bp
+++ b/audio/effect/all-versions/default/Android.bp
@@ -9,7 +9,6 @@
shared_libs: [
"libbase",
"libcutils",
- "libeffects",
"libfmq",
"libhidlbase",
"libhidlmemory",
@@ -21,9 +20,7 @@
],
header_libs: [
- "libaudio_system_headers",
"libaudioclient_headers",
- "libeffects_headers",
"libhardware_headers",
"libmedia_headers",
"android.hardware.audio.common.util@all-versions",
diff --git a/audio/effect/all-versions/legacy/Android.bp b/audio/effect/all-versions/legacy/Android.bp
new file mode 100644
index 0000000..bcf81b3
--- /dev/null
+++ b/audio/effect/all-versions/legacy/Android.bp
@@ -0,0 +1,11 @@
+cc_library_headers {
+ name: "android.hardware.audio.effect.legacy@all-versions",
+ vendor: true,
+ export_include_dirs: ["include"],
+ header_libs: [
+ "android.hardware.audio.common.legacy@all-versions",
+ ],
+ export_header_lib_headers: [
+ "android.hardware.audio.common.legacy@all-versions",
+ ],
+}
diff --git a/audio/effect/all-versions/legacy/OWNERS b/audio/effect/all-versions/legacy/OWNERS
new file mode 100644
index 0000000..6fdc97c
--- /dev/null
+++ b/audio/effect/all-versions/legacy/OWNERS
@@ -0,0 +1,3 @@
+elaurent@google.com
+krocard@google.com
+mnaganov@google.com
diff --git a/audio/effect/all-versions/legacy/include/audio_effects/effect_aec.h b/audio/effect/all-versions/legacy/include/audio_effects/effect_aec.h
new file mode 100644
index 0000000..f48749a
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/audio_effects/effect_aec.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * USAGE NOTE: Only include this header when _implementing_ a particular
+ * effect. When access to UUID and properties is enough, include the
+ * corresponding header from system/audio_effects/, which doesn't include
+ * hardware/audio_effect.h.
+ *
+ * Only code that immediately calls into HAL or implements an effect
+ * can import hardware/audio_effect.h.
+ */
+
+#ifndef ANDROID_EFFECT_AEC_H_
+#define ANDROID_EFFECT_AEC_H_
+
+#include <hardware/audio_effect.h>
+#include <system/audio_effects/effect_aec.h>
+
+#endif /*ANDROID_EFFECT_AEC_H_*/
diff --git a/audio/effect/all-versions/legacy/include/audio_effects/effect_agc.h b/audio/effect/all-versions/legacy/include/audio_effects/effect_agc.h
new file mode 100644
index 0000000..466ea96
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/audio_effects/effect_agc.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * USAGE NOTE: Only include this header when _implementing_ a particular
+ * effect. When access to UUID and properties is enough, include the
+ * corresponding header from system/audio_effects/, which doesn't include
+ * hardware/audio_effect.h.
+ *
+ * Only code that immediately calls into HAL or implements an effect
+ * can import hardware/audio_effect.h.
+ */
+
+#ifndef ANDROID_EFFECT_AGC_H_
+#define ANDROID_EFFECT_AGC_H_
+
+#include <hardware/audio_effect.h>
+#include <system/audio_effects/effect_agc.h>
+
+#endif /*ANDROID_EFFECT_AGC_H_*/
diff --git a/audio/effect/all-versions/legacy/include/audio_effects/effect_bassboost.h b/audio/effect/all-versions/legacy/include/audio_effects/effect_bassboost.h
new file mode 100644
index 0000000..157452e
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/audio_effects/effect_bassboost.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * USAGE NOTE: Only include this header when _implementing_ a particular
+ * effect. When access to UUID and properties is enough, include the
+ * corresponding header from system/audio_effects/, which doesn't include
+ * hardware/audio_effect.h.
+ *
+ * Only code that immediately calls into HAL or implements an effect
+ * can import hardware/audio_effect.h.
+ */
+
+#ifndef ANDROID_EFFECT_BASSBOOST_H_
+#define ANDROID_EFFECT_BASSBOOST_H_
+
+#include <hardware/audio_effect.h>
+#include <system/audio_effects/effect_bassboost.h>
+
+#endif /*ANDROID_EFFECT_BASSBOOST_H_*/
diff --git a/audio/effect/all-versions/legacy/include/audio_effects/effect_downmix.h b/audio/effect/all-versions/legacy/include/audio_effects/effect_downmix.h
new file mode 100644
index 0000000..26b849b
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/audio_effects/effect_downmix.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * USAGE NOTE: Only include this header when _implementing_ a particular
+ * effect. When access to UUID and properties is enough, include the
+ * corresponding header from system/audio_effects/, which doesn't include
+ * hardware/audio_effect.h.
+ *
+ * Only code that immediately calls into HAL or implements an effect
+ * can import hardware/audio_effect.h.
+ */
+
+#ifndef ANDROID_EFFECT_DOWNMIX_H_
+#define ANDROID_EFFECT_DOWNMIX_H_
+
+#include <hardware/audio_effect.h>
+#include <system/audio_effects/effect_downmix.h>
+
+#endif /*ANDROID_EFFECT_DOWNMIX_H_*/
diff --git a/audio/effect/all-versions/legacy/include/audio_effects/effect_environmentalreverb.h b/audio/effect/all-versions/legacy/include/audio_effects/effect_environmentalreverb.h
new file mode 100644
index 0000000..dd474c2
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/audio_effects/effect_environmentalreverb.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * USAGE NOTE: Only include this header when _implementing_ a particular
+ * effect. When access to UUID and properties is enough, include the
+ * corresponding header from system/audio_effects/, which doesn't include
+ * hardware/audio_effect.h.
+ *
+ * Only code that immediately calls into HAL or implements an effect
+ * can import hardware/audio_effect.h.
+ */
+
+#ifndef ANDROID_EFFECT_ENVIRONMENTALREVERB_H_
+#define ANDROID_EFFECT_ENVIRONMENTALREVERB_H_
+
+#include <hardware/audio_effect.h>
+#include <system/audio_effects/effect_environmentalreverb.h>
+
+#endif /*ANDROID_EFFECT_ENVIRONMENTALREVERB_H_*/
diff --git a/audio/effect/all-versions/legacy/include/audio_effects/effect_equalizer.h b/audio/effect/all-versions/legacy/include/audio_effects/effect_equalizer.h
new file mode 100644
index 0000000..3059ec2
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/audio_effects/effect_equalizer.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * USAGE NOTE: Only include this header when _implementing_ a particular
+ * effect. When access to UUID and properties is enough, include the
+ * corresponding header from system/audio_effects/, which doesn't include
+ * hardware/audio_effect.h.
+ *
+ * Only code that immediately calls into HAL or implements an effect
+ * can import hardware/audio_effect.h.
+ */
+
+#ifndef ANDROID_EFFECT_EQUALIZER_H_
+#define ANDROID_EFFECT_EQUALIZER_H_
+
+#include <hardware/audio_effect.h>
+#include <system/audio_effects/effect_equalizer.h>
+
+#endif /*ANDROID_EFFECT_EQUALIZER_H_*/
diff --git a/audio/effect/all-versions/legacy/include/audio_effects/effect_loudnessenhancer.h b/audio/effect/all-versions/legacy/include/audio_effects/effect_loudnessenhancer.h
new file mode 100644
index 0000000..f37ba45
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/audio_effects/effect_loudnessenhancer.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * USAGE NOTE: Only include this header when _implementing_ a particular
+ * effect. When access to UUID and properties is enough, include the
+ * corresponding header from system/audio_effects/, which doesn't include
+ * hardware/audio_effect.h.
+ *
+ * Only code that immediately calls into HAL or implements an effect
+ * can import hardware/audio_effect.h.
+ */
+
+#ifndef ANDROID_EFFECT_LOUDNESS_ENHANCER_H_
+#define ANDROID_EFFECT_LOUDNESS_ENHANCER_H_
+
+#include <hardware/audio_effect.h>
+#include <system/audio_effects/effect_loudnessenhancer.h>
+
+#endif /*ANDROID_EFFECT_LOUDNESS_ENHANCER_H_*/
diff --git a/audio/effect/all-versions/legacy/include/audio_effects/effect_ns.h b/audio/effect/all-versions/legacy/include/audio_effects/effect_ns.h
new file mode 100644
index 0000000..3bd8a41
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/audio_effects/effect_ns.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * USAGE NOTE: Only include this header when _implementing_ a particular
+ * effect. When access to UUID and properties is enough, include the
+ * corresponding header from system/audio_effects/, which doesn't include
+ * hardware/audio_effect.h.
+ *
+ * Only code that immediately calls into HAL or implements an effect
+ * can import hardware/audio_effect.h.
+ */
+
+#ifndef ANDROID_EFFECT_NS_H_
+#define ANDROID_EFFECT_NS_H_
+
+#include <hardware/audio_effect.h>
+#include <system/audio_effects/effect_ns.h>
+
+#endif /*ANDROID_EFFECT_NS_H_*/
diff --git a/audio/effect/all-versions/legacy/include/audio_effects/effect_presetreverb.h b/audio/effect/all-versions/legacy/include/audio_effects/effect_presetreverb.h
new file mode 100644
index 0000000..eac1f5f
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/audio_effects/effect_presetreverb.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * USAGE NOTE: Only include this header when _implementing_ a particular
+ * effect. When access to UUID and properties is enough, include the
+ * corresponding header from system/audio_effects/, which doesn't include
+ * hardware/audio_effect.h.
+ *
+ * Only code that immediately calls into HAL or implements an effect
+ * can import hardware/audio_effect.h.
+ */
+
+#ifndef ANDROID_EFFECT_PRESETREVERB_H_
+#define ANDROID_EFFECT_PRESETREVERB_H_
+
+#include <hardware/audio_effect.h>
+#include <system/audio_effects/effect_presetreverb.h>
+
+#endif /*ANDROID_EFFECT_PRESETREVERB_H_*/
diff --git a/audio/effect/all-versions/legacy/include/audio_effects/effect_virtualizer.h b/audio/effect/all-versions/legacy/include/audio_effects/effect_virtualizer.h
new file mode 100644
index 0000000..aeecfa5
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/audio_effects/effect_virtualizer.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * USAGE NOTE: Only include this header when _implementing_ a particular
+ * effect. When access to UUID and properties is enough, include the
+ * corresponding header from system/audio_effects/, which doesn't include
+ * hardware/audio_effect.h.
+ *
+ * Only code that immediately calls into HAL or implements an effect
+ * can import hardware/audio_effect.h.
+ */
+
+#ifndef ANDROID_EFFECT_VIRTUALIZER_H_
+#define ANDROID_EFFECT_VIRTUALIZER_H_
+
+#include <hardware/audio_effect.h>
+#include <system/audio_effects/effect_virtualizer.h>
+
+#endif /*ANDROID_EFFECT_VIRTUALIZER_H_*/
diff --git a/audio/effect/all-versions/legacy/include/audio_effects/effect_visualizer.h b/audio/effect/all-versions/legacy/include/audio_effects/effect_visualizer.h
new file mode 100644
index 0000000..47217e7
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/audio_effects/effect_visualizer.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * USAGE NOTE: Only include this header when _implementing_ a particular
+ * effect. When access to UUID and properties is enough, include the
+ * corresponding header from system/audio_effects/, which doesn't include
+ * hardware/audio_effect.h.
+ *
+ * Only code that immediately calls into HAL or implements an effect
+ * can import hardware/audio_effect.h.
+ */
+
+#ifndef ANDROID_EFFECT_VISUALIZER_H_
+#define ANDROID_EFFECT_VISUALIZER_H_
+
+#include <hardware/audio_effect.h>
+#include <system/audio_effects/effect_visualizer.h>
+
+#endif /*ANDROID_EFFECT_VISUALIZER_H_*/
diff --git a/audio/effect/all-versions/legacy/include/media/EffectsFactoryApi.h b/audio/effect/all-versions/legacy/include/media/EffectsFactoryApi.h
new file mode 100644
index 0000000..e08fd0b
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/media/EffectsFactoryApi.h
@@ -0,0 +1,188 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_EFFECTSFACTORYAPI_H_
+#define ANDROID_EFFECTSFACTORYAPI_H_
+
+#include <cutils/compiler.h>
+#include <errno.h>
+#include <hardware/audio_effect.h>
+#include <stdint.h>
+#include <sys/types.h>
+
+#if __cplusplus
+extern "C" {
+#endif
+
+/////////////////////////////////////////////////
+// Effect factory interface
+/////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Function: EffectQueryNumberEffects
+//
+// Description: Returns the number of different effects in all loaded libraries.
+// Each effect must have a different effect uuid (see
+// effect_descriptor_t). This function together with EffectQueryEffect()
+// is used to enumerate all effects present in all loaded libraries.
+// Each time EffectQueryNumberEffects() is called, the factory must
+// reset the index of the effect descriptor returned by next call to
+// EffectQueryEffect() to restart enumeration from the beginning.
+//
+// Input/Output:
+// pNumEffects: address where the number of effects should be returned.
+//
+// Output:
+// returned value: 0 successful operation.
+// -ENODEV factory failed to initialize
+// -EINVAL invalid pNumEffects
+// *pNumEffects: updated with number of effects in factory
+//
+////////////////////////////////////////////////////////////////////////////////
+ANDROID_API
+int EffectQueryNumberEffects(uint32_t* pNumEffects);
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Function: EffectQueryEffect
+//
+// Description: Returns a descriptor of the next available effect.
+// See effect_descriptor_t for a details on effect descriptor.
+// This function together with EffectQueryNumberEffects() is used to enumerate all
+// effects present in all loaded libraries. The enumeration sequence is:
+// EffectQueryNumberEffects(&num_effects);
+// for (i = 0; i < num_effects; i++)
+// EffectQueryEffect(i,...);
+//
+// Input/Output:
+// pDescriptor: address where to return the effect descriptor.
+//
+// Output:
+// returned value: 0 successful operation.
+// -ENOENT no more effect available
+// -ENODEV factory failed to initialize
+// -EINVAL invalid pDescriptor
+// -ENOSYS effect list has changed since last execution of
+// EffectQueryNumberEffects()
+// *pDescriptor: updated with the effect descriptor.
+//
+////////////////////////////////////////////////////////////////////////////////
+ANDROID_API
+int EffectQueryEffect(uint32_t index, effect_descriptor_t* pDescriptor);
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Function: EffectCreate
+//
+// Description: Creates an effect engine of the specified type and returns an
+// effect control interface on this engine. The function will allocate the
+// resources for an instance of the requested effect engine and return
+// a handle on the effect control interface.
+//
+// Input:
+// pEffectUuid: pointer to the effect uuid.
+// sessionId: audio session to which this effect instance will be attached. All effects
+// created with the same session ID are connected in series and process the same signal
+// stream. Knowing that two effects are part of the same effect chain can help the
+// library implement some kind of optimizations.
+// ioId: identifies the output or input stream this effect is directed to at audio HAL.
+// For future use especially with tunneled HW accelerated effects
+//
+// Input/Output:
+// pHandle: address where to return the effect handle.
+//
+// Output:
+// returned value: 0 successful operation.
+// -ENODEV factory failed to initialize
+// -EINVAL invalid pEffectUuid or pHandle
+// -ENOENT no effect with this uuid found
+// *pHandle: updated with the effect handle.
+//
+////////////////////////////////////////////////////////////////////////////////
+ANDROID_API
+int EffectCreate(const effect_uuid_t* pEffectUuid, int32_t sessionId, int32_t ioId,
+ effect_handle_t* pHandle);
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Function: EffectRelease
+//
+// Description: Releases the effect engine whose handle is given as argument.
+// All resources allocated to this particular instance of the effect are
+// released.
+//
+// Input:
+// handle: handle on the effect interface to be released.
+//
+// Output:
+// returned value: 0 successful operation.
+// -ENODEV factory failed to initialize
+// -EINVAL invalid interface handle
+//
+////////////////////////////////////////////////////////////////////////////////
+ANDROID_API
+int EffectRelease(effect_handle_t handle);
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Function: EffectGetDescriptor
+//
+// Description: Returns the descriptor of the effect which uuid is pointed
+// to by first argument.
+//
+// Input:
+// pEffectUuid: pointer to the effect uuid.
+//
+// Input/Output:
+// pDescriptor: address where to return the effect descriptor.
+//
+// Output:
+// returned value: 0 successful operation.
+// -ENODEV factory failed to initialize
+// -EINVAL invalid pEffectUuid or pDescriptor
+// -ENOENT no effect with this uuid found
+// *pDescriptor: updated with the effect descriptor.
+//
+////////////////////////////////////////////////////////////////////////////////
+ANDROID_API
+int EffectGetDescriptor(const effect_uuid_t* pEffectUuid, effect_descriptor_t* pDescriptor);
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// Function: EffectIsNullUuid
+//
+// Description: Helper function to compare effect uuid to EFFECT_UUID_NULL
+//
+// Input:
+// pEffectUuid: pointer to effect uuid to compare to EFFECT_UUID_NULL.
+//
+// Output:
+// returned value: 0 if uuid is different from EFFECT_UUID_NULL.
+// 1 if uuid is equal to EFFECT_UUID_NULL.
+//
+////////////////////////////////////////////////////////////////////////////////
+ANDROID_API
+int EffectIsNullUuid(const effect_uuid_t* pEffectUuid);
+
+ANDROID_API
+int EffectDumpEffects(int fd);
+
+#if __cplusplus
+} // extern "C"
+#endif
+
+#endif /*ANDROID_EFFECTSFACTORYAPI_H_*/
diff --git a/audio/effect/all-versions/legacy/include/system/audio_effects/audio_effects_conf.h b/audio/effect/all-versions/legacy/include/system/audio_effects/audio_effects_conf.h
new file mode 100644
index 0000000..b68a6c2
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/system/audio_effects/audio_effects_conf.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_AUDIO_EFFECTS_CONF_H
+#define ANDROID_AUDIO_EFFECTS_CONF_H
+
+/////////////////////////////////////////////////
+// Definitions for effects configuration file (audio_effects.conf)
+/////////////////////////////////////////////////
+
+#define AUDIO_EFFECT_DEFAULT_CONFIG_FILE "/system/etc/audio_effects.conf"
+#define AUDIO_EFFECT_VENDOR_CONFIG_FILE "/vendor/etc/audio_effects.conf"
+#define LIBRARIES_TAG "libraries"
+#define PATH_TAG "path"
+
+#define EFFECTS_TAG "effects"
+#define LIBRARY_TAG "library"
+#define UUID_TAG "uuid"
+
+#define PREPROCESSING_TAG "pre_processing"
+#define OUTPUT_SESSION_PROCESSING_TAG "output_session_processing"
+
+#define PARAM_TAG "param"
+#define VALUE_TAG "value"
+#define INT_TAG "int"
+#define SHORT_TAG "short"
+#define FLOAT_TAG "float"
+#define BOOL_TAG "bool"
+#define STRING_TAG "string"
+
+// audio_source_t
+#define MIC_SRC_TAG "mic" // AUDIO_SOURCE_MIC
+#define VOICE_UL_SRC_TAG "voice_uplink" // AUDIO_SOURCE_VOICE_UPLINK
+#define VOICE_DL_SRC_TAG "voice_downlink" // AUDIO_SOURCE_VOICE_DOWNLINK
+#define VOICE_CALL_SRC_TAG "voice_call" // AUDIO_SOURCE_VOICE_CALL
+#define CAMCORDER_SRC_TAG "camcorder" // AUDIO_SOURCE_CAMCORDER
+#define VOICE_REC_SRC_TAG "voice_recognition" // AUDIO_SOURCE_VOICE_RECOGNITION
+#define VOICE_COMM_SRC_TAG "voice_communication" // AUDIO_SOURCE_VOICE_COMMUNICATION
+#define UNPROCESSED_SRC_TAG "unprocessed" // AUDIO_SOURCE_UNPROCESSED
+
+// audio_stream_type_t
+#define AUDIO_STREAM_DEFAULT_TAG "default"
+#define AUDIO_STREAM_VOICE_CALL_TAG "voice_call"
+#define AUDIO_STREAM_SYSTEM_TAG "system"
+#define AUDIO_STREAM_RING_TAG "ring"
+#define AUDIO_STREAM_MUSIC_TAG "music"
+#define AUDIO_STREAM_ALARM_TAG "alarm"
+#define AUDIO_STREAM_NOTIFICATION_TAG "notification"
+#define AUDIO_STREAM_BLUETOOTH_SCO_TAG "bluetooth_sco"
+#define AUDIO_STREAM_ENFORCED_AUDIBLE_TAG "enforced_audible"
+#define AUDIO_STREAM_DTMF_TAG "dtmf"
+#define AUDIO_STREAM_TTS_TAG "tts"
+
+#endif // ANDROID_AUDIO_EFFECTS_CONF_H
diff --git a/audio/effect/all-versions/legacy/include/system/audio_effects/effect_aec.h b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_aec.h
new file mode 100644
index 0000000..9785055
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_aec.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_EFFECT_AEC_CORE_H_
+#define ANDROID_EFFECT_AEC_CORE_H_
+
+#include <system/audio_effect.h>
+
+#if __cplusplus
+extern "C" {
+#endif
+
+// The AEC type UUID is not defined by OpenSL ES and has been generated from
+// http://www.itu.int/ITU-T/asn1/uuid.html
+static const effect_uuid_t FX_IID_AEC_ = {
+ 0x7b491460, 0x8d4d, 0x11e0, 0xbd61, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
+const effect_uuid_t* const FX_IID_AEC = &FX_IID_AEC_;
+
+typedef enum {
+ AEC_PARAM_ECHO_DELAY, // echo delay in microseconds
+ AEC_PARAM_PROPERTIES
+} t_aec_params;
+
+// t_equalizer_settings groups all current aec settings for backup and restore.
+typedef struct s_aec_settings { uint32_t echoDelay; } t_aec_settings;
+
+#if __cplusplus
+} // extern "C"
+#endif
+
+#endif /*ANDROID_EFFECT_AEC_CORE_H_*/
diff --git a/audio/effect/all-versions/legacy/include/system/audio_effects/effect_agc.h b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_agc.h
new file mode 100644
index 0000000..319bcd4
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_agc.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_EFFECT_AGC_CORE_H_
+#define ANDROID_EFFECT_AGC_CORE_H_
+
+#include <system/audio_effect.h>
+
+#if __cplusplus
+extern "C" {
+#endif
+
+// The AGC type UUID is not defined by OpenSL ES and has been generated from
+// http://www.itu.int/ITU-T/asn1/uuid.html
+static const effect_uuid_t FX_IID_AGC_ = {
+ 0x0a8abfe0, 0x654c, 0x11e0, 0xba26, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
+const effect_uuid_t* const FX_IID_AGC = &FX_IID_AGC_;
+
+typedef enum {
+ AGC_PARAM_TARGET_LEVEL, // target output level in millibel
+ AGC_PARAM_COMP_GAIN, // gain in the compression range in millibel
+ AGC_PARAM_LIMITER_ENA, // enable or disable limiter (boolean)
+ AGC_PARAM_PROPERTIES
+} t_agc_params;
+
+// t_agc_settings groups all current agc settings for backup and restore.
+typedef struct s_agc_settings {
+ int16_t targetLevel;
+ int16_t compGain;
+ bool limiterEnabled;
+} t_agc_settings;
+
+#if __cplusplus
+} // extern "C"
+#endif
+
+#endif /*ANDROID_EFFECT_AGC_CORE_H_*/
diff --git a/audio/effect/all-versions/legacy/include/system/audio_effects/effect_bassboost.h b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_bassboost.h
new file mode 100644
index 0000000..7828d66
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_bassboost.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_EFFECT_BASSBOOST_CORE_H_
+#define ANDROID_EFFECT_BASSBOOST_CORE_H_
+
+#include <system/audio_effect.h>
+
+#if __cplusplus
+extern "C" {
+#endif
+
+#ifndef OPENSL_ES_H_
+static const effect_uuid_t SL_IID_BASSBOOST_ = {
+ 0x0634f220, 0xddd4, 0x11db, 0xa0fc, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
+const effect_uuid_t* const SL_IID_BASSBOOST = &SL_IID_BASSBOOST_;
+#endif // OPENSL_ES_H_
+
+/* enumerated parameter settings for BassBoost effect */
+typedef enum { BASSBOOST_PARAM_STRENGTH_SUPPORTED, BASSBOOST_PARAM_STRENGTH } t_bassboost_params;
+
+#if __cplusplus
+} // extern "C"
+#endif
+
+#endif /*ANDROID_EFFECT_BASSBOOST_CORE_H_*/
diff --git a/audio/effect/all-versions/legacy/include/system/audio_effects/effect_downmix.h b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_downmix.h
new file mode 100644
index 0000000..9f02e41
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_downmix.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_EFFECT_DOWNMIX_CORE_H_
+#define ANDROID_EFFECT_DOWNMIX_CORE_H_
+
+#include <system/audio_effect.h>
+
+#if __cplusplus
+extern "C" {
+#endif
+
+#define EFFECT_UIID_DOWNMIX__ \
+ { \
+ 0x381e49cc, 0xa858, 0x4aa2, 0x87f6, { 0xe8, 0x38, 0x8e, 0x76, 0x01, 0xb2 } \
+ }
+static const effect_uuid_t EFFECT_UIID_DOWNMIX_ = EFFECT_UIID_DOWNMIX__;
+const effect_uuid_t* const EFFECT_UIID_DOWNMIX = &EFFECT_UIID_DOWNMIX_;
+
+/* enumerated parameter settings for downmix effect */
+typedef enum { DOWNMIX_PARAM_TYPE } downmix_params_t;
+
+typedef enum {
+ DOWNMIX_TYPE_INVALID = -1,
+ // throw away the extra channels
+ DOWNMIX_TYPE_STRIP = 0,
+ // mix the extra channels with FL/FR
+ DOWNMIX_TYPE_FOLD = 1,
+ DOWNMIX_TYPE_CNT,
+ DOWNMIX_TYPE_LAST = DOWNMIX_TYPE_CNT - 1
+} downmix_type_t;
+
+#if __cplusplus
+} // extern "C"
+#endif
+
+#endif /*ANDROID_EFFECT_DOWNMIX_CORE_H_*/
diff --git a/audio/effect/all-versions/legacy/include/system/audio_effects/effect_environmentalreverb.h b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_environmentalreverb.h
new file mode 100644
index 0000000..8caee32
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_environmentalreverb.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_EFFECT_ENVIRONMENTALREVERB_CORE_H_
+#define ANDROID_EFFECT_ENVIRONMENTALREVERB_CORE_H_
+
+#include <system/audio_effect.h>
+
+#if __cplusplus
+extern "C" {
+#endif
+
+#ifndef OPENSL_ES_H_
+static const effect_uuid_t SL_IID_ENVIRONMENTALREVERB_ = {
+ 0xc2e5d5f0, 0x94bd, 0x4763, 0x9cac, {0x4e, 0x23, 0x4d, 0x6, 0x83, 0x9e}};
+const effect_uuid_t* const SL_IID_ENVIRONMENTALREVERB = &SL_IID_ENVIRONMENTALREVERB_;
+#endif // OPENSL_ES_H_
+
+/* enumerated parameter settings for environmental reverb effect */
+typedef enum {
+ // Parameters below are as defined in OpenSL ES specification for environmental reverb interface
+ REVERB_PARAM_ROOM_LEVEL, // in millibels, range -6000 to 0
+ REVERB_PARAM_ROOM_HF_LEVEL, // in millibels, range -4000 to 0
+ REVERB_PARAM_DECAY_TIME, // in milliseconds, range 100 to 20000
+ REVERB_PARAM_DECAY_HF_RATIO, // in permilles, range 100 to 1000
+ REVERB_PARAM_REFLECTIONS_LEVEL, // in millibels, range -6000 to 0
+ REVERB_PARAM_REFLECTIONS_DELAY, // in milliseconds, range 0 to 65
+ REVERB_PARAM_REVERB_LEVEL, // in millibels, range -6000 to 0
+ REVERB_PARAM_REVERB_DELAY, // in milliseconds, range 0 to 65
+ REVERB_PARAM_DIFFUSION, // in permilles, range 0 to 1000
+ REVERB_PARAM_DENSITY, // in permilles, range 0 to 1000
+ REVERB_PARAM_PROPERTIES,
+ REVERB_PARAM_BYPASS
+} t_env_reverb_params;
+
+// t_reverb_settings is equal to SLEnvironmentalReverbSettings defined in OpenSL ES specification.
+typedef struct s_reverb_settings {
+ int16_t roomLevel;
+ int16_t roomHFLevel;
+ uint32_t decayTime;
+ int16_t decayHFRatio;
+ int16_t reflectionsLevel;
+ uint32_t reflectionsDelay;
+ int16_t reverbLevel;
+ uint32_t reverbDelay;
+ int16_t diffusion;
+ int16_t density;
+} __attribute__((packed)) t_reverb_settings;
+
+#if __cplusplus
+} // extern "C"
+#endif
+
+#endif /*ANDROID_EFFECT_ENVIRONMENTALREVERB_CORE_H_*/
diff --git a/audio/effect/all-versions/legacy/include/system/audio_effects/effect_equalizer.h b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_equalizer.h
new file mode 100644
index 0000000..83fddcf
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_equalizer.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_EFFECT_EQUALIZER_CORE_H_
+#define ANDROID_EFFECT_EQUALIZER_CORE_H_
+
+#include <system/audio_effect.h>
+
+#ifndef OPENSL_ES_H_
+static const effect_uuid_t SL_IID_EQUALIZER_ = {
+ 0x0bed4300, 0xddd6, 0x11db, 0x8f34, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
+const effect_uuid_t* const SL_IID_EQUALIZER = &SL_IID_EQUALIZER_;
+#endif // OPENSL_ES_H_
+
+#if __cplusplus
+extern "C" {
+#endif
+
+/* enumerated parameters for Equalizer effect */
+typedef enum {
+ EQ_PARAM_NUM_BANDS, // Gets the number of frequency bands that the equalizer
+ // supports.
+ EQ_PARAM_LEVEL_RANGE, // Returns the minimum and maximum band levels supported.
+ EQ_PARAM_BAND_LEVEL, // Gets/Sets the gain set for the given equalizer band.
+ EQ_PARAM_CENTER_FREQ, // Gets the center frequency of the given band.
+ EQ_PARAM_BAND_FREQ_RANGE, // Gets the frequency range of the given frequency band.
+ EQ_PARAM_GET_BAND, // Gets the band that has the most effect on the given
+ // frequency.
+ EQ_PARAM_CUR_PRESET, // Gets/Sets the current preset.
+ EQ_PARAM_GET_NUM_OF_PRESETS, // Gets the total number of presets the equalizer supports.
+ EQ_PARAM_GET_PRESET_NAME, // Gets the preset name based on the index.
+ EQ_PARAM_PROPERTIES // Gets/Sets all parameters at a time.
+} t_equalizer_params;
+
+// t_equalizer_settings groups all current equalizer setting for backup and restore.
+typedef struct s_equalizer_settings {
+ uint16_t curPreset;
+ uint16_t numBands;
+ uint16_t bandLevels[];
+} t_equalizer_settings;
+
+#if __cplusplus
+} // extern "C"
+#endif
+
+#endif /*ANDROID_EFFECT_EQUALIZER_CORE_H_*/
diff --git a/audio/effect/all-versions/legacy/include/system/audio_effects/effect_loudnessenhancer.h b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_loudnessenhancer.h
new file mode 100644
index 0000000..5c78013
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_loudnessenhancer.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_EFFECT_LOUDNESS_ENHANCER_CORE_H_
+#define ANDROID_EFFECT_LOUDNESS_ENHANCER_CORE_H_
+
+#include <system/audio_effect.h>
+
+#if __cplusplus
+extern "C" {
+#endif
+
+// this effect is not defined in OpenSL ES as one of the standard effects
+static const effect_uuid_t FX_IID_LOUDNESS_ENHANCER_ = {
+ 0xfe3199be, 0xaed0, 0x413f, 0x87bb, {0x11, 0x26, 0x0e, 0xb6, 0x3c, 0xf1}};
+const effect_uuid_t* const FX_IID_LOUDNESS_ENHANCER = &FX_IID_LOUDNESS_ENHANCER_;
+
+#define LOUDNESS_ENHANCER_DEFAULT_TARGET_GAIN_MB 0 // mB
+
+// enumerated parameters for DRC effect
+// to keep in sync with frameworks/base/media/java/android/media/audiofx/LoudnessEnhancer.java
+typedef enum {
+ LOUDNESS_ENHANCER_PARAM_TARGET_GAIN_MB = 0, // target gain expressed in mB
+} t_level_monitor_params;
+
+#if __cplusplus
+} // extern "C"
+#endif
+
+#endif /*ANDROID_EFFECT_LOUDNESS_ENHANCER_CORE_H_*/
diff --git a/audio/effect/all-versions/legacy/include/system/audio_effects/effect_ns.h b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_ns.h
new file mode 100644
index 0000000..8b9ac76
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_ns.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_EFFECT_NS_CORE_H_
+#define ANDROID_EFFECT_NS_CORE_H_
+
+#include <system/audio_effect.h>
+
+#if __cplusplus
+extern "C" {
+#endif
+
+// The NS type UUID is not defined by OpenSL ES and has been generated from
+// http://www.itu.int/ITU-T/asn1/uuid.html
+static const effect_uuid_t FX_IID_NS_ = {
+ 0x58b4b260, 0x8e06, 0x11e0, 0xaa8e, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
+const effect_uuid_t* const FX_IID_NS = &FX_IID_NS_;
+
+typedef enum {
+ NS_PARAM_LEVEL, // noise suppression level (t_ns_level)
+ NS_PARAM_PROPERTIES,
+ NS_PARAM_TYPE // noise suppression type (t_ns_type)
+} t_ns_params;
+
+// noise suppression level
+typedef enum { NS_LEVEL_LOW, NS_LEVEL_MEDIUM, NS_LEVEL_HIGH } t_ns_level;
+
+// noise suppression type
+typedef enum { NS_TYPE_SINGLE_CHANNEL, NS_TYPE_MULTI_CHANNEL } t_ns_type;
+
+// s_ns_settings groups all current ns settings for backup and restore.
+typedef struct s_ns_settings {
+ uint32_t level;
+ uint32_t type;
+} t_ns_settings;
+
+#if __cplusplus
+} // extern "C"
+#endif
+
+#endif /*ANDROID_EFFECT_NS_CORE_H_*/
diff --git a/audio/effect/all-versions/legacy/include/system/audio_effects/effect_presetreverb.h b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_presetreverb.h
new file mode 100644
index 0000000..6804fed
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_presetreverb.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_EFFECT_PRESETREVERB_CORE_H_
+#define ANDROID_EFFECT_PRESETREVERB_CORE_H_
+
+#include <system/audio_effect.h>
+
+#if __cplusplus
+extern "C" {
+#endif
+
+#ifndef OPENSL_ES_H_
+static const effect_uuid_t SL_IID_PRESETREVERB_ = {
+ 0x47382d60, 0xddd8, 0x11db, 0xbf3a, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
+const effect_uuid_t* const SL_IID_PRESETREVERB = &SL_IID_PRESETREVERB_;
+#endif // OPENSL_ES_H_
+
+/* enumerated parameter settings for preset reverb effect */
+typedef enum { REVERB_PARAM_PRESET } t_preset_reverb_params;
+
+typedef enum {
+ REVERB_PRESET_NONE,
+ REVERB_PRESET_SMALLROOM,
+ REVERB_PRESET_MEDIUMROOM,
+ REVERB_PRESET_LARGEROOM,
+ REVERB_PRESET_MEDIUMHALL,
+ REVERB_PRESET_LARGEHALL,
+ REVERB_PRESET_PLATE,
+ REVERB_PRESET_LAST = REVERB_PRESET_PLATE
+} t_reverb_presets;
+
+#if __cplusplus
+} // extern "C"
+#endif
+
+#endif /*ANDROID_EFFECT_PRESETREVERB_CORE_H_*/
diff --git a/audio/effect/all-versions/legacy/include/system/audio_effects/effect_virtualizer.h b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_virtualizer.h
new file mode 100644
index 0000000..a6a31ec
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_virtualizer.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_EFFECT_VIRTUALIZER_CORE_H_
+#define ANDROID_EFFECT_VIRTUALIZER_CORE_H_
+
+#include <system/audio_effect.h>
+
+#if __cplusplus
+extern "C" {
+#endif
+
+#ifndef OPENSL_ES_H_
+static const effect_uuid_t SL_IID_VIRTUALIZER_ = {
+ 0x37cc2c00, 0xdddd, 0x11db, 0x8577, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
+const effect_uuid_t* const SL_IID_VIRTUALIZER = &SL_IID_VIRTUALIZER_;
+#endif // OPENSL_ES_H_
+
+/* enumerated parameter settings for virtualizer effect */
+/* to keep in sync with frameworks/base/media/java/android/media/audiofx/Virtualizer.java */
+typedef enum {
+ VIRTUALIZER_PARAM_STRENGTH_SUPPORTED,
+ VIRTUALIZER_PARAM_STRENGTH,
+ // used with EFFECT_CMD_GET_PARAM
+ // format:
+ // parameters int32_t VIRTUALIZER_PARAM_VIRTUAL_SPEAKER_ANGLES
+ // audio_channel_mask_t input channel mask
+ // audio_devices_t audio output device
+ // output int32_t* an array of length 3 * the number of channels in the mask
+ // where entries are the succession of the channel mask
+ // of each speaker (i.e. a single bit is selected in the
+ // channel mask) followed by the azimuth and the
+ // elevation angles.
+ // status int -EINVAL if configuration is not supported or invalid or not forcing
+ // 0 if configuration is supported and the mode is forced
+ // notes:
+ // - all angles are expressed in degrees and are relative to the listener,
+ // - for azimuth: 0 is the direction the listener faces, 180 is behind the listener, and
+ // -90 is to her/his left,
+ // - for elevation: 0 is the horizontal plane, +90 is above the listener, -90 is below.
+ VIRTUALIZER_PARAM_VIRTUAL_SPEAKER_ANGLES,
+ // used with EFFECT_CMD_SET_PARAM
+ // format:
+ // parameters int32_t VIRTUALIZER_PARAM_FORCE_VIRTUALIZATION_MODE
+ // audio_devices_t audio output device
+ // status int -EINVAL if the device is not supported or invalid
+ // 0 if the device is supported and the mode is forced, or forcing
+ // was disabled for the AUDIO_DEVICE_NONE audio device.
+ VIRTUALIZER_PARAM_FORCE_VIRTUALIZATION_MODE,
+ // used with EFFECT_CMD_GET_PARAM
+ // format:
+ // parameters int32_t VIRTUALIZER_PARAM_VIRTUALIZATION_MODE
+ // output audio_device_t audio device reflecting the current virtualization mode,
+ // AUDIO_DEVICE_NONE when not virtualizing
+ // status int -EINVAL if an error occurred
+ // 0 if the output value is successfully retrieved
+ VIRTUALIZER_PARAM_VIRTUALIZATION_MODE
+} t_virtualizer_params;
+
+#if __cplusplus
+} // extern "C"
+#endif
+
+#endif /*ANDROID_EFFECT_VIRTUALIZER_CORE_H_*/
diff --git a/audio/effect/all-versions/legacy/include/system/audio_effects/effect_visualizer.h b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_visualizer.h
new file mode 100644
index 0000000..cc78e15
--- /dev/null
+++ b/audio/effect/all-versions/legacy/include/system/audio_effects/effect_visualizer.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_EFFECT_VISUALIZER_CORE_H_
+#define ANDROID_EFFECT_VISUALIZER_CORE_H_
+
+#include <system/audio_effect.h>
+
+#if __cplusplus
+extern "C" {
+#endif
+
+#ifndef OPENSL_ES_H_
+static const effect_uuid_t SL_IID_VISUALIZATION_ = {
+ 0xe46b26a0, 0xdddd, 0x11db, 0x8afd, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}};
+const effect_uuid_t* const SL_IID_VISUALIZATION = &SL_IID_VISUALIZATION_;
+#endif // OPENSL_ES_H_
+
+#define VISUALIZER_CAPTURE_SIZE_MAX 1024 // maximum capture size in samples
+#define VISUALIZER_CAPTURE_SIZE_MIN 128 // minimum capture size in samples
+
+// to keep in sync with frameworks/base/media/java/android/media/audiofx/Visualizer.java
+#define VISUALIZER_SCALING_MODE_NORMALIZED 0
+#define VISUALIZER_SCALING_MODE_AS_PLAYED 1
+
+#define MEASUREMENT_MODE_NONE 0x0
+#define MEASUREMENT_MODE_PEAK_RMS 0x1
+
+#define MEASUREMENT_IDX_PEAK 0
+#define MEASUREMENT_IDX_RMS 1
+#define MEASUREMENT_COUNT 2
+
+/* enumerated parameters for Visualizer effect */
+typedef enum {
+ VISUALIZER_PARAM_CAPTURE_SIZE, // Sets the number PCM samples in the capture.
+ VISUALIZER_PARAM_SCALING_MODE, // Sets the way the captured data is scaled
+ VISUALIZER_PARAM_LATENCY, // Informs the visualizer about the downstream latency
+ VISUALIZER_PARAM_MEASUREMENT_MODE, // Sets which measurements are to be made
+} t_visualizer_params;
+
+/* commands */
+typedef enum {
+ VISUALIZER_CMD_CAPTURE = EFFECT_CMD_FIRST_PROPRIETARY, // Gets the latest PCM capture.
+ VISUALIZER_CMD_MEASURE, // Gets the current measurements
+} t_visualizer_cmds;
+
+// VISUALIZER_CMD_CAPTURE retrieves the latest PCM snapshot captured by the visualizer engine.
+// It returns the number of samples specified by VISUALIZER_PARAM_CAPTURE_SIZE
+// in 8 bit unsigned format (0 = 0x80)
+
+// VISUALIZER_CMD_MEASURE retrieves the lastest measurements as int32_t saved in the
+// MEASUREMENT_IDX_* array index order.
+
+#if __cplusplus
+} // extern "C"
+#endif
+
+#endif /*ANDROID_EFFECT_VISUALIZER_CORE_H_*/
diff --git a/soundtrigger/2.0/default/Android.bp b/soundtrigger/2.0/default/Android.bp
index cc20f91..21e50e1 100644
--- a/soundtrigger/2.0/default/Android.bp
+++ b/soundtrigger/2.0/default/Android.bp
@@ -16,10 +16,7 @@
cc_library_shared {
name: "android.hardware.soundtrigger@2.0-core",
defaults: ["hidl_defaults"],
- vendor_available: true,
- vndk: {
- enabled: true,
- },
+ vendor: true,
srcs: [
"SoundTriggerHalImpl.cpp",
],
@@ -37,7 +34,7 @@
],
header_libs: [
- "libaudio_system_headers",
+ "android.hardware.soundtrigger.legacy@2.0",
"libhardware_headers",
],
}
diff --git a/soundtrigger/2.0/default/Android.mk b/soundtrigger/2.0/default/Android.mk
index 835a020..1b6360b 100644
--- a/soundtrigger/2.0/default/Android.mk
+++ b/soundtrigger/2.0/default/Android.mk
@@ -32,6 +32,7 @@
android.hardware.soundtrigger@2.0-core
LOCAL_C_INCLUDE_DIRS := $(LOCAL_PATH)
+LOCAL_HEADER_LIBRARIES += android.hardware.soundtrigger.legacy@2.0
ifeq ($(strip $(AUDIOSERVER_MULTILIB)),)
LOCAL_MULTILIB := 32
diff --git a/soundtrigger/2.0/legacy/Android.bp b/soundtrigger/2.0/legacy/Android.bp
new file mode 100644
index 0000000..9954779
--- /dev/null
+++ b/soundtrigger/2.0/legacy/Android.bp
@@ -0,0 +1,11 @@
+cc_library_headers {
+ name: "android.hardware.soundtrigger.legacy@2.0",
+ vendor: true,
+ export_include_dirs: ["include"],
+ header_libs: [
+ "android.hardware.audio.common.legacy@2.0",
+ ],
+ export_header_lib_headers: [
+ "android.hardware.audio.common.legacy@2.0",
+ ],
+}
diff --git a/soundtrigger/2.0/legacy/OWNERS b/soundtrigger/2.0/legacy/OWNERS
new file mode 100644
index 0000000..6fdc97c
--- /dev/null
+++ b/soundtrigger/2.0/legacy/OWNERS
@@ -0,0 +1,3 @@
+elaurent@google.com
+krocard@google.com
+mnaganov@google.com
diff --git a/soundtrigger/2.0/legacy/include/hardware/sound_trigger.h b/soundtrigger/2.0/legacy/include/hardware/sound_trigger.h
new file mode 100644
index 0000000..57b405e
--- /dev/null
+++ b/soundtrigger/2.0/legacy/include/hardware/sound_trigger.h
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <hardware/hardware.h>
+#include <system/audio.h>
+#include <system/sound_trigger.h>
+
+#ifndef ANDROID_SOUND_TRIGGER_HAL_H
+#define ANDROID_SOUND_TRIGGER_HAL_H
+
+__BEGIN_DECLS
+
+/**
+ * The id of this module
+ */
+#define SOUND_TRIGGER_HARDWARE_MODULE_ID "sound_trigger"
+
+/**
+ * Name of the audio devices to open
+ */
+#define SOUND_TRIGGER_HARDWARE_INTERFACE "sound_trigger_hw_if"
+
+#define SOUND_TRIGGER_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
+#define SOUND_TRIGGER_MODULE_API_VERSION_CURRENT SOUND_TRIGGER_MODULE_API_VERSION_1_0
+
+#define SOUND_TRIGGER_DEVICE_API_VERSION_1_0 HARDWARE_DEVICE_API_VERSION(1, 0)
+#define SOUND_TRIGGER_DEVICE_API_VERSION_1_1 HARDWARE_DEVICE_API_VERSION(1, 1)
+#define SOUND_TRIGGER_DEVICE_API_VERSION_CURRENT SOUND_TRIGGER_DEVICE_API_VERSION_1_1
+
+/**
+ * List of known sound trigger HAL modules. This is the base name of the sound_trigger HAL
+ * library composed of the "sound_trigger." prefix, one of the base names below and
+ * a suffix specific to the device.
+ * e.g: sondtrigger.primary.goldfish.so or sound_trigger.primary.default.so
+ */
+
+#define SOUND_TRIGGER_HARDWARE_MODULE_ID_PRIMARY "primary"
+
+/**
+ * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
+ * and the fields of this data structure must begin with hw_module_t
+ * followed by module specific information.
+ */
+struct sound_trigger_module {
+ struct hw_module_t common;
+};
+
+typedef void (*recognition_callback_t)(struct sound_trigger_recognition_event* event, void* cookie);
+typedef void (*sound_model_callback_t)(struct sound_trigger_model_event* event, void* cookie);
+
+struct sound_trigger_hw_device {
+ struct hw_device_t common;
+
+ /*
+ * Retrieve implementation properties.
+ */
+ int (*get_properties)(const struct sound_trigger_hw_device* dev,
+ struct sound_trigger_properties* properties);
+
+ /*
+ * Load a sound model. Once loaded, recognition of this model can be started and stopped.
+ * Only one active recognition per model at a time. The SoundTrigger service will handle
+ * concurrent recognition requests by different users/applications on the same model.
+ * The implementation returns a unique handle used by other functions (unload_sound_model(),
+ * start_recognition(), etc...
+ */
+ int (*load_sound_model)(const struct sound_trigger_hw_device* dev,
+ struct sound_trigger_sound_model* sound_model,
+ sound_model_callback_t callback, void* cookie,
+ sound_model_handle_t* handle);
+
+ /*
+ * Unload a sound model. A sound model can be unloaded to make room for a new one to overcome
+ * implementation limitations.
+ */
+ int (*unload_sound_model)(const struct sound_trigger_hw_device* dev,
+ sound_model_handle_t handle);
+
+ /* Start recognition on a given model. Only one recognition active at a time per model.
+ * Once recognition succeeds of fails, the callback is called.
+ * TODO: group recognition configuration parameters into one struct and add key phrase options.
+ */
+ int (*start_recognition)(const struct sound_trigger_hw_device* dev,
+ sound_model_handle_t sound_model_handle,
+ const struct sound_trigger_recognition_config* config,
+ recognition_callback_t callback, void* cookie);
+
+ /* Stop recognition on a given model.
+ * The implementation does not have to call the callback when stopped via this method.
+ */
+ int (*stop_recognition)(const struct sound_trigger_hw_device* dev,
+ sound_model_handle_t sound_model_handle);
+
+ /* Stop recognition on all models.
+ * Only supported for device api versions SOUND_TRIGGER_DEVICE_API_VERSION_1_1 or above.
+ * If no implementation is provided, stop_recognition will be called for each running model.
+ */
+ int (*stop_all_recognitions)(const struct sound_trigger_hw_device* dev);
+};
+
+typedef struct sound_trigger_hw_device sound_trigger_hw_device_t;
+
+/** convenience API for opening and closing a supported device */
+
+static inline int sound_trigger_hw_device_open(const struct hw_module_t* module,
+ struct sound_trigger_hw_device** device) {
+ return module->methods->open(module, SOUND_TRIGGER_HARDWARE_INTERFACE,
+ TO_HW_DEVICE_T_OPEN(device));
+}
+
+static inline int sound_trigger_hw_device_close(struct sound_trigger_hw_device* device) {
+ return device->common.close(&device->common);
+}
+
+__END_DECLS
+
+#endif // ANDROID_SOUND_TRIGGER_HAL_H
diff --git a/soundtrigger/2.0/legacy/include/system/sound_trigger.h b/soundtrigger/2.0/legacy/include/system/sound_trigger.h
new file mode 100644
index 0000000..5d00c12
--- /dev/null
+++ b/soundtrigger/2.0/legacy/include/system/sound_trigger.h
@@ -0,0 +1,228 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_SOUND_TRIGGER_H
+#define ANDROID_SOUND_TRIGGER_H
+
+#include <stdbool.h>
+#include <system/audio.h>
+
+#define SOUND_TRIGGER_MAX_STRING_LEN 64 // max length of strings in properties & descriptor structs
+#define SOUND_TRIGGER_MAX_LOCALE_LEN 6 // max length of locale string. e.g en_US
+#define SOUND_TRIGGER_MAX_USERS 10 // max number of concurrent users
+#define SOUND_TRIGGER_MAX_PHRASES 10 // max number of concurrent phrases
+
+typedef enum {
+ SOUND_TRIGGER_STATE_NO_INIT = -1, /* The sound trigger service is not initialized */
+ SOUND_TRIGGER_STATE_ENABLED = 0, /* The sound trigger service is enabled */
+ SOUND_TRIGGER_STATE_DISABLED = 1 /* The sound trigger service is disabled */
+} sound_trigger_service_state_t;
+
+#define RECOGNITION_MODE_VOICE_TRIGGER 0x1 // simple voice trigger
+#define RECOGNITION_MODE_USER_IDENTIFICATION 0x2 // trigger only if one user in model identified
+#define RECOGNITION_MODE_USER_AUTHENTICATION 0x4 // trigger only if one user in mode authenticated
+#define RECOGNITION_MODE_GENERIC_TRIGGER 0x8 // generic sound trigger
+
+#define RECOGNITION_STATUS_SUCCESS 0
+#define RECOGNITION_STATUS_ABORT 1
+#define RECOGNITION_STATUS_FAILURE 2
+
+#define SOUND_MODEL_STATUS_UPDATED 0
+
+typedef enum {
+ SOUND_MODEL_TYPE_UNKNOWN = -1, /* use for unspecified sound model type */
+ SOUND_MODEL_TYPE_KEYPHRASE = 0, /* use for key phrase sound models */
+ SOUND_MODEL_TYPE_GENERIC = 1 /* use for all models other than keyphrase */
+} sound_trigger_sound_model_type_t;
+
+typedef audio_uuid_t sound_trigger_uuid_t;
+
+/*
+ * sound trigger implementation descriptor read by the framework via get_properties().
+ * Used by SoundTrigger service to report to applications and manage concurrency and policy.
+ */
+struct sound_trigger_properties {
+ char implementor[SOUND_TRIGGER_MAX_STRING_LEN]; /* implementor name */
+ char description[SOUND_TRIGGER_MAX_STRING_LEN]; /* implementation description */
+ unsigned int version; /* implementation version */
+ sound_trigger_uuid_t uuid; /* unique implementation ID.
+ Must change with version each version */
+ unsigned int max_sound_models; /* maximum number of concurrent sound models
+ loaded */
+ unsigned int max_key_phrases; /* maximum number of key phrases */
+ unsigned int max_users; /* maximum number of concurrent users detected */
+ unsigned int recognition_modes; /* all supported modes.
+ e.g RECOGNITION_MODE_VOICE_TRIGGER */
+ bool capture_transition; /* supports seamless transition from detection
+ to capture */
+ unsigned int max_buffer_ms; /* maximum buffering capacity in ms if
+ capture_transition is true*/
+ bool concurrent_capture; /* supports capture by other use cases while
+ detection is active */
+ bool trigger_in_event; /* returns the trigger capture in event */
+ unsigned int power_consumption_mw; /* Rated power consumption when detection is active
+ with TDB silence/sound/speech ratio */
+};
+
+typedef int sound_trigger_module_handle_t;
+
+struct sound_trigger_module_descriptor {
+ sound_trigger_module_handle_t handle;
+ struct sound_trigger_properties properties;
+};
+
+typedef int sound_model_handle_t;
+
+/*
+ * Base sound model descriptor. This struct is the header of a larger block passed to
+ * load_sound_model() and containing the binary data of the sound model.
+ * Proprietary representation of users in binary data must match information indicated
+ * by users field
+ */
+struct sound_trigger_sound_model {
+ sound_trigger_sound_model_type_t type; /* model type. e.g. SOUND_MODEL_TYPE_KEYPHRASE */
+ sound_trigger_uuid_t uuid; /* unique sound model ID. */
+ sound_trigger_uuid_t vendor_uuid; /* unique vendor ID. Identifies the engine the
+ sound model was build for */
+ unsigned int data_size; /* size of opaque model data */
+ unsigned int data_offset; /* offset of opaque data start from head of struct
+ (e.g sizeof struct sound_trigger_sound_model) */
+};
+
+/* key phrase descriptor */
+struct sound_trigger_phrase {
+ unsigned int id; /* keyphrase ID */
+ unsigned int recognition_mode; /* recognition modes supported by this key phrase */
+ unsigned int num_users; /* number of users in the key phrase */
+ unsigned int users[SOUND_TRIGGER_MAX_USERS]; /* users ids: (not uid_t but sound trigger
+ specific IDs */
+ char locale[SOUND_TRIGGER_MAX_LOCALE_LEN]; /* locale - JAVA Locale style (e.g. en_US) */
+ char text[SOUND_TRIGGER_MAX_STRING_LEN]; /* phrase text in UTF-8 format. */
+};
+
+/*
+ * Specialized sound model for key phrase detection.
+ * Proprietary representation of key phrases in binary data must match information indicated
+ * by phrases field
+ */
+struct sound_trigger_phrase_sound_model {
+ struct sound_trigger_sound_model common;
+ unsigned int num_phrases; /* number of key phrases in model */
+ struct sound_trigger_phrase phrases[SOUND_TRIGGER_MAX_PHRASES];
+};
+
+/*
+ * Generic sound model, used for all cases except key phrase detection.
+ */
+struct sound_trigger_generic_sound_model {
+ struct sound_trigger_sound_model common;
+};
+
+/*
+ * Generic recognition event sent via recognition callback
+ * Must be aligned to transmit as raw memory through Binder.
+ */
+struct __attribute__((aligned(8))) sound_trigger_recognition_event {
+ int status; /* recognition status e.g.
+ RECOGNITION_STATUS_SUCCESS */
+ sound_trigger_sound_model_type_t type; /* event type, same as sound model type.
+ e.g. SOUND_MODEL_TYPE_KEYPHRASE */
+ sound_model_handle_t model; /* loaded sound model that triggered the
+ event */
+ bool capture_available; /* it is possible to capture audio from this
+ utterance buffered by the
+ implementation */
+ int capture_session; /* audio session ID. framework use */
+ int capture_delay_ms; /* delay in ms between end of model
+ detection and start of audio available
+ for capture. A negative value is possible
+ (e.g. if key phrase is also available for
+ capture */
+ int capture_preamble_ms; /* duration in ms of audio captured
+ before the start of the trigger.
+ 0 if none. */
+ bool trigger_in_data; /* the opaque data is the capture of
+ the trigger sound */
+ audio_config_t audio_config; /* audio format of either the trigger in
+ event data or to use for capture of the
+ rest of the utterance */
+ unsigned int data_size; /* size of opaque event data */
+ unsigned int data_offset; /* offset of opaque data start from start of
+ this struct (e.g sizeof struct
+ sound_trigger_phrase_recognition_event) */
+};
+
+/*
+ * Confidence level for each user in struct sound_trigger_phrase_recognition_extra
+ */
+struct sound_trigger_confidence_level {
+ unsigned int user_id; /* user ID */
+ unsigned int level; /* confidence level in percent (0 - 100).
+ - min level for recognition configuration
+ - detected level for recognition event */
+};
+
+/*
+ * Specialized recognition event for key phrase detection
+ */
+struct sound_trigger_phrase_recognition_extra {
+ unsigned int id; /* keyphrase ID */
+ unsigned int recognition_modes; /* recognition modes used for this keyphrase */
+ unsigned int confidence_level; /* confidence level for mode RECOGNITION_MODE_VOICE_TRIGGER */
+ unsigned int num_levels; /* number of user confidence levels */
+ struct sound_trigger_confidence_level levels[SOUND_TRIGGER_MAX_USERS];
+};
+
+struct sound_trigger_phrase_recognition_event {
+ struct sound_trigger_recognition_event common;
+ unsigned int num_phrases;
+ struct sound_trigger_phrase_recognition_extra phrase_extras[SOUND_TRIGGER_MAX_PHRASES];
+};
+
+struct sound_trigger_generic_recognition_event {
+ struct sound_trigger_recognition_event common;
+};
+
+/*
+ * configuration for sound trigger capture session passed to start_recognition()
+ */
+struct sound_trigger_recognition_config {
+ audio_io_handle_t capture_handle; /* IO handle that will be used for capture.
+ N/A if capture_requested is false */
+ audio_devices_t capture_device; /* input device requested for detection capture */
+ bool capture_requested; /* capture and buffer audio for this recognition
+ instance */
+ unsigned int num_phrases; /* number of key phrases recognition extras */
+ struct sound_trigger_phrase_recognition_extra phrases[SOUND_TRIGGER_MAX_PHRASES];
+ /* configuration for each key phrase */
+ unsigned int data_size; /* size of opaque capture configuration data */
+ unsigned int data_offset; /* offset of opaque data start from start of this struct
+ (e.g sizeof struct sound_trigger_recognition_config) */
+};
+
+/*
+ * Event sent via load sound model callback
+ */
+struct sound_trigger_model_event {
+ int status; /* sound model status e.g. SOUND_MODEL_STATUS_UPDATED */
+ sound_model_handle_t model; /* loaded sound model that triggered the event */
+ unsigned int data_size; /* size of event data if any. Size of updated sound model if
+ status is SOUND_MODEL_STATUS_UPDATED */
+ unsigned int data_offset; /* offset of data start from start of this struct
+ (e.g sizeof struct sound_trigger_model_event) */
+};
+
+#endif // ANDROID_SOUND_TRIGGER_H
diff --git a/soundtrigger/2.1/default/Android.mk b/soundtrigger/2.1/default/Android.mk
index 5851d63..04d3f36 100644
--- a/soundtrigger/2.1/default/Android.mk
+++ b/soundtrigger/2.1/default/Android.mk
@@ -38,6 +38,8 @@
android.hidl.allocator@1.0 \
android.hidl.memory@1.0
+LOCAL_HEADER_LIBRARIES := android.hardware.soundtrigger.legacy@2.0
+
LOCAL_C_INCLUDE_DIRS := $(LOCAL_PATH)
ifeq ($(strip $(AUDIOSERVER_MULTILIB)),)
diff --git a/tv/input/1.0/default/Android.bp b/tv/input/1.0/default/Android.bp
index 7c140a5..c422230 100644
--- a/tv/input/1.0/default/Android.bp
+++ b/tv/input/1.0/default/Android.bp
@@ -16,6 +16,9 @@
"android.hardware.tv.input@1.0",
],
+ header_libs: [
+ "android.hardware.audio.common.legacy@2.0",
+ ],
}
cc_binary {