audio/media: convert to using the audio HAL and new audio defs

Change-Id: Ibc637918637329e4f2b62f4ac7781102fbc269f5
Signed-off-by: Dima Zavin <dima@android.com>
diff --git a/include/media/AudioParameter.h b/include/media/AudioParameter.h
index dc0bd2e..79d5d82 100644
--- a/include/media/AudioParameter.h
+++ b/include/media/AudioParameter.h
@@ -33,12 +33,12 @@
     // reserved parameter keys for changing standard parameters with setParameters() function.
     // Using these keys is mandatory for AudioFlinger to properly monitor audio output/input
     // configuration changes and act accordingly.
-    //  keyRouting: to change audio routing, value is an int in AudioSystem::audio_devices
+    //  keyRouting: to change audio routing, value is an int in audio_devices_t
     //  keySamplingRate: to change sampling rate routing, value is an int
-    //  keyFormat: to change audio format, value is an int in AudioSystem::audio_format
-    //  keyChannels: to change audio channel configuration, value is an int in AudioSystem::audio_channels
+    //  keyFormat: to change audio format, value is an int in audio_format_t
+    //  keyChannels: to change audio channel configuration, value is an int in audio_channels_t
     //  keyFrameCount: to change audio output frame count, value is an int
-    //  keyInputSource: to change audio input source, value is an int in audio_source
+    //  keyInputSource: to change audio input source, value is an int in audio_source_t
     //     (defined in media/mediarecorder.h)
     static const char *keyRouting;
     static const char *keySamplingRate;
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
index 293764d..def3612 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -30,6 +30,7 @@
 #include <binder/IMemory.h>
 #include <utils/threads.h>
 
+#include <hardware/audio.h>
 
 namespace android {
 
@@ -127,9 +128,9 @@
      *
      * inputSource:        Select the audio input to record to (e.g. AUDIO_SOURCE_DEFAULT).
      * sampleRate:         Track sampling rate in Hz.
-     * format:             Audio format (e.g AudioSystem::PCM_16_BIT for signed
+     * format:             Audio format (e.g AUDIO_FORMAT_PCM_16_BIT for signed
      *                     16 bits per sample).
-     * channels:           Channel mask: see AudioSystem::audio_channels.
+     * channels:           Channel mask: see audio_channels_t.
      * frameCount:         Total size of track PCM buffer in frames. This defines the
      *                     latency of the track.
      * flags:              A bitmask of acoustic values from enum record_flags.  It enables
@@ -142,15 +143,15 @@
      */
 
      enum record_flags {
-         RECORD_AGC_ENABLE = AudioSystem::AGC_ENABLE,
-         RECORD_NS_ENABLE  = AudioSystem::NS_ENABLE,
-         RECORD_IIR_ENABLE = AudioSystem::TX_IIR_ENABLE
+         RECORD_AGC_ENABLE = AUDIO_IN_ACOUSTICS_AGC_ENABLE,
+         RECORD_NS_ENABLE  = AUDIO_IN_ACOUSTICS_NS_ENABLE,
+         RECORD_IIR_ENABLE = AUDIO_IN_ACOUSTICS_TX_IIR_ENABLE,
      };
 
                         AudioRecord(int inputSource,
                                     uint32_t sampleRate = 0,
                                     int format          = 0,
-                                    uint32_t channels = AudioSystem::CHANNEL_IN_MONO,
+                                    uint32_t channels = AUDIO_CHANNEL_IN_MONO,
                                     int frameCount      = 0,
                                     uint32_t flags      = 0,
                                     callback_t cbf = 0,
@@ -176,7 +177,7 @@
             status_t    set(int inputSource     = 0,
                             uint32_t sampleRate = 0,
                             int format          = 0,
-                            uint32_t channels = AudioSystem::CHANNEL_IN_MONO,
+                            uint32_t channels = AUDIO_CHANNEL_IN_MONO,
                             int frameCount      = 0,
                             uint32_t flags      = 0,
                             callback_t cbf = 0,
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index b0c82d8..eb61a87 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -21,13 +21,15 @@
 #include <utils/threads.h>
 #include <media/IAudioFlinger.h>
 
+#include <hardware/audio.h>
+#include <hardware/audio_policy.h>
+
 /* XXX: Should be include by all the users instead */
 #include <media/AudioParameter.h>
 
 namespace android {
 
 typedef void (*audio_error_callback)(status_t err);
-typedef int audio_io_handle_t;
 
 class IAudioPolicyService;
 class String8;
@@ -36,155 +38,6 @@
 {
 public:
 
-    // must match android/media/AudioSystem.java STREAM_* constants
-    enum stream_type {
-        DEFAULT          =-1,
-        VOICE_CALL       = 0,
-        SYSTEM           = 1,
-        RING             = 2,
-        MUSIC            = 3,
-        ALARM            = 4,
-        NOTIFICATION     = 5,
-        BLUETOOTH_SCO    = 6,
-        ENFORCED_AUDIBLE = 7, // Sounds that cannot be muted by user and must be routed to speaker
-        DTMF             = 8,
-        TTS              = 9,
-        NUM_STREAM_TYPES
-    };
-
-    // Audio sub formats (see AudioSystem::audio_format).
-    enum pcm_sub_format {
-        PCM_SUB_16_BIT          = 0x1, // must be 1 for backward compatibility
-        PCM_SUB_8_BIT           = 0x2, // must be 2 for backward compatibility
-    };
-
-    // FIXME These sub_format enums are currently unused
-
-    // MP3 sub format field definition : can use 11 LSBs in the same way as MP3 frame header to specify
-    // bit rate, stereo mode, version...
-    enum mp3_sub_format {
-        //TODO
-    };
-
-    // AMR NB/WB sub format field definition: specify frame block interleaving, bandwidth efficient or octet aligned,
-    // encoding mode for recording...
-    enum amr_sub_format {
-        //TODO
-    };
-
-    // AAC sub format field definition: specify profile or bitrate for recording...
-    enum aac_sub_format {
-        //TODO
-    };
-
-    // VORBIS sub format field definition: specify quality for recording...
-    enum vorbis_sub_format {
-        //TODO
-    };
-
-    // Audio format consists in a main format field (upper 8 bits) and a sub format field (lower 24 bits).
-    // The main format indicates the main codec type. The sub format field indicates options and parameters
-    // for each format. The sub format is mainly used for record to indicate for instance the requested bitrate
-    // or profile. It can also be used for certain formats to give informations not present in the encoded
-    // audio stream (e.g. octet alignement for AMR).
-    enum audio_format {
-        INVALID_FORMAT      = -1,
-        FORMAT_DEFAULT      = 0,
-        PCM                 = 0x00000000, // must be 0 for backward compatibility
-        MP3                 = 0x01000000,
-        AMR_NB              = 0x02000000,
-        AMR_WB              = 0x03000000,
-        AAC                 = 0x04000000,
-        HE_AAC_V1           = 0x05000000,
-        HE_AAC_V2           = 0x06000000,
-        VORBIS              = 0x07000000,
-        MAIN_FORMAT_MASK    = 0xFF000000,
-        SUB_FORMAT_MASK     = 0x00FFFFFF,
-        // Aliases
-        PCM_16_BIT          = (PCM|PCM_SUB_16_BIT),
-        PCM_8_BIT          = (PCM|PCM_SUB_8_BIT)
-    };
-
-
-    // Channel mask definitions must be kept in sync with values in /media/java/android/media/AudioFormat.java
-    enum audio_channels {
-        // output channels
-        CHANNEL_OUT_FRONT_LEFT = 0x4,
-        CHANNEL_OUT_FRONT_RIGHT = 0x8,
-        CHANNEL_OUT_FRONT_CENTER = 0x10,
-        CHANNEL_OUT_LOW_FREQUENCY = 0x20,
-        CHANNEL_OUT_BACK_LEFT = 0x40,
-        CHANNEL_OUT_BACK_RIGHT = 0x80,
-        CHANNEL_OUT_FRONT_LEFT_OF_CENTER = 0x100,
-        CHANNEL_OUT_FRONT_RIGHT_OF_CENTER = 0x200,
-        CHANNEL_OUT_BACK_CENTER = 0x400,
-        CHANNEL_OUT_MONO = CHANNEL_OUT_FRONT_LEFT,
-        CHANNEL_OUT_STEREO = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT),
-        CHANNEL_OUT_QUAD = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT |
-                CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT),
-        CHANNEL_OUT_SURROUND = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT |
-                CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_BACK_CENTER),
-        CHANNEL_OUT_5POINT1 = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT |
-                CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_LOW_FREQUENCY | CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT),
-        CHANNEL_OUT_7POINT1 = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT |
-                CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_LOW_FREQUENCY | CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT |
-                CHANNEL_OUT_FRONT_LEFT_OF_CENTER | CHANNEL_OUT_FRONT_RIGHT_OF_CENTER),
-        CHANNEL_OUT_ALL = (CHANNEL_OUT_FRONT_LEFT | CHANNEL_OUT_FRONT_RIGHT |
-                CHANNEL_OUT_FRONT_CENTER | CHANNEL_OUT_LOW_FREQUENCY | CHANNEL_OUT_BACK_LEFT | CHANNEL_OUT_BACK_RIGHT |
-                CHANNEL_OUT_FRONT_LEFT_OF_CENTER | CHANNEL_OUT_FRONT_RIGHT_OF_CENTER | CHANNEL_OUT_BACK_CENTER),
-
-        // input channels
-        CHANNEL_IN_LEFT = 0x4,
-        CHANNEL_IN_RIGHT = 0x8,
-        CHANNEL_IN_FRONT = 0x10,
-        CHANNEL_IN_BACK = 0x20,
-        CHANNEL_IN_LEFT_PROCESSED = 0x40,
-        CHANNEL_IN_RIGHT_PROCESSED = 0x80,
-        CHANNEL_IN_FRONT_PROCESSED = 0x100,
-        CHANNEL_IN_BACK_PROCESSED = 0x200,
-        CHANNEL_IN_PRESSURE = 0x400,
-        CHANNEL_IN_X_AXIS = 0x800,
-        CHANNEL_IN_Y_AXIS = 0x1000,
-        CHANNEL_IN_Z_AXIS = 0x2000,
-        CHANNEL_IN_VOICE_UPLINK = 0x4000,
-        CHANNEL_IN_VOICE_DNLINK = 0x8000,
-        CHANNEL_IN_MONO = CHANNEL_IN_FRONT,
-        CHANNEL_IN_STEREO = (CHANNEL_IN_LEFT | CHANNEL_IN_RIGHT),
-        CHANNEL_IN_ALL = (CHANNEL_IN_LEFT | CHANNEL_IN_RIGHT | CHANNEL_IN_FRONT | CHANNEL_IN_BACK|
-                CHANNEL_IN_LEFT_PROCESSED | CHANNEL_IN_RIGHT_PROCESSED | CHANNEL_IN_FRONT_PROCESSED | CHANNEL_IN_BACK_PROCESSED|
-                CHANNEL_IN_PRESSURE | CHANNEL_IN_X_AXIS | CHANNEL_IN_Y_AXIS | CHANNEL_IN_Z_AXIS |
-                CHANNEL_IN_VOICE_UPLINK | CHANNEL_IN_VOICE_DNLINK)
-    };
-
-    // must match android/media/AudioSystem.java MODE_* values
-    enum audio_mode {
-        MODE_INVALID = -2,
-        MODE_CURRENT = -1,
-        MODE_NORMAL = 0,
-        MODE_RINGTONE,
-        MODE_IN_CALL,
-        MODE_IN_COMMUNICATION,
-        NUM_MODES  // not a valid entry, denotes end-of-list
-    };
-
-    enum audio_in_acoustics {
-        AGC_ENABLE    = 0x0001,
-        AGC_DISABLE   = 0,
-        NS_ENABLE     = 0x0002,
-        NS_DISABLE    = 0,
-        TX_IIR_ENABLE = 0x0004,
-        TX_DISABLE    = 0
-    };
-
-    // special audio session values
-    enum audio_sessions {
-        SESSION_OUTPUT_STAGE = -1, // session for effects attached to a particular output stream
-                                   // (value must be less than 0)
-        SESSION_OUTPUT_MIX = 0,    // session for effects applied to output mix. These effects can
-                                   // be moved by audio policy manager to another output stream
-                                   // (value must be 0)
-    };
-
     /* These are static methods to control the system-wide AudioFlinger
      * only privileged processes can have access to them
      */
@@ -209,7 +62,7 @@
     static status_t setStreamMute(int stream, bool mute);
     static status_t getStreamMute(int stream, bool* mute);
 
-    // set audio mode in audio hardware (see AudioSystem::audio_mode)
+    // set audio mode in audio hardware (see audio_mode_t)
     static status_t setMode(int mode);
 
     // returns true in *state if tracks are active on the specified stream or has been active
@@ -230,9 +83,9 @@
     static float linearToLog(int volume);
     static int logToLinear(float volume);
 
-    static status_t getOutputSamplingRate(int* samplingRate, int stream = DEFAULT);
-    static status_t getOutputFrameCount(int* frameCount, int stream = DEFAULT);
-    static status_t getOutputLatency(uint32_t* latency, int stream = DEFAULT);
+    static status_t getOutputSamplingRate(int* samplingRate, int stream = AUDIO_STREAM_DEFAULT);
+    static status_t getOutputFrameCount(int* frameCount, int stream = AUDIO_STREAM_DEFAULT);
+    static status_t getOutputLatency(uint32_t* latency, int stream = AUDIO_STREAM_DEFAULT);
 
     static bool routedToA2dpOutput(int streamType);
 
@@ -250,93 +103,11 @@
     // - BAD_VALUE: invalid parameter
     // NOTE: this feature is not supported on all hardware platforms and it is
     // necessary to check returned status before using the returned values.
-    static status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int stream = DEFAULT);
+    static status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int stream = AUDIO_STREAM_DEFAULT);
 
     static unsigned int  getInputFramesLost(audio_io_handle_t ioHandle);
 
     static int newAudioSessionId();
-    //
-    // AudioPolicyService interface
-    //
-
-    enum audio_devices {
-        // output devices
-        DEVICE_OUT_EARPIECE = 0x1,
-        DEVICE_OUT_SPEAKER = 0x2,
-        DEVICE_OUT_WIRED_HEADSET = 0x4,
-        DEVICE_OUT_WIRED_HEADPHONE = 0x8,
-        DEVICE_OUT_BLUETOOTH_SCO = 0x10,
-        DEVICE_OUT_BLUETOOTH_SCO_HEADSET = 0x20,
-        DEVICE_OUT_BLUETOOTH_SCO_CARKIT = 0x40,
-        DEVICE_OUT_BLUETOOTH_A2DP = 0x80,
-        DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100,
-        DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER = 0x200,
-        DEVICE_OUT_AUX_DIGITAL = 0x400,
-        DEVICE_OUT_ANLG_DOCK_HEADSET = 0x800,
-        DEVICE_OUT_DGTL_DOCK_HEADSET = 0x1000,
-        DEVICE_OUT_DEFAULT = 0x8000,
-        DEVICE_OUT_ALL = (DEVICE_OUT_EARPIECE | DEVICE_OUT_SPEAKER | DEVICE_OUT_WIRED_HEADSET |
-                DEVICE_OUT_WIRED_HEADPHONE | DEVICE_OUT_BLUETOOTH_SCO | DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
-                DEVICE_OUT_BLUETOOTH_SCO_CARKIT | DEVICE_OUT_BLUETOOTH_A2DP | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
-                DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER | DEVICE_OUT_AUX_DIGITAL |
-                DEVICE_OUT_ANLG_DOCK_HEADSET | DEVICE_OUT_DGTL_DOCK_HEADSET |
-                DEVICE_OUT_DEFAULT),
-        DEVICE_OUT_ALL_A2DP = (DEVICE_OUT_BLUETOOTH_A2DP | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
-                DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER),
-
-        // input devices
-        DEVICE_IN_COMMUNICATION = 0x10000,
-        DEVICE_IN_AMBIENT = 0x20000,
-        DEVICE_IN_BUILTIN_MIC = 0x40000,
-        DEVICE_IN_BLUETOOTH_SCO_HEADSET = 0x80000,
-        DEVICE_IN_WIRED_HEADSET = 0x100000,
-        DEVICE_IN_AUX_DIGITAL = 0x200000,
-        DEVICE_IN_VOICE_CALL = 0x400000,
-        DEVICE_IN_BACK_MIC = 0x800000,
-        DEVICE_IN_DEFAULT = 0x80000000,
-
-        DEVICE_IN_ALL = (DEVICE_IN_COMMUNICATION | DEVICE_IN_AMBIENT | DEVICE_IN_BUILTIN_MIC |
-                DEVICE_IN_BLUETOOTH_SCO_HEADSET | DEVICE_IN_WIRED_HEADSET | DEVICE_IN_AUX_DIGITAL |
-                DEVICE_IN_VOICE_CALL | DEVICE_IN_BACK_MIC | DEVICE_IN_DEFAULT)
-    };
-
-    // device connection states used for setDeviceConnectionState()
-    enum device_connection_state {
-        DEVICE_STATE_UNAVAILABLE,
-        DEVICE_STATE_AVAILABLE,
-        NUM_DEVICE_STATES
-    };
-
-    // request to open a direct output with getOutput() (by opposition to sharing an output with other AudioTracks)
-    enum output_flags {
-        OUTPUT_FLAG_INDIRECT = 0x0,
-        OUTPUT_FLAG_DIRECT = 0x1
-    };
-
-    // device categories used for setForceUse()
-    enum forced_config {
-        FORCE_NONE,
-        FORCE_SPEAKER,
-        FORCE_HEADPHONES,
-        FORCE_BT_SCO,
-        FORCE_BT_A2DP,
-        FORCE_WIRED_ACCESSORY,
-        FORCE_BT_CAR_DOCK,
-        FORCE_BT_DESK_DOCK,
-        FORCE_ANALOG_DOCK,
-        FORCE_DIGITAL_DOCK,
-        NUM_FORCE_CONFIG,
-        FORCE_DEFAULT = FORCE_NONE
-    };
-
-    // usages used for setForceUse(), must match AudioSystem.java
-    enum force_use {
-        FOR_COMMUNICATION,
-        FOR_MEDIA,
-        FOR_RECORD,
-        FOR_DOCK,
-        NUM_FORCE_USE
-    };
 
     // types of io configuration change events received with ioConfigChanged()
     enum io_config_event {
@@ -367,40 +138,40 @@
     //
     // IAudioPolicyService interface (see AudioPolicyInterface for method descriptions)
     //
-    static status_t setDeviceConnectionState(audio_devices device, device_connection_state state, const char *device_address);
-    static device_connection_state getDeviceConnectionState(audio_devices device, const char *device_address);
+    static status_t setDeviceConnectionState(audio_devices_t device, audio_policy_dev_state_t state, const char *device_address);
+    static audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device, const char *device_address);
     static status_t setPhoneState(int state);
     static status_t setRingerMode(uint32_t mode, uint32_t mask);
-    static status_t setForceUse(force_use usage, forced_config config);
-    static forced_config getForceUse(force_use usage);
-    static audio_io_handle_t getOutput(stream_type stream,
+    static status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config);
+    static audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage);
+    static audio_io_handle_t getOutput(audio_stream_type_t stream,
                                         uint32_t samplingRate = 0,
-                                        uint32_t format = FORMAT_DEFAULT,
-                                        uint32_t channels = CHANNEL_OUT_STEREO,
-                                        output_flags flags = OUTPUT_FLAG_INDIRECT);
+                                        uint32_t format = AUDIO_FORMAT_DEFAULT,
+                                        uint32_t channels = AUDIO_CHANNEL_OUT_STEREO,
+                                        audio_policy_output_flags_t flags = AUDIO_POLICY_OUTPUT_FLAG_INDIRECT);
     static status_t startOutput(audio_io_handle_t output,
-                                AudioSystem::stream_type stream,
+                                audio_stream_type_t stream,
                                 int session = 0);
     static status_t stopOutput(audio_io_handle_t output,
-                               AudioSystem::stream_type stream,
+                               audio_stream_type_t stream,
                                int session = 0);
     static void releaseOutput(audio_io_handle_t output);
     static audio_io_handle_t getInput(int inputSource,
                                     uint32_t samplingRate = 0,
-                                    uint32_t format = FORMAT_DEFAULT,
-                                    uint32_t channels = CHANNEL_IN_MONO,
-                                    audio_in_acoustics acoustics = (audio_in_acoustics)0);
+                                    uint32_t format = AUDIO_FORMAT_DEFAULT,
+                                    uint32_t channels = AUDIO_CHANNEL_IN_MONO,
+                                    audio_in_acoustics_t acoustics = (audio_in_acoustics_t)0);
     static status_t startInput(audio_io_handle_t input);
     static status_t stopInput(audio_io_handle_t input);
     static void releaseInput(audio_io_handle_t input);
-    static status_t initStreamVolume(stream_type stream,
+    static status_t initStreamVolume(audio_stream_type_t stream,
                                       int indexMin,
                                       int indexMax);
-    static status_t setStreamVolumeIndex(stream_type stream, int index);
-    static status_t getStreamVolumeIndex(stream_type stream, int *index);
+    static status_t setStreamVolumeIndex(audio_stream_type_t stream, int index);
+    static status_t getStreamVolumeIndex(audio_stream_type_t stream, int *index);
 
-    static uint32_t getStrategyForStream(stream_type stream);
-    static uint32_t getDevicesForStream(stream_type stream);
+    static uint32_t getStrategyForStream(audio_stream_type_t stream);
+    static uint32_t getDevicesForStream(audio_stream_type_t stream);
 
     static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc);
     static status_t registerEffect(effect_descriptor_t *desc,
@@ -414,17 +185,6 @@
 
     // ----------------------------------------------------------------------------
 
-    static uint32_t popCount(uint32_t u);
-    static bool isOutputDevice(audio_devices device);
-    static bool isInputDevice(audio_devices device);
-    static bool isA2dpDevice(audio_devices device);
-    static bool isBluetoothScoDevice(audio_devices device);
-    static bool isLowVisibility(stream_type stream);
-    static bool isOutputChannel(uint32_t channel);
-    static bool isInputChannel(uint32_t channel);
-    static bool isValidFormat(uint32_t format);
-    static bool isLinearPCM(uint32_t format);
-
 private:
 
     class AudioFlingerClient: public IBinder::DeathRecipient, public BnAudioFlingerClient
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index 3e346db..de928da 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -30,7 +30,6 @@
 #include <binder/IMemory.h>
 #include <utils/threads.h>
 
-
 namespace android {
 
 // ----------------------------------------------------------------------------
@@ -126,11 +125,11 @@
      * Parameters:
      *
      * streamType:         Select the type of audio stream this track is attached to
-     *                     (e.g. AudioSystem::MUSIC).
+     *                     (e.g. AUDIO_STREAM_MUSIC).
      * sampleRate:         Track sampling rate in Hz.
-     * format:             Audio format (e.g AudioSystem::PCM_16_BIT for signed
+     * format:             Audio format (e.g AUDIO_FORMAT_PCM_16_BIT for signed
      *                     16 bits per sample).
-     * channels:           Channel mask: see AudioSystem::audio_channels.
+     * channels:           Channel mask: see audio_channels_t.
      * frameCount:         Total size of track PCM buffer in frames. This defines the
      *                     latency of the track.
      * flags:              Reserved for future use.
diff --git a/include/media/EffectApi.h b/include/media/EffectApi.h
index b97c22e..a5ad846 100644
--- a/include/media/EffectApi.h
+++ b/include/media/EffectApi.h
@@ -602,9 +602,9 @@
 
 // Audio mode
 enum audio_mode_e {
-    AUDIO_MODE_NORMAL,      // device idle
-    AUDIO_MODE_RINGTONE,    // device ringing
-    AUDIO_MODE_IN_CALL      // audio call connected (VoIP or telephony)
+    AUDIO_EFFECT_MODE_NORMAL,   // device idle
+    AUDIO_EFFECT_MODE_RINGTONE, // device ringing
+    AUDIO_EFFECT_MODE_IN_CALL,  // audio call connected (VoIP or telephony)
 };
 
 // Values for "accessMode" field of buffer_config_t:
diff --git a/include/media/IAudioPolicyService.h b/include/media/IAudioPolicyService.h
index 720a562..09b2bfe 100644
--- a/include/media/IAudioPolicyService.h
+++ b/include/media/IAudioPolicyService.h
@@ -26,6 +26,7 @@
 #include <binder/IInterface.h>
 #include <media/AudioSystem.h>
 
+#include <hardware/audio_policy.h>
 
 namespace android {
 
@@ -39,42 +40,42 @@
     //
     // IAudioPolicyService interface (see AudioPolicyInterface for method descriptions)
     //
-    virtual status_t setDeviceConnectionState(AudioSystem::audio_devices device,
-                                              AudioSystem::device_connection_state state,
+    virtual status_t setDeviceConnectionState(audio_devices_t device,
+                                              audio_policy_dev_state_t state,
                                               const char *device_address) = 0;
-    virtual AudioSystem::device_connection_state getDeviceConnectionState(AudioSystem::audio_devices device,
+    virtual audio_policy_dev_state_t getDeviceConnectionState(audio_devices_t device,
                                                                           const char *device_address) = 0;
     virtual status_t setPhoneState(int state) = 0;
     virtual status_t setRingerMode(uint32_t mode, uint32_t mask) = 0;
-    virtual status_t setForceUse(AudioSystem::force_use usage, AudioSystem::forced_config config) = 0;
-    virtual AudioSystem::forced_config getForceUse(AudioSystem::force_use usage) = 0;
-    virtual audio_io_handle_t getOutput(AudioSystem::stream_type stream,
+    virtual status_t setForceUse(audio_policy_force_use_t usage, audio_policy_forced_cfg_t config) = 0;
+    virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) = 0;
+    virtual audio_io_handle_t getOutput(audio_stream_type_t stream,
                                         uint32_t samplingRate = 0,
-                                        uint32_t format = AudioSystem::FORMAT_DEFAULT,
+                                        uint32_t format = AUDIO_FORMAT_DEFAULT,
                                         uint32_t channels = 0,
-                                        AudioSystem::output_flags flags = AudioSystem::OUTPUT_FLAG_INDIRECT) = 0;
+                                        audio_policy_output_flags_t flags = AUDIO_POLICY_OUTPUT_FLAG_INDIRECT) = 0;
     virtual status_t startOutput(audio_io_handle_t output,
-                                 AudioSystem::stream_type stream,
+                                 audio_stream_type_t stream,
                                  int session = 0) = 0;
     virtual status_t stopOutput(audio_io_handle_t output,
-                                AudioSystem::stream_type stream,
+                                audio_stream_type_t stream,
                                 int session = 0) = 0;
     virtual void releaseOutput(audio_io_handle_t output) = 0;
     virtual audio_io_handle_t getInput(int inputSource,
                                     uint32_t samplingRate = 0,
-                                    uint32_t format = AudioSystem::FORMAT_DEFAULT,
+                                    uint32_t format = AUDIO_FORMAT_DEFAULT,
                                     uint32_t channels = 0,
-                                    AudioSystem::audio_in_acoustics acoustics = (AudioSystem::audio_in_acoustics)0) = 0;
+                                    audio_in_acoustics_t acoustics = (audio_in_acoustics_t)0) = 0;
     virtual status_t startInput(audio_io_handle_t input) = 0;
     virtual status_t stopInput(audio_io_handle_t input) = 0;
     virtual void releaseInput(audio_io_handle_t input) = 0;
-    virtual status_t initStreamVolume(AudioSystem::stream_type stream,
+    virtual status_t initStreamVolume(audio_stream_type_t stream,
                                       int indexMin,
                                       int indexMax) = 0;
-    virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, int index) = 0;
-    virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index) = 0;
-    virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream) = 0;
-    virtual uint32_t getDevicesForStream(AudioSystem::stream_type stream) = 0;
+    virtual status_t setStreamVolumeIndex(audio_stream_type_t stream, int index) = 0;
+    virtual status_t getStreamVolumeIndex(audio_stream_type_t stream, int *index) = 0;
+    virtual uint32_t getStrategyForStream(audio_stream_type_t stream) = 0;
+    virtual uint32_t getDevicesForStream(audio_stream_type_t stream) = 0;
     virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) = 0;
     virtual status_t registerEffect(effect_descriptor_t *desc,
                                     audio_io_handle_t output,
diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h
index e1b6dd6..bebecc0 100644
--- a/include/media/MediaPlayerInterface.h
+++ b/include/media/MediaPlayerInterface.h
@@ -85,7 +85,7 @@
         // audio data.
         virtual status_t    open(
                 uint32_t sampleRate, int channelCount,
-                int format=AudioSystem::PCM_16_BIT,
+                int format=AUDIO_FORMAT_PCM_16_BIT,
                 int bufferCount=DEFAULT_AUDIOSINK_BUFFERCOUNT,
                 AudioCallback cb = NULL,
                 void *cookie = NULL) = 0;
diff --git a/include/media/MediaRecorderBase.h b/include/media/MediaRecorderBase.h
index c42346e..5fe7722 100644
--- a/include/media/MediaRecorderBase.h
+++ b/include/media/MediaRecorderBase.h
@@ -20,6 +20,8 @@
 
 #include <media/mediarecorder.h>
 
+#include <hardware/audio.h>
+
 namespace android {
 
 class Surface;
@@ -29,7 +31,7 @@
     virtual ~MediaRecorderBase() {}
 
     virtual status_t init() = 0;
-    virtual status_t setAudioSource(audio_source as) = 0;
+    virtual status_t setAudioSource(audio_source_t as) = 0;
     virtual status_t setVideoSource(video_source vs) = 0;
     virtual status_t setOutputFormat(output_format of) = 0;
     virtual status_t setAudioEncoder(audio_encoder ae) = 0;
diff --git a/include/media/mediarecorder.h b/include/media/mediarecorder.h
index 67d940b..18a3c6a 100644
--- a/include/media/mediarecorder.h
+++ b/include/media/mediarecorder.h
@@ -33,23 +33,6 @@
 
 typedef void (*media_completion_f)(status_t status, void *cookie);
 
-/* Do not change these values without updating their counterparts
- * in media/java/android/media/MediaRecorder.java!
- */
-enum audio_source {
-    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_MAX = AUDIO_SOURCE_VOICE_COMMUNICATION,
-
-    AUDIO_SOURCE_LIST_END  // must be last - used to validate audio source type
-};
-
 enum video_source {
     VIDEO_SOURCE_DEFAULT = 0,
     VIDEO_SOURCE_CAMERA = 1,
diff --git a/include/media/stagefright/AudioSource.h b/include/media/stagefright/AudioSource.h
index 9e6f0e2..20a9e16 100644
--- a/include/media/stagefright/AudioSource.h
+++ b/include/media/stagefright/AudioSource.h
@@ -24,16 +24,18 @@
 #include <media/stagefright/MediaBuffer.h>
 #include <utils/List.h>
 
+#include <hardware/audio.h>
+
 namespace android {
 
 class AudioRecord;
 
 struct AudioSource : public MediaSource, public MediaBufferObserver {
     // Note that the "channels" parameter is _not_ the number of channels,
-    // but a bitmask of AudioSystem::audio_channels constants.
+    // but a bitmask of audio_channels_t constants.
     AudioSource(
             int inputSource, uint32_t sampleRate,
-            uint32_t channels = AudioSystem::CHANNEL_IN_MONO);
+            uint32_t channels = AUDIO_CHANNEL_IN_MONO);
 
     status_t initCheck() const;