audio: Unified audio related header files. [3/7]

PD#SWPL-140847

Problem:
Unified audio related header files.

Solution:
Delete duplicate header files.
Common header files depend on audio hal.

Verify:
Yocto: :AP222

Change-Id: I9934215d60de7e102da46924fccbfdac676738b0
Signed-off-by: xingri.gao <xingri.gao@amlogic.com>
diff --git a/Makefile b/Makefile
index a36cdd2..129d832 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,6 @@
 OBJS=src/primitives.o \
 	src/resampler.o \
 	src/speexresample/resample.o \
-	src/spdif/AC3FrameScanner.o \
-	src/spdif/BitFieldParser.o \
-	src/spdif/DTSFrameScanner.o \
-	src/spdif/FrameScanner.o \
-        src/spdif/MatFrameScanner.o \
-	src/spdif/SPDIFEncoder.o \
 	src/IpcBuffer/IpcBuffer.o
 
 CUTILS_OBJS=src/cutils/hashmap.o \
@@ -50,9 +44,6 @@
 	for f in $(@D)/include/audio_utils/*.h; do \
 		install -m 644 -D $${f} -t $(STAGING_DIR)/usr/include/audio_utils; \
 	done
-	for f in $(@D)/include/audio_utils/spdif/*.h; do \
-		install -m 644 -D $${f} -t $(STAGING_DIR)/usr/include/audio_utils/spdif; \
-	done
 	for f in $(@D)/include/IpcBuffer/*.h; do \
 		install -m 644 -D $${f} -t $(STAGING_DIR)/usr/include/IpcBuffer; \
 	done
diff --git a/include/audio_utils/spdif/FrameScanner.h b/include/audio_utils/spdif/FrameScanner.h
deleted file mode 100644
index 6d391ee..0000000
--- a/include/audio_utils/spdif/FrameScanner.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 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_AUDIO_FRAME_SCANNER_H
-#define ANDROID_AUDIO_FRAME_SCANNER_H
-
-#include <stdint.h>
-
-namespace android {
-
-
-/**
- * Scan a byte stream looking for the start of an encoded frame.
- * Parse the sample rate and the size of the encoded frame.
- * Buffer the sync header so it can be prepended to the remaining data.
- *
- * This is used directly by the SPDIFEncoder. External clients will
- * generally not call this class.
- */
-class FrameScanner {
-public:
-    FrameScanner(int dataType,
-            const uint8_t *syncBytes,
-            uint32_t syncLength,
-            uint32_t headerLength
-            );
-    virtual ~FrameScanner();
-
-    /**
-     * Pass each byte of the encoded stream to this scanner.
-     * @return true if a complete and valid header was detected
-     */
-    virtual bool scan(uint8_t byte);
-
-    /**
-     * @return address of where the sync header was stored by scan()
-     */
-    const uint8_t *getHeaderAddress() const { return mHeaderBuffer; }
-
-    /**
-     * @return number of bytes in sync header stored by scan()
-     */
-    size_t getHeaderSizeBytes() const { return mHeaderLength; }
-
-    /**
-     * @return sample rate of the encoded audio
-     */
-    uint32_t getSampleRate()   const { return mSampleRate; }
-
-    /**
-     * Some formats, for example EAC3, are wrapped in data bursts that have
-     * a sample rate that is a multiple of the encoded sample rate.
-     * The default multiplier is 1.
-     * @return sample rate multiplier for the SP/DIF PCM data bursts
-     */
-    uint32_t getRateMultiplier()   const { return mRateMultiplier; }
-
-    size_t getFrameSizeBytes()     const { return mFrameSizeBytes; }
-
-    /**
-     * dataType is defined by the SPDIF standard for each format
-     */
-    int getDataType()      const { return mDataType; }
-    int getDataTypeInfo()  const { return mDataTypeInfo; }
-
-    virtual int getMaxChannels() const = 0;
-
-    virtual void resetBurst() = 0;
-
-    /**
-     * @return the number of pcm frames that correspond to one encoded frame
-     */
-    virtual int getMaxSampleFramesPerSyncFrame() const = 0;
-    virtual int getSampleFramesPerSyncFrame()    const = 0;
-
-    /**
-     * @return true if this parsed frame must be the first frame in a data burst.
-     */
-    virtual bool isFirstInBurst() = 0;
-
-    /**
-     * If this returns false then the previous frame may or may not be the last frame.
-     * @return true if this parsed frame is definitely the last frame in a data burst.
-     */
-    virtual bool isLastInBurst()  = 0;
-
-    /**
-     * Most compression types use a lengthCode expressed in bits.
-     */
-    virtual uint16_t convertBytesToLengthCode(uint16_t numBytes) const { return numBytes * 8; }
-
-protected:
-    uint32_t  mBytesSkipped;     // how many bytes were skipped looking for the start of a frame
-    const uint8_t *mSyncBytes;   // pointer to the sync word specific to a format
-    uint32_t  mSyncLength;       // number of bytes in sync word
-    uint8_t   mHeaderBuffer[32]; // a place to gather the relevant header bytes for parsing
-    uint32_t  mHeaderLength;     // the number of bytes we need to parse
-    uint32_t  mCursor;           // position in the mHeaderBuffer
-    uint32_t  mFormatDumpCount;  // used to thin out the debug dumps
-    uint32_t  mSampleRate;       // encoded sample rate
-    uint32_t  mRateMultiplier;   // SPDIF output data burst rate = msampleRate * mRateMultiplier
-    size_t    mFrameSizeBytes;   // encoded frame size
-    int       mDataType;         // as defined in IEC61937-2 paragraph 4.2
-    int       mDataTypeInfo;     // as defined in IEC61937-2 paragraph 4.1
-
-    /**
-     * Parse data in mHeaderBuffer.
-     * Sets mDataType, mFrameSizeBytes, mSampleRate, mRateMultiplier.
-     * @return true if the header is valid.
-     */
-    virtual bool parseHeader() = 0;
-
-};
-
-
-}  // namespace android
-#endif  // ANDROID_AUDIO_FRAME_SCANNER_H
diff --git a/include/audio_utils/spdif/SPDIFEncoder.h b/include/audio_utils/spdif/SPDIFEncoder.h
deleted file mode 100644
index 3c84d73..0000000
--- a/include/audio_utils/spdif/SPDIFEncoder.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 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_AUDIO_SPDIF_ENCODER_H
-#define ANDROID_AUDIO_SPDIF_ENCODER_H
-
-#include <stdint.h>
-#include <system/audio.h>
-#include <audio_utils/spdif/FrameScanner.h>
-
-namespace android {
-
-/**
- * Scan the incoming byte stream for a frame sync.
- * Then wrap the encoded frame in a data burst and send it as if it were PCM.
- * The receiver will see the data burst header and decode the wrapped frame.
- */
-#define SPDIF_MAX_CHANNELS          8
-#define SPDIF_ENCODED_CHANNEL_COUNT 2
-
-class SPDIFEncoder {
-public:
-
-    explicit SPDIFEncoder(audio_format_t format);
-    // Defaults to AC3 format. Was in original API.
-    SPDIFEncoder();
-
-    virtual ~SPDIFEncoder();
-
-    /**
-     * Write encoded data to be wrapped for SPDIF.
-     * The compressed frames do not have to be aligned.
-     * @return number of bytes written or negative error
-     */
-    ssize_t write( const void* buffer, size_t numBytes );
-
-    /**
-     * Called by SPDIFEncoder when it is ready to output a data burst.
-     * Must be implemented in the subclass.
-     * @return number of bytes written or negative error
-     */
-    virtual ssize_t writeOutput( const void* buffer, size_t numBytes ) = 0;
-
-    /**
-     * Get ratio of the encoded data burst sample rate to the encoded rate.
-     * For example, EAC3 data bursts are 4X the encoded rate.
-     */
-    uint32_t getRateMultiplier() const { return mRateMultiplier; }
-
-    /**
-     * @return number of PCM frames in a data burst
-     */
-    uint32_t getBurstFrames() const { return mBurstFrames; }
-
-    /**
-     * @return number of bytes per PCM frame for the data burst
-     */
-    int      getBytesPerOutputFrame();
-
-    /**
-     * @return  true if we can wrap this format in an SPDIF stream
-     */
-    static bool isFormatSupported(audio_format_t format);
-
-    /**
-     * Discard any data in the buffer. Reset frame scanners.
-     * This should be called when seeking to a new position in the stream.
-     */
-    void reset();
-
-protected:
-    void   clearBurstBuffer();
-    void   writeBurstBufferShorts(const uint16_t* buffer, size_t numBytes);
-    void   writeBurstBufferBytes(const uint8_t* buffer, size_t numBytes);
-    void   sendZeroPad();
-    void   flushBurstBuffer();
-    void   startDataBurst();
-    size_t startSyncFrame();
-
-    // Works with various formats including AC3.
-    FrameScanner *mFramer;
-
-    uint32_t  mSampleRate;
-    size_t    mFrameSize;   // size of sync frame in bytes
-    uint16_t *mBurstBuffer; // ALSA wants to get SPDIF data as shorts.
-    size_t    mBurstBufferSizeBytes;
-    uint32_t  mRateMultiplier;
-    uint32_t  mBurstFrames;
-    size_t    mByteCursor;  // cursor into data burst
-    int       mBitstreamNumber;
-    size_t    mPayloadBytesPending; // number of bytes needed to finish burst
-    // state variable, true if scanning for start of frame
-    bool      mScanning;
-
-    static const uint16_t kSPDIFSync1; // Pa
-    static const uint16_t kSPDIFSync2; // Pb
-};
-
-}  // namespace android
-
-#endif  // ANDROID_AUDIO_SPDIF_ENCODER_H
diff --git a/include/media/AudioBufferProvider.h b/include/media/AudioBufferProvider.h
deleted file mode 100644
index 458d170..0000000
--- a/include/media/AudioBufferProvider.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2007 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_BUFFER_PROVIDER_H
-#define ANDROID_AUDIO_BUFFER_PROVIDER_H
-
-#include <utils/Errors.h>
-
-namespace android {
-// ----------------------------------------------------------------------------
-
-class AudioBufferProvider
-{
-public:
-
-    // FIXME merge with AudioTrackShared::Buffer, AudioTrack::Buffer, and AudioRecord::Buffer
-    //       and rename getNextBuffer() to obtainBuffer()
-    struct Buffer {
-        Buffer() : raw(NULL), frameCount(0) { }
-        union {
-            void*       raw;
-            short*      i16;
-            int8_t*     i8;
-        };
-        size_t frameCount;
-    };
-
-    virtual ~AudioBufferProvider() {}
-
-    // On entry:
-    //  buffer              != NULL
-    //  buffer->raw         unused
-    //  buffer->frameCount  maximum number of desired frames
-    // On successful return:
-    //  status              NO_ERROR
-    //  buffer->raw         non-NULL pointer to buffer->frameCount contiguous available frames
-    //  buffer->frameCount  number of contiguous available frames at buffer->raw,
-    //                      0 < buffer->frameCount <= entry value
-    // On error return:
-    //  status              != NO_ERROR
-    //  buffer->raw         NULL
-    //  buffer->frameCount  0
-    virtual status_t getNextBuffer(Buffer* buffer) = 0;
-
-    // Release (a portion of) the buffer previously obtained by getNextBuffer().
-    // It is permissible to call releaseBuffer() multiple times per getNextBuffer().
-    // On entry:
-    //  buffer->frameCount  number of frames to release, must be <= number of frames
-    //                      obtained but not yet released
-    //  buffer->raw         unused
-    // On return:
-    //  buffer->frameCount  0; implementation MUST set to zero
-    //  buffer->raw         undefined; implementation is PERMITTED to set to any value,
-    //                      so if caller needs to continue using this buffer it must
-    //                      keep track of the pointer itself
-    virtual void releaseBuffer(Buffer* buffer) = 0;
-};
-
-// ----------------------------------------------------------------------------
-}; // namespace android
-
-#endif // ANDROID_AUDIO_BUFFER_PROVIDER_H
diff --git a/include/media/AudioResampler.h b/include/media/AudioResampler.h
deleted file mode 100644
index c4627e8..0000000
--- a/include/media/AudioResampler.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2007 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_RESAMPLER_H
-#define ANDROID_AUDIO_RESAMPLER_H
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <cutils/compiler.h>
-#include <utils/Compat.h>
-
-#include <media/AudioBufferProvider.h>
-#include <system/audio.h>
-
-namespace android {
-// ----------------------------------------------------------------------------
-
-class ANDROID_API AudioResampler {
-public:
-    // Determines quality of SRC.
-    //  LOW_QUALITY: linear interpolator (1st order)
-    //  MED_QUALITY: cubic interpolator (3rd order)
-    //  HIGH_QUALITY: fixed multi-tap FIR (e.g. 48KHz->44.1KHz)
-    // NOTE: high quality SRC will only be supported for
-    // certain fixed rate conversions. Sample rate cannot be
-    // changed dynamically.
-    enum src_quality {
-        DEFAULT_QUALITY=0,
-        LOW_QUALITY=1,
-        MED_QUALITY=2,
-        HIGH_QUALITY=3,
-        VERY_HIGH_QUALITY=4,
-        DYN_LOW_QUALITY=5,
-        DYN_MED_QUALITY=6,
-        DYN_HIGH_QUALITY=7,
-    };
-
-    static const CONSTEXPR float UNITY_GAIN_FLOAT = 1.0f;
-
-    static AudioResampler* create(audio_format_t format, int inChannelCount,
-            int32_t sampleRate, src_quality quality=DEFAULT_QUALITY);
-
-    virtual ~AudioResampler();
-
-    virtual void init() = 0;
-    virtual void setSampleRate(int32_t inSampleRate);
-    virtual void setVolume(float left, float right);
-
-    // Resample int16_t samples from provider and accumulate into 'out'.
-    // A mono provider delivers a sequence of samples.
-    // A stereo provider delivers a sequence of interleaved pairs of samples.
-    //
-    // In either case, 'out' holds interleaved pairs of fixed-point Q4.27.
-    // That is, for a mono provider, there is an implicit up-channeling.
-    // Since this method accumulates, the caller is responsible for clearing 'out' initially.
-    //
-    // For a float resampler, 'out' holds interleaved pairs of float samples.
-    //
-    // Multichannel interleaved frames for n > 2 is supported for quality DYN_LOW_QUALITY,
-    // DYN_MED_QUALITY, and DYN_HIGH_QUALITY.
-    //
-    // Returns the number of frames resampled into the out buffer.
-    virtual size_t resample(int32_t* out, size_t outFrameCount,
-            AudioBufferProvider* provider) = 0;
-
-    virtual void reset();
-    virtual size_t getUnreleasedFrames() const { return mInputIndex; }
-
-    // called from destructor, so must not be virtual
-    src_quality getQuality() const { return mQuality; }
-
-protected:
-    // number of bits for phase fraction - 30 bits allows nearly 2x downsampling
-    static const int kNumPhaseBits = 30;
-
-    // phase mask for fraction
-    static const uint32_t kPhaseMask = (1LU<<kNumPhaseBits)-1;
-
-    // multiplier to calculate fixed point phase increment
-    static const double kPhaseMultiplier;
-
-    AudioResampler(int inChannelCount, int32_t sampleRate, src_quality quality);
-
-    // prevent copying
-    AudioResampler(const AudioResampler&);
-    AudioResampler& operator=(const AudioResampler&);
-
-    const int32_t mChannelCount;
-    const int32_t mSampleRate;
-    int32_t mInSampleRate;
-    AudioBufferProvider::Buffer mBuffer;
-    union {
-        int16_t mVolume[2];
-        uint32_t mVolumeRL;
-    };
-    int16_t mTargetVolume[2];
-    size_t mInputIndex;
-    int32_t mPhaseIncrement;
-    uint32_t mPhaseFraction;
-
-    // returns the inFrameCount required to generate outFrameCount frames.
-    //
-    // Placed here to be a consistent for all resamplers.
-    //
-    // Right now, we use the upper bound without regards to the current state of the
-    // input buffer using integer arithmetic, as follows:
-    //
-    // (static_cast<uint64_t>(outFrameCount)*mInSampleRate + (mSampleRate - 1))/mSampleRate;
-    //
-    // The double precision equivalent (float may not be precise enough):
-    // ceil(static_cast<double>(outFrameCount) * mInSampleRate / mSampleRate);
-    //
-    // this relies on the fact that the mPhaseIncrement is rounded down from
-    // #phases * mInSampleRate/mSampleRate and the fact that Sum(Floor(x)) <= Floor(Sum(x)).
-    // http://www.proofwiki.org/wiki/Sum_of_Floors_Not_Greater_Than_Floor_of_Sums
-    //
-    // (so long as double precision is computed accurately enough to be considered
-    // greater than or equal to the Floor(x) value in int32_t arithmetic; thus this
-    // will not necessarily hold for floats).
-    //
-    // TODO:
-    // Greater accuracy and a tight bound is obtained by:
-    // 1) subtract and adjust for the current state of the AudioBufferProvider buffer.
-    // 2) using the exact integer formula where (ignoring 64b casting)
-    //  inFrameCount = (mPhaseIncrement * (outFrameCount - 1) + mPhaseFraction) / phaseWrapLimit;
-    //  phaseWrapLimit is the wraparound (1 << kNumPhaseBits), if not specified explicitly.
-    //
-    inline size_t getInFrameCountRequired(size_t outFrameCount) {
-        return (static_cast<uint64_t>(outFrameCount)*mInSampleRate
-                + (mSampleRate - 1))/mSampleRate;
-    }
-
-    inline float clampFloatVol(float volume) {
-        if (volume > UNITY_GAIN_FLOAT) {
-            return UNITY_GAIN_FLOAT;
-        } else if (volume >= 0.) {
-            return volume;
-        }
-        return 0.;  // NaN or negative volume maps to 0.
-    }
-
-private:
-    const src_quality mQuality;
-
-    // Return 'true' if the quality level is supported without explicit request
-    static bool qualityIsSupported(src_quality quality);
-
-    // For pthread_once()
-    static void init_routine();
-
-    // Return the estimated CPU load for specific resampler in MHz.
-    // The absolute number is irrelevant, it's the relative values that matter.
-    static uint32_t qualityMHz(src_quality quality);
-};
-
-// ----------------------------------------------------------------------------
-} // namespace android
-
-#endif // ANDROID_AUDIO_RESAMPLER_H
diff --git a/include/system/audio-base-utils.h b/include/system/audio-base-utils.h
deleted file mode 100644
index 016a085..0000000
--- a/include/system/audio-base-utils.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2018 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_BASE_UTILS_H
-#define ANDROID_AUDIO_BASE_UTILS_H
-
-#include "audio-base.h"
-
-/** Define helper values to iterate over enum, extend them or checking value validity.
- *  Those values are compatible with the O corresponding enum values.
- *  They are not macro like similar values in audio.h to avoid conflicting
- *  with the libhardware_legacy audio.h.
- */
-enum {
-    /** Number of audio stream available to vendors. */
-    AUDIO_STREAM_PUBLIC_CNT = AUDIO_STREAM_ACCESSIBILITY + 1,
-
-#ifndef AUDIO_NO_SYSTEM_DECLARATIONS
-    /** Total number of stream handled by the policy*/
-    AUDIO_STREAM_FOR_POLICY_CNT= AUDIO_STREAM_REROUTING + 1,
-#endif
-
-   /** Total number of stream. */
-    AUDIO_STREAM_CNT          = AUDIO_STREAM_PATCH + 1,
-
-    AUDIO_SOURCE_MAX          = AUDIO_SOURCE_UNPROCESSED,
-    AUDIO_SOURCE_CNT          = AUDIO_SOURCE_MAX + 1,
-
-    AUDIO_MODE_MAX            = AUDIO_MODE_IN_COMMUNICATION,
-    AUDIO_MODE_CNT            = AUDIO_MODE_MAX + 1,
-
-    /** For retrocompatibility AUDIO_MODE_* and AUDIO_STREAM_* must be signed. */
-    AUDIO_DETAIL_NEGATIVE_VALUE = -1,
-};
-
-enum {
-    AUDIO_CHANNEL_OUT_ALL     = AUDIO_CHANNEL_OUT_FRONT_LEFT |
-                                AUDIO_CHANNEL_OUT_FRONT_RIGHT |
-                                AUDIO_CHANNEL_OUT_FRONT_CENTER |
-                                AUDIO_CHANNEL_OUT_LOW_FREQUENCY |
-                                AUDIO_CHANNEL_OUT_BACK_LEFT |
-                                AUDIO_CHANNEL_OUT_BACK_RIGHT |
-                                AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER |
-                                AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER |
-                                AUDIO_CHANNEL_OUT_BACK_CENTER |
-                                AUDIO_CHANNEL_OUT_SIDE_LEFT |
-                                AUDIO_CHANNEL_OUT_SIDE_RIGHT |
-                                AUDIO_CHANNEL_OUT_TOP_CENTER |
-                                AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT |
-                                AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER |
-                                AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT |
-                                AUDIO_CHANNEL_OUT_TOP_BACK_LEFT |
-                                AUDIO_CHANNEL_OUT_TOP_BACK_CENTER |
-                                AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT |
-                                AUDIO_CHANNEL_OUT_TOP_SIDE_LEFT |
-                                AUDIO_CHANNEL_OUT_TOP_SIDE_RIGHT,
-
-    AUDIO_CHANNEL_IN_ALL      = AUDIO_CHANNEL_IN_LEFT |
-                                AUDIO_CHANNEL_IN_RIGHT |
-                                AUDIO_CHANNEL_IN_FRONT |
-                                AUDIO_CHANNEL_IN_BACK|
-                                AUDIO_CHANNEL_IN_LEFT_PROCESSED |
-                                AUDIO_CHANNEL_IN_RIGHT_PROCESSED |
-                                AUDIO_CHANNEL_IN_FRONT_PROCESSED |
-                                AUDIO_CHANNEL_IN_BACK_PROCESSED|
-                                AUDIO_CHANNEL_IN_PRESSURE |
-                                AUDIO_CHANNEL_IN_X_AXIS |
-                                AUDIO_CHANNEL_IN_Y_AXIS |
-                                AUDIO_CHANNEL_IN_Z_AXIS |
-                                AUDIO_CHANNEL_IN_VOICE_UPLINK |
-                                AUDIO_CHANNEL_IN_VOICE_DNLINK |
-                                AUDIO_CHANNEL_IN_BACK_LEFT |
-                                AUDIO_CHANNEL_IN_BACK_RIGHT |
-                                AUDIO_CHANNEL_IN_CENTER |
-                                AUDIO_CHANNEL_IN_LOW_FREQUENCY |
-                                AUDIO_CHANNEL_IN_TOP_LEFT |
-                                AUDIO_CHANNEL_IN_TOP_RIGHT,
-
-    AUDIO_DEVICE_OUT_ALL      = AUDIO_DEVICE_OUT_EARPIECE |
-                                AUDIO_DEVICE_OUT_SPEAKER |
-                                AUDIO_DEVICE_OUT_WIRED_HEADSET |
-                                AUDIO_DEVICE_OUT_WIRED_HEADPHONE |
-                                AUDIO_DEVICE_OUT_BLUETOOTH_SCO |
-                                AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
-                                AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT |
-                                AUDIO_DEVICE_OUT_BLUETOOTH_A2DP |
-                                AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
-                                AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER |
-                                AUDIO_DEVICE_OUT_HDMI |
-                                AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET |
-                                AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET |
-                                AUDIO_DEVICE_OUT_USB_ACCESSORY |
-                                AUDIO_DEVICE_OUT_USB_DEVICE |
-                                AUDIO_DEVICE_OUT_REMOTE_SUBMIX |
-                                AUDIO_DEVICE_OUT_TELEPHONY_TX |
-                                AUDIO_DEVICE_OUT_LINE |
-                                AUDIO_DEVICE_OUT_HDMI_ARC |
-                                AUDIO_DEVICE_OUT_SPDIF |
-                                AUDIO_DEVICE_OUT_FM |
-                                AUDIO_DEVICE_OUT_AUX_LINE |
-                                AUDIO_DEVICE_OUT_SPEAKER_SAFE |
-                                AUDIO_DEVICE_OUT_IP |
-                                AUDIO_DEVICE_OUT_BUS |
-                                AUDIO_DEVICE_OUT_PROXY |
-                                AUDIO_DEVICE_OUT_USB_HEADSET |
-                                AUDIO_DEVICE_OUT_HEARING_AID |
-                                AUDIO_DEVICE_OUT_ECHO_CANCELLER |
-                                AUDIO_DEVICE_OUT_DEFAULT,
-
-    AUDIO_DEVICE_OUT_ALL_A2DP = AUDIO_DEVICE_OUT_BLUETOOTH_A2DP |
-                                AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
-                                AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER,
-
-    AUDIO_DEVICE_OUT_ALL_SCO  = AUDIO_DEVICE_OUT_BLUETOOTH_SCO |
-                                AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
-                                AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT,
-
-    AUDIO_DEVICE_OUT_ALL_USB  = AUDIO_DEVICE_OUT_USB_ACCESSORY |
-                                AUDIO_DEVICE_OUT_USB_DEVICE |
-                                AUDIO_DEVICE_OUT_USB_HEADSET,
-
-    AUDIO_DEVICE_IN_ALL       = AUDIO_DEVICE_IN_COMMUNICATION |
-                                AUDIO_DEVICE_IN_AMBIENT |
-                                AUDIO_DEVICE_IN_BUILTIN_MIC |
-                                AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET |
-                                AUDIO_DEVICE_IN_WIRED_HEADSET |
-                                AUDIO_DEVICE_IN_HDMI |
-                                AUDIO_DEVICE_IN_TELEPHONY_RX |
-                                AUDIO_DEVICE_IN_BACK_MIC |
-                                AUDIO_DEVICE_IN_REMOTE_SUBMIX |
-                                AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET |
-                                AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET |
-                                AUDIO_DEVICE_IN_USB_ACCESSORY |
-                                AUDIO_DEVICE_IN_USB_DEVICE |
-                                AUDIO_DEVICE_IN_FM_TUNER |
-                                AUDIO_DEVICE_IN_TV_TUNER |
-                                AUDIO_DEVICE_IN_LINE |
-                                AUDIO_DEVICE_IN_SPDIF |
-                                AUDIO_DEVICE_IN_BLUETOOTH_A2DP |
-                                AUDIO_DEVICE_IN_LOOPBACK |
-                                AUDIO_DEVICE_IN_IP |
-                                AUDIO_DEVICE_IN_BUS |
-                                AUDIO_DEVICE_IN_PROXY |
-                                AUDIO_DEVICE_IN_USB_HEADSET |
-                                AUDIO_DEVICE_IN_BLUETOOTH_BLE |
-                                AUDIO_DEVICE_IN_DEFAULT,
-
-    AUDIO_DEVICE_IN_ALL_SCO   = AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET,
-
-    AUDIO_DEVICE_IN_ALL_USB   = AUDIO_DEVICE_IN_USB_ACCESSORY |
-                                AUDIO_DEVICE_IN_USB_DEVICE |
-                                AUDIO_DEVICE_IN_USB_HEADSET,
-
-    AUDIO_USAGE_MAX           = AUDIO_USAGE_ASSISTANT,
-    AUDIO_USAGE_CNT           = AUDIO_USAGE_ASSISTANT + 1,
-
-    AUDIO_PORT_CONFIG_ALL     = AUDIO_PORT_CONFIG_SAMPLE_RATE |
-                                AUDIO_PORT_CONFIG_CHANNEL_MASK |
-                                AUDIO_PORT_CONFIG_FORMAT |
-                                AUDIO_PORT_CONFIG_GAIN,
-}; // enum
-
-
-#endif  // ANDROID_AUDIO_BASE_UTILS_H
diff --git a/include/system/audio-base.h b/include/system/audio-base.h
deleted file mode 100644
index 4eb2808..0000000
--- a/include/system/audio-base.h
+++ /dev/null
@@ -1,457 +0,0 @@
-// This file is autogenerated by hidl-gen
-// then manualy edited for retrocompatiblity
-// Source: android.hardware.audio.common@4.0
-// Root: android.hardware:hardware/interfaces
-
-#ifndef HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_COMMON_V4_0_EXPORTED_CONSTANTS_H_
-#define HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_COMMON_V4_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,
-#ifndef AUDIO_NO_SYSTEM_DECLARATIONS
-    /** For dynamic policy output mixes. Only used by the audio policy */
-    AUDIO_STREAM_REROUTING = 11,
-    /** For audio flinger tracks volume. Only used by the audioflinger */
-    AUDIO_STREAM_PATCH = 12,
-#endif // AUDIO_NO_SYSTEM_DECLARATIONS
-} 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_FM_TUNER = 1998,
-#ifndef AUDIO_NO_SYSTEM_DECLARATIONS
-    /**
-     * A low-priority, preemptible audio source for for background software
-     * hotword detection. Same tuning as VOICE_RECOGNITION.
-     * Used only internally by the framework.
-     */
-    AUDIO_SOURCE_HOTWORD = 1999,
-#endif // AUDIO_NO_SYSTEM_DECLARATIONS
-} 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             = 0xFFFFFFFFu,
-    AUDIO_FORMAT_DEFAULT             = 0,
-    AUDIO_FORMAT_PCM                 = 0x00000000u,
-    AUDIO_FORMAT_MP3                 = 0x01000000u,
-    AUDIO_FORMAT_AMR_NB              = 0x02000000u,
-    AUDIO_FORMAT_AMR_WB              = 0x03000000u,
-    AUDIO_FORMAT_AAC                 = 0x04000000u,
-    AUDIO_FORMAT_HE_AAC_V1           = 0x05000000u,
-    AUDIO_FORMAT_HE_AAC_V2           = 0x06000000u,
-    AUDIO_FORMAT_VORBIS              = 0x07000000u,
-    AUDIO_FORMAT_OPUS                = 0x08000000u,
-    AUDIO_FORMAT_AC3                 = 0x09000000u,
-    AUDIO_FORMAT_E_AC3               = 0x0A000000u,
-    AUDIO_FORMAT_DTS                 = 0x0B000000u,
-    AUDIO_FORMAT_DTS_HD              = 0x0C000000u,
-    AUDIO_FORMAT_IEC61937            = 0x0D000000u,
-    AUDIO_FORMAT_DOLBY_TRUEHD        = 0x0E000000u,
-    AUDIO_FORMAT_EVRC                = 0x10000000u,
-    AUDIO_FORMAT_EVRCB               = 0x11000000u,
-    AUDIO_FORMAT_EVRCWB              = 0x12000000u,
-    AUDIO_FORMAT_EVRCNW              = 0x13000000u,
-    AUDIO_FORMAT_AAC_ADIF            = 0x14000000u,
-    AUDIO_FORMAT_WMA                 = 0x15000000u,
-    AUDIO_FORMAT_WMA_PRO             = 0x16000000u,
-    AUDIO_FORMAT_AMR_WB_PLUS         = 0x17000000u,
-    AUDIO_FORMAT_MP2                 = 0x18000000u,
-    AUDIO_FORMAT_QCELP               = 0x19000000u,
-    AUDIO_FORMAT_DSD                 = 0x1A000000u,
-    AUDIO_FORMAT_FLAC                = 0x1B000000u,
-    AUDIO_FORMAT_ALAC                = 0x1C000000u,
-    AUDIO_FORMAT_APE                 = 0x1D000000u,
-    AUDIO_FORMAT_AAC_ADTS            = 0x1E000000u,
-    AUDIO_FORMAT_SBC                 = 0x1F000000u,
-    AUDIO_FORMAT_APTX                = 0x20000000u,
-    AUDIO_FORMAT_APTX_HD             = 0x21000000u,
-    AUDIO_FORMAT_AC4                 = 0x22000000u,
-    AUDIO_FORMAT_LDAC                = 0x23000000u,
-    AUDIO_FORMAT_MAT                 = 0x24000000u,
-    AUDIO_FORMAT_MAIN_MASK           = 0xFF000000u,
-    AUDIO_FORMAT_SUB_MASK            = 0x00FFFFFFu,
-
-    /* Subformats */
-    AUDIO_FORMAT_PCM_SUB_16_BIT        = 0x1u,
-    AUDIO_FORMAT_PCM_SUB_8_BIT         = 0x2u,
-    AUDIO_FORMAT_PCM_SUB_32_BIT        = 0x3u,
-    AUDIO_FORMAT_PCM_SUB_8_24_BIT      = 0x4u,
-    AUDIO_FORMAT_PCM_SUB_FLOAT         = 0x5u,
-    AUDIO_FORMAT_PCM_SUB_24_BIT_PACKED = 0x6u,
-
-    AUDIO_FORMAT_MP3_SUB_NONE          = 0x0u,
-
-    AUDIO_FORMAT_AMR_SUB_NONE          = 0x0u,
-
-    AUDIO_FORMAT_AAC_SUB_MAIN          = 0x1u,
-    AUDIO_FORMAT_AAC_SUB_LC            = 0x2u,
-    AUDIO_FORMAT_AAC_SUB_SSR           = 0x4u,
-    AUDIO_FORMAT_AAC_SUB_LTP           = 0x8u,
-    AUDIO_FORMAT_AAC_SUB_HE_V1         = 0x10u,
-    AUDIO_FORMAT_AAC_SUB_SCALABLE      = 0x20u,
-    AUDIO_FORMAT_AAC_SUB_ERLC          = 0x40u,
-    AUDIO_FORMAT_AAC_SUB_LD            = 0x80u,
-    AUDIO_FORMAT_AAC_SUB_HE_V2         = 0x100u,
-    AUDIO_FORMAT_AAC_SUB_ELD           = 0x200u,
-    AUDIO_FORMAT_AAC_SUB_XHE           = 0x300u,
-
-    AUDIO_FORMAT_VORBIS_SUB_NONE       = 0x0u,
-
-    AUDIO_FORMAT_E_AC3_SUB_JOC         = 0x1u,
-
-    AUDIO_FORMAT_MAT_SUB_1_0           = 0x1u,
-    AUDIO_FORMAT_MAT_SUB_2_0           = 0x2u,
-    AUDIO_FORMAT_MAT_SUB_2_1           = 0x3u,
-
-    /* Aliases */
-    AUDIO_FORMAT_PCM_16_BIT            = 0x1u,        // (PCM | PCM_SUB_16_BIT)
-    AUDIO_FORMAT_PCM_8_BIT             = 0x2u,        // (PCM | PCM_SUB_8_BIT)
-    AUDIO_FORMAT_PCM_32_BIT            = 0x3u,        // (PCM | PCM_SUB_32_BIT)
-    AUDIO_FORMAT_PCM_8_24_BIT          = 0x4u,        // (PCM | PCM_SUB_8_24_BIT)
-    AUDIO_FORMAT_PCM_FLOAT             = 0x5u,        // (PCM | PCM_SUB_FLOAT)
-    AUDIO_FORMAT_PCM_24_BIT_PACKED     = 0x6u,        // (PCM | PCM_SUB_24_BIT_PACKED)
-    AUDIO_FORMAT_AAC_MAIN              = 0x4000001u,  // (AAC | AAC_SUB_MAIN)
-    AUDIO_FORMAT_AAC_LC                = 0x4000002u,  // (AAC | AAC_SUB_LC)
-    AUDIO_FORMAT_AAC_SSR               = 0x4000004u,  // (AAC | AAC_SUB_SSR)
-    AUDIO_FORMAT_AAC_LTP               = 0x4000008u,  // (AAC | AAC_SUB_LTP)
-    AUDIO_FORMAT_AAC_HE_V1             = 0x4000010u,  // (AAC | AAC_SUB_HE_V1)
-    AUDIO_FORMAT_AAC_SCALABLE          = 0x4000020u,  // (AAC | AAC_SUB_SCALABLE)
-    AUDIO_FORMAT_AAC_ERLC              = 0x4000040u,  // (AAC | AAC_SUB_ERLC)
-    AUDIO_FORMAT_AAC_LD                = 0x4000080u,  // (AAC | AAC_SUB_LD)
-    AUDIO_FORMAT_AAC_HE_V2             = 0x4000100u,  // (AAC | AAC_SUB_HE_V2)
-    AUDIO_FORMAT_AAC_ELD               = 0x4000200u,  // (AAC | AAC_SUB_ELD)
-    AUDIO_FORMAT_AAC_XHE               = 0x4000300u,  // (AAC | AAC_SUB_XHE)
-    AUDIO_FORMAT_AAC_ADTS_MAIN         = 0x1e000001u, // (AAC_ADTS | AAC_SUB_MAIN)
-    AUDIO_FORMAT_AAC_ADTS_LC           = 0x1e000002u, // (AAC_ADTS | AAC_SUB_LC)
-    AUDIO_FORMAT_AAC_ADTS_SSR          = 0x1e000004u, // (AAC_ADTS | AAC_SUB_SSR)
-    AUDIO_FORMAT_AAC_ADTS_LTP          = 0x1e000008u, // (AAC_ADTS | AAC_SUB_LTP)
-    AUDIO_FORMAT_AAC_ADTS_HE_V1        = 0x1e000010u, // (AAC_ADTS | AAC_SUB_HE_V1)
-    AUDIO_FORMAT_AAC_ADTS_SCALABLE     = 0x1e000020u, // (AAC_ADTS | AAC_SUB_SCALABLE)
-    AUDIO_FORMAT_AAC_ADTS_ERLC         = 0x1e000040u, // (AAC_ADTS | AAC_SUB_ERLC)
-    AUDIO_FORMAT_AAC_ADTS_LD           = 0x1e000080u, // (AAC_ADTS | AAC_SUB_LD)
-    AUDIO_FORMAT_AAC_ADTS_HE_V2        = 0x1e000100u, // (AAC_ADTS | AAC_SUB_HE_V2)
-    AUDIO_FORMAT_AAC_ADTS_ELD          = 0x1e000200u, // (AAC_ADTS | AAC_SUB_ELD)
-    AUDIO_FORMAT_AAC_ADTS_XHE          = 0x1e000300u, // (AAC_ADTS | AAC_SUB_XHE)
-    AUDIO_FORMAT_E_AC3_JOC             = 0xA000001u,  // (E_AC3 | E_AC3_SUB_JOC)
-    AUDIO_FORMAT_MAT_1_0               = 0x24000001u, // (MAT | MAT_SUB_1_0)
-    AUDIO_FORMAT_MAT_2_0               = 0x24000002u, // (MAT | MAT_SUB_2_0)
-    AUDIO_FORMAT_MAT_2_1               = 0x24000003u, // (MAT | MAT_SUB_2_1)
-} audio_format_t;
-
-enum {
-    FCC_2 = 2,
-    FCC_8 = 8,
-};
-
-enum {
-    AUDIO_CHANNEL_REPRESENTATION_POSITION   = 0x0u,
-    AUDIO_CHANNEL_REPRESENTATION_INDEX      = 0x2u,
-    AUDIO_CHANNEL_NONE                      = 0x0u,
-    AUDIO_CHANNEL_INVALID                   = 0xC0000000u,
-
-    AUDIO_CHANNEL_OUT_FRONT_LEFT            = 0x1u,
-    AUDIO_CHANNEL_OUT_FRONT_RIGHT           = 0x2u,
-    AUDIO_CHANNEL_OUT_FRONT_CENTER          = 0x4u,
-    AUDIO_CHANNEL_OUT_LOW_FREQUENCY         = 0x8u,
-    AUDIO_CHANNEL_OUT_BACK_LEFT             = 0x10u,
-    AUDIO_CHANNEL_OUT_BACK_RIGHT            = 0x20u,
-    AUDIO_CHANNEL_OUT_FRONT_LEFT_OF_CENTER  = 0x40u,
-    AUDIO_CHANNEL_OUT_FRONT_RIGHT_OF_CENTER = 0x80u,
-    AUDIO_CHANNEL_OUT_BACK_CENTER           = 0x100u,
-    AUDIO_CHANNEL_OUT_SIDE_LEFT             = 0x200u,
-    AUDIO_CHANNEL_OUT_SIDE_RIGHT            = 0x400u,
-    AUDIO_CHANNEL_OUT_TOP_CENTER            = 0x800u,
-    AUDIO_CHANNEL_OUT_TOP_FRONT_LEFT        = 0x1000u,
-    AUDIO_CHANNEL_OUT_TOP_FRONT_CENTER      = 0x2000u,
-    AUDIO_CHANNEL_OUT_TOP_FRONT_RIGHT       = 0x4000u,
-    AUDIO_CHANNEL_OUT_TOP_BACK_LEFT         = 0x8000u,
-    AUDIO_CHANNEL_OUT_TOP_BACK_CENTER       = 0x10000u,
-    AUDIO_CHANNEL_OUT_TOP_BACK_RIGHT        = 0x20000u,
-    AUDIO_CHANNEL_OUT_TOP_SIDE_LEFT         = 0x40000u,
-    AUDIO_CHANNEL_OUT_TOP_SIDE_RIGHT        = 0x80000u,
-    AUDIO_CHANNEL_OUT_MONO                  = 0x1u,     // OUT_FRONT_LEFT
-    AUDIO_CHANNEL_OUT_STEREO                = 0x3u,     // OUT_FRONT_LEFT | OUT_FRONT_RIGHT
-    AUDIO_CHANNEL_OUT_2POINT1               = 0xBu,     // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_LOW_FREQUENCY
-    AUDIO_CHANNEL_OUT_2POINT0POINT2         = 0xC0003u, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT
-    AUDIO_CHANNEL_OUT_2POINT1POINT2         = 0xC000Bu, // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT | OUT_LOW_FREQUENCY
-    AUDIO_CHANNEL_OUT_3POINT0POINT2         = 0xC0007u, // OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT
-    AUDIO_CHANNEL_OUT_3POINT1POINT2         = 0xC000Fu, // OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT | OUT_LOW_FREQUENCY
-    AUDIO_CHANNEL_OUT_QUAD                  = 0x33u,    // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_BACK_LEFT | OUT_BACK_RIGHT
-    AUDIO_CHANNEL_OUT_QUAD_BACK             = 0x33u,    // OUT_QUAD
-    AUDIO_CHANNEL_OUT_QUAD_SIDE             = 0x603u,   // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_SIDE_LEFT | OUT_SIDE_RIGHT
-    AUDIO_CHANNEL_OUT_SURROUND              = 0x107u,   // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_FRONT_CENTER | OUT_BACK_CENTER
-    AUDIO_CHANNEL_OUT_PENTA                 = 0x37u,    // OUT_QUAD | OUT_FRONT_CENTER
-    AUDIO_CHANNEL_OUT_5POINT1               = 0x3Fu,    // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_FRONT_CENTER | OUT_LOW_FREQUENCY | OUT_BACK_LEFT | OUT_BACK_RIGHT
-    AUDIO_CHANNEL_OUT_5POINT1_BACK          = 0x3Fu,    // OUT_5POINT1
-    AUDIO_CHANNEL_OUT_5POINT1_SIDE          = 0x60Fu,   // OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_FRONT_CENTER | OUT_LOW_FREQUENCY | OUT_SIDE_LEFT | OUT_SIDE_RIGHT
-    AUDIO_CHANNEL_OUT_5POINT1POINT2         = 0xC003Fu, // OUT_5POINT1 | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT
-    AUDIO_CHANNEL_OUT_5POINT1POINT4         = 0x2D03Fu, // OUT_5POINT1 | OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_RIGHT | OUT_TOP_BACK_LEFT | OUT_TOP_BACK_RIGHT
-    AUDIO_CHANNEL_OUT_6POINT1               = 0x13Fu,   // 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               = 0x63Fu,   // 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_7POINT1POINT2         = 0xC063Fu, // OUT_7POINT1 | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT
-    AUDIO_CHANNEL_OUT_7POINT1POINT4         = 0x2D63Fu, // OUT_7POINT1 | OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_RIGHT | OUT_TOP_BACK_LEFT | OUT_TOP_BACK_RIGHT
-
-    AUDIO_CHANNEL_IN_LEFT                   = 0x4u,
-    AUDIO_CHANNEL_IN_RIGHT                  = 0x8u,
-    AUDIO_CHANNEL_IN_FRONT                  = 0x10u,
-    AUDIO_CHANNEL_IN_BACK                   = 0x20u,
-    AUDIO_CHANNEL_IN_LEFT_PROCESSED         = 0x40u,
-    AUDIO_CHANNEL_IN_RIGHT_PROCESSED        = 0x80u,
-    AUDIO_CHANNEL_IN_FRONT_PROCESSED        = 0x100u,
-    AUDIO_CHANNEL_IN_BACK_PROCESSED         = 0x200u,
-    AUDIO_CHANNEL_IN_PRESSURE               = 0x400u,
-    AUDIO_CHANNEL_IN_X_AXIS                 = 0x800u,
-    AUDIO_CHANNEL_IN_Y_AXIS                 = 0x1000u,
-    AUDIO_CHANNEL_IN_Z_AXIS                 = 0x2000u,
-    AUDIO_CHANNEL_IN_BACK_LEFT              = 0x10000u,
-    AUDIO_CHANNEL_IN_BACK_RIGHT             = 0x20000u,
-    AUDIO_CHANNEL_IN_CENTER                 = 0x40000u,
-    AUDIO_CHANNEL_IN_LOW_FREQUENCY          = 0x100000u,
-    AUDIO_CHANNEL_IN_TOP_LEFT               = 0x200000u,
-    AUDIO_CHANNEL_IN_TOP_RIGHT              = 0x400000u,
-    AUDIO_CHANNEL_IN_VOICE_UPLINK           = 0x4000u,
-    AUDIO_CHANNEL_IN_VOICE_DNLINK           = 0x8000u,
-    AUDIO_CHANNEL_IN_MONO                   = 0x10u,     // IN_FRONT
-    AUDIO_CHANNEL_IN_STEREO                 = 0xCu,      // IN_LEFT | IN_RIGHT
-    AUDIO_CHANNEL_IN_FRONT_BACK             = 0x30u,     // IN_FRONT | IN_BACK
-    AUDIO_CHANNEL_IN_6                      = 0xFCu,     // IN_LEFT | IN_RIGHT | IN_FRONT | IN_BACK | IN_LEFT_PROCESSED | IN_RIGHT_PROCESSED
-    AUDIO_CHANNEL_IN_2POINT0POINT2          = 0x60000Cu, // IN_LEFT | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT
-    AUDIO_CHANNEL_IN_2POINT1POINT2          = 0x70000Cu, // IN_LEFT | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT | IN_LOW_FREQUENCY
-    AUDIO_CHANNEL_IN_3POINT0POINT2          = 0x64000Cu, // IN_LEFT | IN_CENTER | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT
-    AUDIO_CHANNEL_IN_3POINT1POINT2          = 0x74000Cu, // IN_LEFT | IN_CENTER | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT | IN_LOW_FREQUENCY
-    AUDIO_CHANNEL_IN_5POINT1                = 0x17000Cu, // IN_LEFT | IN_CENTER | IN_RIGHT | IN_BACK_LEFT | IN_BACK_RIGHT | IN_LOW_FREQUENCY
-    AUDIO_CHANNEL_IN_VOICE_UPLINK_MONO      = 0x4010u,   // IN_VOICE_UPLINK | IN_MONO
-    AUDIO_CHANNEL_IN_VOICE_DNLINK_MONO      = 0x8010u,   // IN_VOICE_DNLINK | IN_MONO
-    AUDIO_CHANNEL_IN_VOICE_CALL_MONO        = 0xC010u,   // IN_VOICE_UPLINK_MONO | IN_VOICE_DNLINK_MONO
-
-    AUDIO_CHANNEL_COUNT_MAX                 = 30u,
-    AUDIO_CHANNEL_INDEX_HDR                 = 0x80000000u, // REPRESENTATION_INDEX << COUNT_MAX
-    AUDIO_CHANNEL_INDEX_MASK_1              = 0x80000001u, // INDEX_HDR | (1 << 1) - 1
-    AUDIO_CHANNEL_INDEX_MASK_2              = 0x80000003u, // INDEX_HDR | (1 << 2) - 1
-    AUDIO_CHANNEL_INDEX_MASK_3              = 0x80000007u, // INDEX_HDR | (1 << 3) - 1
-    AUDIO_CHANNEL_INDEX_MASK_4              = 0x8000000Fu, // INDEX_HDR | (1 << 4) - 1
-    AUDIO_CHANNEL_INDEX_MASK_5              = 0x8000001Fu, // INDEX_HDR | (1 << 5) - 1
-    AUDIO_CHANNEL_INDEX_MASK_6              = 0x8000003Fu, // INDEX_HDR | (1 << 6) - 1
-    AUDIO_CHANNEL_INDEX_MASK_7              = 0x8000007Fu, // INDEX_HDR | (1 << 7) - 1
-    AUDIO_CHANNEL_INDEX_MASK_8              = 0x800000FFu, // INDEX_HDR | (1 << 8) - 1
-};
-
-typedef enum {
-#ifndef AUDIO_NO_SYSTEM_DECLARATIONS
-    AUDIO_MODE_INVALID = -2, // (-2)
-    AUDIO_MODE_CURRENT = -1, // (-1)
-#endif // AUDIO_NO_SYSTEM_DECLARATIONS
-    AUDIO_MODE_NORMAL = 0,
-    AUDIO_MODE_RINGTONE = 1,
-    AUDIO_MODE_IN_CALL = 2,
-    AUDIO_MODE_IN_COMMUNICATION = 3,
-} audio_mode_t;
-
-enum {
-    AUDIO_DEVICE_NONE                          = 0x0u,
-    AUDIO_DEVICE_BIT_IN                        = 0x80000000u,
-    AUDIO_DEVICE_BIT_DEFAULT                   = 0x40000000u,
-
-    AUDIO_DEVICE_OUT_EARPIECE                  = 0x1u,
-    AUDIO_DEVICE_OUT_SPEAKER                   = 0x2u,
-    AUDIO_DEVICE_OUT_WIRED_HEADSET             = 0x4u,
-    AUDIO_DEVICE_OUT_WIRED_HEADPHONE           = 0x8u,
-    AUDIO_DEVICE_OUT_BLUETOOTH_SCO             = 0x10u,
-    AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET     = 0x20u,
-    AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT      = 0x40u,
-    AUDIO_DEVICE_OUT_BLUETOOTH_A2DP            = 0x80u,
-    AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100u,
-    AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER    = 0x200u,
-    AUDIO_DEVICE_OUT_AUX_DIGITAL               = 0x400u,
-    AUDIO_DEVICE_OUT_HDMI                      = 0x400u,      // OUT_AUX_DIGITAL
-    AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET         = 0x800u,
-    AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET         = 0x1000u,
-    AUDIO_DEVICE_OUT_USB_ACCESSORY             = 0x2000u,
-    AUDIO_DEVICE_OUT_USB_DEVICE                = 0x4000u,
-    AUDIO_DEVICE_OUT_REMOTE_SUBMIX             = 0x8000u,
-    AUDIO_DEVICE_OUT_TELEPHONY_TX              = 0x10000u,
-    AUDIO_DEVICE_OUT_LINE                      = 0x20000u,
-    AUDIO_DEVICE_OUT_HDMI_ARC                  = 0x40000u,
-    AUDIO_DEVICE_OUT_SPDIF                     = 0x80000u,
-    AUDIO_DEVICE_OUT_FM                        = 0x100000u,
-    AUDIO_DEVICE_OUT_AUX_LINE                  = 0x200000u,
-    AUDIO_DEVICE_OUT_SPEAKER_SAFE              = 0x400000u,
-    AUDIO_DEVICE_OUT_IP                        = 0x800000u,
-    AUDIO_DEVICE_OUT_BUS                       = 0x1000000u,
-    AUDIO_DEVICE_OUT_PROXY                     = 0x2000000u,
-    AUDIO_DEVICE_OUT_USB_HEADSET               = 0x4000000u,
-    AUDIO_DEVICE_OUT_HEARING_AID               = 0x8000000u,
-    AUDIO_DEVICE_OUT_ECHO_CANCELLER            = 0x10000000u,
-    AUDIO_DEVICE_OUT_DEFAULT                   = 0x40000000u, // BIT_DEFAULT
-
-    AUDIO_DEVICE_IN_COMMUNICATION              = 0x80000001u, // BIT_IN | 0x1
-    AUDIO_DEVICE_IN_AMBIENT                    = 0x80000002u, // BIT_IN | 0x2
-    AUDIO_DEVICE_IN_BUILTIN_MIC                = 0x80000004u, // BIT_IN | 0x4
-    AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET      = 0x80000008u, // BIT_IN | 0x8
-    AUDIO_DEVICE_IN_WIRED_HEADSET              = 0x80000010u, // BIT_IN | 0x10
-    AUDIO_DEVICE_IN_AUX_DIGITAL                = 0x80000020u, // BIT_IN | 0x20
-    AUDIO_DEVICE_IN_HDMI                       = 0x80000020u, // IN_AUX_DIGITAL
-    AUDIO_DEVICE_IN_VOICE_CALL                 = 0x80000040u, // BIT_IN | 0x40
-    AUDIO_DEVICE_IN_TELEPHONY_RX               = 0x80000040u, // IN_VOICE_CALL
-    AUDIO_DEVICE_IN_BACK_MIC                   = 0x80000080u, // BIT_IN | 0x80
-    AUDIO_DEVICE_IN_REMOTE_SUBMIX              = 0x80000100u, // BIT_IN | 0x100
-    AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET          = 0x80000200u, // BIT_IN | 0x200
-    AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET          = 0x80000400u, // BIT_IN | 0x400
-    AUDIO_DEVICE_IN_USB_ACCESSORY              = 0x80000800u, // BIT_IN | 0x800
-    AUDIO_DEVICE_IN_USB_DEVICE                 = 0x80001000u, // BIT_IN | 0x1000
-    AUDIO_DEVICE_IN_FM_TUNER                   = 0x80002000u, // BIT_IN | 0x2000
-    AUDIO_DEVICE_IN_TV_TUNER                   = 0x80004000u, // BIT_IN | 0x4000
-    AUDIO_DEVICE_IN_LINE                       = 0x80008000u, // BIT_IN | 0x8000
-    AUDIO_DEVICE_IN_SPDIF                      = 0x80010000u, // BIT_IN | 0x10000
-    AUDIO_DEVICE_IN_BLUETOOTH_A2DP             = 0x80020000u, // BIT_IN | 0x20000
-    AUDIO_DEVICE_IN_LOOPBACK                   = 0x80040000u, // BIT_IN | 0x40000
-    AUDIO_DEVICE_IN_IP                         = 0x80080000u, // BIT_IN | 0x80000
-    AUDIO_DEVICE_IN_BUS                        = 0x80100000u, // BIT_IN | 0x100000
-    AUDIO_DEVICE_IN_PROXY                      = 0x81000000u, // BIT_IN | 0x1000000
-    AUDIO_DEVICE_IN_USB_HEADSET                = 0x82000000u, // BIT_IN | 0x2000000
-    AUDIO_DEVICE_IN_BLUETOOTH_BLE              = 0x84000000u, // BIT_IN | 0x4000000
-    AUDIO_DEVICE_IN_DEFAULT                    = 0xC0000000u, // BIT_IN | BIT_DEFAULT
-};
-
-typedef enum {
-    AUDIO_OUTPUT_FLAG_NONE             = 0x0,
-    AUDIO_OUTPUT_FLAG_DIRECT           = 0x1,
-    AUDIO_OUTPUT_FLAG_PRIMARY          = 0x2,
-    AUDIO_OUTPUT_FLAG_FAST             = 0x4,
-    AUDIO_OUTPUT_FLAG_DEEP_BUFFER      = 0x8,
-    AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD = 0x10,
-    AUDIO_OUTPUT_FLAG_NON_BLOCKING     = 0x20,
-    AUDIO_OUTPUT_FLAG_HW_AV_SYNC       = 0x40,
-    AUDIO_OUTPUT_FLAG_TTS              = 0x80,
-    AUDIO_OUTPUT_FLAG_RAW              = 0x100,
-    AUDIO_OUTPUT_FLAG_SYNC             = 0x200,
-    AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO  = 0x400,
-    AUDIO_OUTPUT_FLAG_DIRECT_PCM       = 0x2000,
-    AUDIO_OUTPUT_FLAG_MMAP_NOIRQ       = 0x4000,
-    AUDIO_OUTPUT_FLAG_VOIP_RX          = 0x8000,
-    AUDIO_OUTPUT_FLAG_INCALL_MUSIC     = 0x10000,
-} audio_output_flags_t;
-
-typedef enum {
-    AUDIO_INPUT_FLAG_NONE       = 0x0,
-    AUDIO_INPUT_FLAG_FAST       = 0x1,
-    AUDIO_INPUT_FLAG_HW_HOTWORD = 0x2,
-    AUDIO_INPUT_FLAG_RAW        = 0x4,
-    AUDIO_INPUT_FLAG_SYNC       = 0x8,
-    AUDIO_INPUT_FLAG_MMAP_NOIRQ = 0x10,
-    AUDIO_INPUT_FLAG_VOIP_TX    = 0x20,
-    AUDIO_INPUT_FLAG_HW_AV_SYNC = 0x40,
-#ifndef AUDIO_NO_SYSTEM_DECLARATIONS  // TODO: Expose at HAL interface, remove FRAMEWORK_FLAGS mask
-    AUDIO_INPUT_FLAG_DIRECT     = 0x80,
-    AUDIO_INPUT_FRAMEWORK_FLAGS = AUDIO_INPUT_FLAG_DIRECT,
-#endif
-} 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,
-#ifndef AUDIO_NO_SYSTEM_DECLARATIONS
-    AUDIO_USAGE_NOTIFICATION_COMMUNICATION_REQUEST = 7,
-    AUDIO_USAGE_NOTIFICATION_COMMUNICATION_INSTANT = 8,
-    AUDIO_USAGE_NOTIFICATION_COMMUNICATION_DELAYED = 9,
-    AUDIO_USAGE_NOTIFICATION_EVENT = 10,
-#endif // AUDIO_NO_SYSTEM_DECLARATIONS
-    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_t;
-
-typedef enum {
-    AUDIO_CONTENT_TYPE_UNKNOWN = 0u,
-    AUDIO_CONTENT_TYPE_SPEECH = 1u,
-    AUDIO_CONTENT_TYPE_MUSIC = 2u,
-    AUDIO_CONTENT_TYPE_MOVIE = 3u,
-    AUDIO_CONTENT_TYPE_SONIFICATION = 4u,
-} audio_content_type_t;
-
-enum {
-    AUDIO_GAIN_MODE_JOINT    = 0x1u,
-    AUDIO_GAIN_MODE_CHANNELS = 0x2u,
-    AUDIO_GAIN_MODE_RAMP     = 0x4u,
-};
-
-typedef enum {
-    AUDIO_PORT_ROLE_NONE = 0,
-    AUDIO_PORT_ROLE_SOURCE = 1, // (::android::hardware::audio::common::V4_0::AudioPortRole.NONE implicitly + 1)
-    AUDIO_PORT_ROLE_SINK = 2, // (::android::hardware::audio::common::V4_0::AudioPortRole.SOURCE implicitly + 1)
-} audio_port_role_t;
-
-typedef enum {
-    AUDIO_PORT_TYPE_NONE = 0,
-    AUDIO_PORT_TYPE_DEVICE = 1, // (::android::hardware::audio::common::V4_0::AudioPortType.NONE implicitly + 1)
-    AUDIO_PORT_TYPE_MIX = 2, // (::android::hardware::audio::common::V4_0::AudioPortType.DEVICE implicitly + 1)
-    AUDIO_PORT_TYPE_SESSION = 3, // (::android::hardware::audio::common::V4_0::AudioPortType.MIX implicitly + 1)
-} audio_port_type_t;
-
-enum {
-    AUDIO_PORT_CONFIG_SAMPLE_RATE  = 0x1u,
-    AUDIO_PORT_CONFIG_CHANNEL_MASK = 0x2u,
-    AUDIO_PORT_CONFIG_FORMAT       = 0x4u,
-    AUDIO_PORT_CONFIG_GAIN         = 0x8u,
-#ifndef AUDIO_NO_SYSTEM_DECLARATIONS
-    AUDIO_PORT_CONFIG_FLAGS        = 0x10u,  // Absent from AudioPortConfigMask, framework only.
-#endif
-};
-
-typedef enum {
-    AUDIO_LATENCY_LOW = 0,
-    AUDIO_LATENCY_NORMAL = 1, // (::android::hardware::audio::common::V4_0::AudioMixLatencyClass.LOW implicitly + 1)
-} audio_mix_latency_class_t;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  // HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_COMMON_V4_0_EXPORTED_CONSTANTS_H_
diff --git a/include/system/audio.h b/include/system/audio.h
deleted file mode 100644
index 2295c3d..0000000
--- a/include/system/audio.h
+++ /dev/null
@@ -1,1390 +0,0 @@
-/*
- * 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 <string.h>
-#include <sys/cdefs.h>
-#include <sys/types.h>
-
-#include <cutils/bitops.h>
-
-#include "audio-base.h"
-#include "audio-base-utils.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;
-
-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);
-}
-
-/**
- * Expresses the convention when stereo audio samples are stored interleaved
- * in an array.  This should improve readability by allowing code to use
- * symbolic indices instead of hard-coded [0] and [1].
- *
- * For multi-channel beyond stereo, the platform convention is that channels
- * are interleaved in order from least significant channel mask bit to most
- * significant channel mask bit, with unused bits skipped.  Any exceptions
- * to this convention will be noted at the appropriate API.
- */
-enum {
-    AUDIO_INTERLEAVE_LEFT = 0,
-    AUDIO_INTERLEAVE_RIGHT = 1,
-};
-
-/* 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
-
-/* a union to store port configuration flags. Declared as a type so can be reused
-   in framework code */
-union audio_io_flags {
-    audio_input_flags_t  input;
-    audio_output_flags_t output;
-};
-
-/* 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 */
-#ifndef AUDIO_NO_SYSTEM_DECLARATIONS
-    union audio_io_flags     flags;        /* framework only: HW_AV_SYNC, DIRECT, ... */
-#endif
-    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 */
-};
-
-/** Metadata of a record track for an in stream. */
-typedef struct playback_track_metadata {
-    audio_usage_t usage;
-    audio_content_type_t content_type;
-    float gain; // Normalized linear volume. 0=silence, 1=0dbfs...
-} playback_track_metadata_t;
-
-/** Metadata of a playback track for an out stream. */
-typedef struct record_track_metadata {
-    audio_source_t source;
-    float gain; // Normalized linear volume. 0=silence, 1=0dbfs...
-} record_track_metadata_t;
-
-
-/******************************
- *  Helper functions
- *****************************/
-
-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_hearing_aid_out_device(audio_devices_t device)
-{
-    return device == AUDIO_DEVICE_OUT_HEARING_AID;
-}
-
-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 audio_channel_mask_t audio_channel_mask_in_to_out(audio_channel_mask_t in)
-{
-    switch (in) {
-    case AUDIO_CHANNEL_IN_MONO:
-        return AUDIO_CHANNEL_OUT_MONO;
-    case AUDIO_CHANNEL_IN_STEREO:
-        return AUDIO_CHANNEL_OUT_STEREO;
-    case AUDIO_CHANNEL_IN_5POINT1:
-        return AUDIO_CHANNEL_OUT_5POINT1;
-    case AUDIO_CHANNEL_IN_3POINT1POINT2:
-        return AUDIO_CHANNEL_OUT_3POINT1POINT2;
-    case AUDIO_CHANNEL_IN_3POINT0POINT2:
-        return AUDIO_CHANNEL_OUT_3POINT0POINT2;
-    case AUDIO_CHANNEL_IN_2POINT1POINT2:
-        return AUDIO_CHANNEL_OUT_2POINT1POINT2;
-    case AUDIO_CHANNEL_IN_2POINT0POINT2:
-        return AUDIO_CHANNEL_OUT_2POINT0POINT2;
-    default:
-        return AUDIO_CHANNEL_INVALID;
-    }
-}
-
-static inline audio_channel_mask_t audio_channel_mask_out_to_in(audio_channel_mask_t out)
-{
-    switch (out) {
-    case AUDIO_CHANNEL_OUT_MONO:
-        return AUDIO_CHANNEL_IN_MONO;
-    case AUDIO_CHANNEL_OUT_STEREO:
-        return AUDIO_CHANNEL_IN_STEREO;
-    case AUDIO_CHANNEL_OUT_5POINT1:
-        return AUDIO_CHANNEL_IN_5POINT1;
-    case AUDIO_CHANNEL_OUT_3POINT1POINT2:
-        return AUDIO_CHANNEL_IN_3POINT1POINT2;
-    case AUDIO_CHANNEL_OUT_3POINT0POINT2:
-        return AUDIO_CHANNEL_IN_3POINT0POINT2;
-    case AUDIO_CHANNEL_OUT_2POINT1POINT2:
-        return AUDIO_CHANNEL_IN_2POINT1POINT2;
-    case AUDIO_CHANNEL_OUT_2POINT0POINT2:
-        return AUDIO_CHANNEL_IN_2POINT0POINT2;
-    default:
-        return AUDIO_CHANNEL_INVALID;
-    }
-}
-
-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_AAC_ELD:
-    case AUDIO_FORMAT_AAC_XHE:
-    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:
-    case AUDIO_FORMAT_E_AC3_JOC:
-    case AUDIO_FORMAT_MAT_1_0:
-    case AUDIO_FORMAT_MAT_2_0:
-    case AUDIO_FORMAT_MAT_2_1:
-        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;
-}
-
-static inline size_t audio_bytes_per_frame(uint32_t channel_count, audio_format_t format)
-{
-    // cannot overflow for reasonable channel_count
-    return channel_count * audio_bytes_per_sample(format);
-}
-
-/* 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;
-    }
-}
-
-#ifndef AUDIO_NO_SYSTEM_DECLARATIONS
-
-static inline bool audio_gain_config_are_equal(
-        const struct audio_gain_config *lhs, const struct audio_gain_config *rhs) {
-    if (lhs->mode != rhs->mode) return false;
-    switch (lhs->mode) {
-    case AUDIO_GAIN_MODE_JOINT:
-        if (lhs->values[0] != rhs->values[0]) return false;
-        break;
-    case AUDIO_GAIN_MODE_CHANNELS:
-    case AUDIO_GAIN_MODE_RAMP:
-        if (lhs->channel_mask != rhs->channel_mask) return false;
-        for (int i = 0; i < popcount(lhs->channel_mask); ++i) {
-            if (lhs->values[i] != rhs->values[i]) return false;
-        }
-        break;
-    default: return false;
-    }
-    return lhs->ramp_duration_ms == rhs->ramp_duration_ms;
-}
-
-static inline bool audio_port_config_has_input_direction(const struct audio_port_config *port_cfg) {
-    switch (port_cfg->type) {
-    case AUDIO_PORT_TYPE_DEVICE:
-        switch (port_cfg->role) {
-        case AUDIO_PORT_ROLE_SOURCE: return true;
-        case AUDIO_PORT_ROLE_SINK: return false;
-        default: return false;
-        }
-    case AUDIO_PORT_TYPE_MIX:
-        switch (port_cfg->role) {
-        case AUDIO_PORT_ROLE_SOURCE: return false;
-        case AUDIO_PORT_ROLE_SINK: return true;
-        default: return false;
-        }
-    default: return false;
-    }
-}
-
-static inline bool audio_port_configs_are_equal(
-        const struct audio_port_config *lhs, const struct audio_port_config *rhs) {
-    if (lhs->role != rhs->role || lhs->type != rhs->type) return false;
-    switch (lhs->type) {
-    case AUDIO_PORT_TYPE_NONE: break;
-    case AUDIO_PORT_TYPE_DEVICE:
-        if (lhs->ext.device.hw_module != rhs->ext.device.hw_module ||
-                lhs->ext.device.type != rhs->ext.device.type ||
-                strncmp(lhs->ext.device.address, rhs->ext.device.address,
-                        AUDIO_DEVICE_MAX_ADDRESS_LEN) != 0) {
-            return false;
-        }
-        break;
-    case AUDIO_PORT_TYPE_MIX:
-        if (lhs->ext.mix.hw_module != rhs->ext.mix.hw_module ||
-                lhs->ext.mix.handle != rhs->ext.mix.handle) return false;
-        if (lhs->role == AUDIO_PORT_ROLE_SOURCE &&
-                lhs->ext.mix.usecase.stream != rhs->ext.mix.usecase.stream) return false;
-        else if (lhs->role == AUDIO_PORT_ROLE_SINK &&
-                lhs->ext.mix.usecase.source != rhs->ext.mix.usecase.source) return false;
-        break;
-    case AUDIO_PORT_TYPE_SESSION:
-        if (lhs->ext.session.session != rhs->ext.session.session) return false;
-        break;
-    default: return false;
-    }
-    return lhs->config_mask == rhs->config_mask &&
-            ((lhs->config_mask & AUDIO_PORT_CONFIG_SAMPLE_RATE) == 0 ||
-                    lhs->sample_rate == rhs->sample_rate) &&
-            ((lhs->config_mask & AUDIO_PORT_CONFIG_CHANNEL_MASK) == 0 ||
-                    lhs->channel_mask == rhs->channel_mask) &&
-            ((lhs->config_mask & AUDIO_PORT_CONFIG_FORMAT) == 0 ||
-                    lhs->format == rhs->format) &&
-            ((lhs->config_mask & AUDIO_PORT_CONFIG_GAIN) == 0 ||
-                    audio_gain_config_are_equal(&lhs->gain, &rhs->gain)) &&
-            ((lhs->config_mask & AUDIO_PORT_CONFIG_FLAGS) == 0 ||
-                    (audio_port_config_has_input_direction(lhs) ?
-                            lhs->flags.input == rhs->flags.input :
-                            lhs->flags.output == rhs->flags.output));
-}
-
-static inline bool audio_port_config_has_hw_av_sync(const struct audio_port_config *port_cfg) {
-    if (!(port_cfg->config_mask & AUDIO_PORT_CONFIG_FLAGS)) {
-        return false;
-    }
-    return audio_port_config_has_input_direction(port_cfg) ?
-            port_cfg->flags.input & AUDIO_INPUT_FLAG_HW_AV_SYNC
-            : port_cfg->flags.output & AUDIO_OUTPUT_FLAG_HW_AV_SYNC;
-}
-
-static inline bool audio_patch_has_hw_av_sync(const struct audio_patch *patch) {
-    for (unsigned int i = 0; i < patch->num_sources; ++i) {
-        if (audio_port_config_has_hw_av_sync(&patch->sources[i])) return true;
-    }
-    for (unsigned int i = 0; i < patch->num_sinks; ++i) {
-        if (audio_port_config_has_hw_av_sync(&patch->sinks[i])) return true;
-    }
-    return false;
-}
-
-static inline bool audio_patch_is_valid(const struct audio_patch *patch) {
-    // Note that patch can have no sinks.
-    return patch->num_sources != 0 && patch->num_sources <= AUDIO_PATCH_PORTS_MAX &&
-            patch->num_sinks <= AUDIO_PATCH_PORTS_MAX;
-}
-
-// Note that when checking for equality the order of ports must match.
-// Patches will not be equivalent if they contain the same ports but they are permuted differently.
-static inline bool audio_patches_are_equal(
-        const struct audio_patch *lhs, const struct audio_patch *rhs) {
-    if (!audio_patch_is_valid(lhs) || !audio_patch_is_valid(rhs)) return false;
-    if (lhs->num_sources != rhs->num_sources || lhs->num_sinks != rhs->num_sinks) return false;
-    for (unsigned int i = 0; i < lhs->num_sources; ++i) {
-        if (!audio_port_configs_are_equal(&lhs->sources[i], &rhs->sources[i])) return false;
-    }
-    for (unsigned int i = 0; i < lhs->num_sinks; ++i) {
-        if (!audio_port_configs_are_equal(&lhs->sinks[i], &rhs->sinks[i])) return false;
-    }
-    return true;
-}
-
-#endif
-
-// 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;
-
-//TODO: audio_microphone_location_t need to move to HAL v4.0
-typedef enum {
-    AUDIO_MICROPHONE_LOCATION_UNKNOWN = 0,
-    AUDIO_MICROPHONE_LOCATION_MAINBODY = 1,
-    AUDIO_MICROPHONE_LOCATION_MAINBODY_MOVABLE = 2,
-    AUDIO_MICROPHONE_LOCATION_PERIPHERAL = 3,
-    AUDIO_MICROPHONE_LOCATION_CNT = 4,
-} audio_microphone_location_t;
-
-//TODO: audio_microphone_directionality_t need to move to HAL v4.0
-typedef enum {
-    AUDIO_MICROPHONE_DIRECTIONALITY_UNKNOWN = 0,
-    AUDIO_MICROPHONE_DIRECTIONALITY_OMNI = 1,
-    AUDIO_MICROPHONE_DIRECTIONALITY_BI_DIRECTIONAL = 2,
-    AUDIO_MICROPHONE_DIRECTIONALITY_CARDIOID = 3,
-    AUDIO_MICROPHONE_DIRECTIONALITY_HYPER_CARDIOID = 4,
-    AUDIO_MICROPHONE_DIRECTIONALITY_SUPER_CARDIOID = 5,
-    AUDIO_MICROPHONE_DIRECTIONALITY_CNT = 6,
-} audio_microphone_directionality_t;
-
-/* A 3D point which could be used to represent geometric location
- * or orientation of a microphone.
- */
-struct audio_microphone_coordinate {
-    float x;
-    float y;
-    float z;
-};
-
-/* An number to indicate which group the microphone locate. Main body is
- * usually group 0. Developer could use this value to group the microphones
- * that locate on the same peripheral or attachments.
- */
-typedef int audio_microphone_group_t;
-
-typedef enum {
-    AUDIO_MICROPHONE_CHANNEL_MAPPING_UNUSED = 0,
-    AUDIO_MICROPHONE_CHANNEL_MAPPING_DIRECT = 1,
-    AUDIO_MICROPHONE_CHANNEL_MAPPING_PROCESSED = 2,
-    AUDIO_MICROPHONE_CHANNEL_MAPPING_CNT = 3,
-} audio_microphone_channel_mapping_t;
-
-/* the maximum length for the microphone id */
-#define AUDIO_MICROPHONE_ID_MAX_LEN 32
-/* max number of frequency responses in a frequency response table */
-#define AUDIO_MICROPHONE_MAX_FREQUENCY_RESPONSES 256
-/* max number of microphone */
-#define AUDIO_MICROPHONE_MAX_COUNT 32
-/* the value of unknown spl */
-#define AUDIO_MICROPHONE_SPL_UNKNOWN -FLT_MAX
-/* the value of unknown sensitivity */
-#define AUDIO_MICROPHONE_SENSITIVITY_UNKNOWN -FLT_MAX
-/* the value of unknown coordinate */
-#define AUDIO_MICROPHONE_COORDINATE_UNKNOWN -FLT_MAX
-/* the value used as address when the address of bottom microphone is empty */
-#define AUDIO_BOTTOM_MICROPHONE_ADDRESS "bottom"
-/* the value used as address when the address of back microphone is empty */
-#define AUDIO_BACK_MICROPHONE_ADDRESS "back"
-
-struct audio_microphone_characteristic_t {
-    char                               device_id[AUDIO_MICROPHONE_ID_MAX_LEN];
-    audio_port_handle_t                id;
-    audio_devices_t                    device;
-    char                               address[AUDIO_DEVICE_MAX_ADDRESS_LEN];
-    audio_microphone_channel_mapping_t channel_mapping[AUDIO_CHANNEL_COUNT_MAX];
-    audio_microphone_location_t        location;
-    audio_microphone_group_t           group;
-    unsigned int                       index_in_the_group;
-    float                              sensitivity;
-    float                              max_spl;
-    float                              min_spl;
-    audio_microphone_directionality_t  directionality;
-    unsigned int                       num_frequency_responses;
-    float frequency_responses[2][AUDIO_MICROPHONE_MAX_FREQUENCY_RESPONSES];
-    struct audio_microphone_coordinate geometric_location;
-    struct audio_microphone_coordinate orientation;
-};
-
-__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"
-#define AUDIO_HARDWARE_MODULE_ID_HEARING_AID "hearing_aid"
-#define AUDIO_HARDWARE_MODULE_ID_MSD "msd"
-
-/**
- * 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"
-
-/* User's preferred audio language setting (in ISO 639-2/T three-letter string code)
- * used to select a specific language presentation for next generation audio codecs. */
-#define AUDIO_PARAMETER_KEY_AUDIO_LANGUAGE_PREFERRED "audio_language_preferred"
-
-/**
- *  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 */
-
-/* Request the presentation id to be decoded by a next gen audio decoder */
-#define AUDIO_PARAMETER_STREAM_PRESENTATION_ID "presentation_id" /* int32_t */
-
-/* Request the program id to be decoded by a next gen audio decoder */
-#define AUDIO_PARAMETER_STREAM_PROGRAM_ID "program_id"           /* int32_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 "|"
-
-/* Reconfigure offloaded A2DP codec */
-#define AUDIO_PARAMETER_RECONFIG_A2DP "reconfigA2dp"
-/* Query if HwModule supports reconfiguration of offloaded A2DP codec */
-#define AUDIO_PARAMETER_A2DP_RECONFIG_SUPPORTED "isReconfigA2dpSupported"
-
-/**
- * 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"
-
-#endif  // ANDROID_AUDIO_CORE_H
diff --git a/include/system/audio_effect-base.h b/include/system/audio_effect-base.h
deleted file mode 100644
index 7a6a593..0000000
--- a/include/system/audio_effect-base.h
+++ /dev/null
@@ -1,99 +0,0 @@
-// This file is autogenerated by hidl-gen. Do not edit manually.
-// Source: android.hardware.audio.effect@4.0
-// Root: android.hardware:hardware/interfaces
-
-#ifndef HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EXPORTED_CONSTANTS_H_
-#define HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_EFFECT_V4_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, // (::android::hardware::audio::effect::V4_0::EffectBufferAccess.ACCESS_WRITE implicitly + 1)
-    EFFECT_BUFFER_ACCESS_ACCUMULATE = 2, // (::android::hardware::audio::effect::V4_0::EffectBufferAccess.ACCESS_READ implicitly + 1)
-} effect_buffer_access_e;
-
-enum {
-    EFFECT_CONFIG_BUFFER = 1,
-    EFFECT_CONFIG_SMP_RATE = 2,
-    EFFECT_CONFIG_CHANNELS = 4,
-    EFFECT_CONFIG_FORMAT = 8,
-    EFFECT_CONFIG_ACC_MODE = 16,
-};
-
-typedef enum {
-    EFFECT_FEATURE_AUX_CHANNELS = 0,
-    EFFECT_FEATURE_CNT = 1, // (::android::hardware::audio::effect::V4_0::EffectFeature.AUX_CHANNELS implicitly + 1)
-} effect_feature_e;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  // HIDL_GENERATED_ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EXPORTED_CONSTANTS_H_
diff --git a/include/system/audio_effect.h b/include/system/audio_effect.h
deleted file mode 100644
index 4cdc773..0000000
--- a/include/system/audio_effect.h
+++ /dev/null
@@ -1,536 +0,0 @@
-/*
- * 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 "audio.h"
-#include "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;
-
-#define EFFECT_CONFIG_ALL (EFFECT_CONFIG_BUFFER | \
-                           EFFECT_CONFIG_SMP_RATE | \
-                           EFFECT_CONFIG_CHANNELS | \
-                           EFFECT_CONFIG_FORMAT | \
-                           EFFECT_CONFIG_ACC_MODE)
-
-/////////////////////////////////////////////////
-//      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/src/resampler.c b/src/resampler.c
index 066668e..3e26956 100644
--- a/src/resampler.c
+++ b/src/resampler.c
@@ -19,10 +19,7 @@
 
 #include <errno.h>
 #include <stdlib.h>
-
 #include <cutils/log.h>
-
-#include <system/audio.h>
 #include <audio_utils/resampler.h>
 #include <speex/speex_resampler.h>
 
diff --git a/src/spdif/AC3FrameScanner.cpp b/src/spdif/AC3FrameScanner.cpp
deleted file mode 100644
index 6c92099..0000000
--- a/src/spdif/AC3FrameScanner.cpp
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#define LOG_TAG "AudioSPDIF"
-
-#include <string.h>
-
-#include <cutils/log.h>
-#include <audio_utils/spdif/FrameScanner.h>
-
-#include "AC3FrameScanner.h"
-
-namespace android {
-
-// These values are from the AC3 spec. Do not change them.
-
-const uint8_t AC3FrameScanner::kSyncBytes[] = { 0x0B, 0x77 };
-
-const uint16_t AC3FrameScanner::kAC3SampleRateTable[AC3_NUM_SAMPLE_RATE_TABLE_ENTRIES]
-    = { 48000, 44100, 32000 };
-
-// Table contains number of 16-bit words in an AC3 frame.
-// From AC3 spec table 5.13
-const uint16_t AC3FrameScanner::kAC3FrameSizeTable[AC3_NUM_FRAME_SIZE_TABLE_ENTRIES]
-        [AC3_NUM_SAMPLE_RATE_TABLE_ENTRIES] = {
-    { 64, 69, 96 },
-    { 64, 70, 96 },
-    { 80, 87, 120 },
-    { 80, 88, 120 },
-    { 96, 104, 144 },
-    { 96, 105, 144 },
-    { 112, 121, 168 },
-    { 112, 122, 168 },
-    { 128, 139, 192 },
-    { 128, 140, 192 },
-    { 160, 174, 240 },
-    { 160, 175, 240 },
-    { 192, 208, 288 },
-    { 192, 209, 288 },
-    { 224, 243, 336 },
-    { 224, 244, 336 },
-    { 256, 278, 384 },
-    { 256, 279, 384 },
-    { 320, 348, 480 },
-    { 320, 349, 480 },
-    { 384, 417, 576 },
-    { 384, 418, 576 },
-    { 448, 487, 672 },
-    { 448, 488, 672 },
-    { 512, 557, 768 },
-    { 512, 558, 768 },
-    { 640, 696, 960 },
-    { 640, 697, 960 },
-    { 768, 835, 1152 },
-    { 768, 836, 1152 },
-    { 896, 975, 1344 },
-    { 896, 976, 1344 },
-    { 1024, 1114, 1536 },
-    { 1024, 1115, 1536 },
-    { 1152, 1253, 1728 },
-    { 1152, 1254, 1728 },
-    { 1280, 1393, 1920 },
-    { 1280, 1394, 1920 }
-};
-
-const uint16_t AC3FrameScanner::kEAC3ReducedSampleRateTable[AC3_NUM_SAMPLE_RATE_TABLE_ENTRIES]
-        = { 24000, 22050, 16000 };
-
-const uint16_t
-        AC3FrameScanner::kEAC3BlocksPerFrameTable[EAC3_NUM_BLOCKS_PER_FRAME_TABLE_ENTRIES]
-        = { 1, 2, 3, 6 };
-
-// Defined in IEC61937-2
-#define SPDIF_DATA_TYPE_AC3     1
-#define SPDIF_DATA_TYPE_E_AC3  21
-#define AC3_STREAM_TYPE_0       0
-#define AC3_STREAM_TYPE_1       1
-#define AC3_STREAM_TYPE_2       2
-// -----------------------------------------------------------------------------
-
-// Scanner for AC3 byte streams.
-AC3FrameScanner::AC3FrameScanner(audio_format_t format)
- : FrameScanner(SPDIF_DATA_TYPE_AC3,
-        AC3FrameScanner::kSyncBytes,
-        sizeof(AC3FrameScanner::kSyncBytes), 6)
- , mStreamType(0)
- , mSubstreamID(0)
- , mFormat(format)
-{
-    mAudioBlocksPerSyncFrame = 6;
-    memset(mSubstreamBlockCounts, 0, sizeof(mSubstreamBlockCounts));
-}
-
-AC3FrameScanner::~AC3FrameScanner()
-{
-}
-
-int AC3FrameScanner::getSampleFramesPerSyncFrame() const
-{
-    return mRateMultiplier
-            * AC3_MAX_BLOCKS_PER_SYNC_FRAME_BLOCK * AC3_PCM_FRAMES_PER_BLOCK;
-}
-
-void AC3FrameScanner::resetBurst()
-{
-    for (int i = 0; i < EAC3_MAX_SUBSTREAMS; i++) {
-        if (mSubstreamBlockCounts[i] >= AC3_MAX_BLOCKS_PER_SYNC_FRAME_BLOCK) {
-            mSubstreamBlockCounts[i] -= AC3_MAX_BLOCKS_PER_SYNC_FRAME_BLOCK;
-        } else if (mSubstreamBlockCounts[i] > 0) {
-            ALOGW("EAC3 substream[%d] has only %d audio blocks!",
-                i, mSubstreamBlockCounts[i]);
-            mSubstreamBlockCounts[i] = 0;
-        }
-    }
-}
-
-// Per IEC 61973-3:5.3.3, for E-AC3 burst-length shall be in bytes.
-uint16_t AC3FrameScanner::convertBytesToLengthCode(uint16_t numBytes) const
-{
-    return (mDataType == SPDIF_DATA_TYPE_E_AC3) ? numBytes : numBytes * 8;
-}
-
-// per IEC 61973-3 Paragraph 5.3.3
-// We have to send 6 audio blocks on all active substreams.
-// Substream zero must be the first.
-// We don't know if we have all the blocks we need until we see
-// the 7th block of substream#0.
-bool AC3FrameScanner::isFirstInBurst()
-{
-    if (mDataType == SPDIF_DATA_TYPE_E_AC3) {
-        if (((mStreamType == AC3_STREAM_TYPE_0)
-                || (mStreamType == AC3_STREAM_TYPE_2))
-                && (mSubstreamID == 0)
-                // The ">" is intentional. We have to see the beginning
-                // of the block in the next burst before we can send
-                // the current burst.
-                && (mSubstreamBlockCounts[0] > AC3_MAX_BLOCKS_PER_SYNC_FRAME_BLOCK)) {
-            return true;
-        }
-    }
-    return false;
-}
-
-bool AC3FrameScanner::isLastInBurst()
-{
-    // For EAC3 we don't know if we are the end until we see a
-    // frame that must be at the beginning. See isFirstInBurst().
-    return (mDataType != SPDIF_DATA_TYPE_E_AC3); // Just one AC3 frame per burst.
-}
-
-// TODO Use BitFieldParser
-
-// Parse AC3 header.
-// Detect whether the stream is AC3 or EAC3. Extract data depending on type.
-//
-// @return true if valid
-bool AC3FrameScanner::parseHeader()
-{
-    // Interpret bsid based on paragraph E2.3.1.6 of EAC3 spec.
-    uint32_t bsid = mHeaderBuffer[5] >> 3; // bitstream ID
-    // Check BSID to see if this is EAC3 or regular AC3.
-    // These arbitrary BSID numbers do not have any names in the spec.
-    if ((bsid > 10) && (bsid <= 16)) {
-        mDataType = SPDIF_DATA_TYPE_E_AC3;
-    } else if (bsid <= 8) {
-        mDataType = SPDIF_DATA_TYPE_AC3;
-    } else {
-        ALOGW("AC3 bsid = %d not supported", bsid);
-        return false;
-    }
-
-    // bitstream mode, main, commentary, etc.
-    uint32_t bsmod = mHeaderBuffer[5] & 7;
-    mDataTypeInfo = bsmod; // as per IEC61937-3, table 3.
-
-    // The names fscod, frmsiz are from the AC3 spec.
-    uint32_t fscod = mHeaderBuffer[4] >> 6;
-    if (mDataType == SPDIF_DATA_TYPE_E_AC3) {
-        mStreamType = mHeaderBuffer[2] >> 6; // strmtyp in spec
-        mSubstreamID = (mHeaderBuffer[2] >> 3) & 0x07;
-
-        // Frame size is explicit in EAC3. Paragraph E2.3.1.3
-        uint32_t frmsiz = ((mHeaderBuffer[2] & 0x07) << 8) + mHeaderBuffer[3];
-        mFrameSizeBytes = (frmsiz + 1) * sizeof(int16_t);
-
-        uint32_t numblkscod = 3; // 6 blocks default
-        if (fscod == 3) {
-            uint32_t fscod2 = (mHeaderBuffer[4] >> 4) & 0x03;
-            if (fscod2 >= AC3_NUM_SAMPLE_RATE_TABLE_ENTRIES) {
-                ALOGW("Invalid EAC3 fscod2 = %d", fscod2);
-                return false;
-            } else {
-                mSampleRate = kEAC3ReducedSampleRateTable[fscod2];
-            }
-        } else {
-            mSampleRate = kAC3SampleRateTable[fscod];
-            numblkscod = (mHeaderBuffer[4] >> 4) & 0x03;
-        }
-        mRateMultiplier = EAC3_RATE_MULTIPLIER; // per IEC 61973-3 Paragraph 5.3.3
-        // Don't send data burst until we have 6 blocks per substream.
-        mAudioBlocksPerSyncFrame = kEAC3BlocksPerFrameTable[numblkscod];
-        // Keep track of how many audio blocks we have for each substream.
-        // This should be safe because mSubstreamID is ANDed with 0x07 above.
-        // And the array is allocated as [8].
-        if ((mStreamType == AC3_STREAM_TYPE_0)
-                || (mStreamType == AC3_STREAM_TYPE_2)) {
-            mSubstreamBlockCounts[mSubstreamID] += mAudioBlocksPerSyncFrame;
-        }
-
-        // Print enough so we can see all the substreams.
-        ALOGD_IF((mFormatDumpCount < 3*8 ),
-                "EAC3 mStreamType = %d, mSubstreamID = %d",
-                mStreamType, mSubstreamID);
-    } else { // regular AC3
-        // Extract sample rate and frame size from codes.
-        uint32_t frmsizcod = mHeaderBuffer[4] & 0x3F; // frame size code
-
-        if (fscod >= AC3_NUM_SAMPLE_RATE_TABLE_ENTRIES) {
-            ALOGW("Invalid AC3 sampleRateCode = %d", fscod);
-            return false;
-        } else if (frmsizcod >= AC3_NUM_FRAME_SIZE_TABLE_ENTRIES) {
-            ALOGW("Invalid AC3 frameSizeCode = %d", frmsizcod);
-            return false;
-        } else {
-            mSampleRate = kAC3SampleRateTable[fscod];
-            mRateMultiplier = 1;
-            mFrameSizeBytes = sizeof(uint16_t)
-                    * kAC3FrameSizeTable[frmsizcod][fscod];
-        }
-        mAudioBlocksPerSyncFrame = 6;
-        if (mFormat == AUDIO_FORMAT_E_AC3) {
-            ALOGV("Its a Ac3 substream in EAC3 stream");
-            mStreamType = 2;
-            mSubstreamID = 0;
-            mSubstreamBlockCounts[0] += mAudioBlocksPerSyncFrame;
-            mDataType = SPDIF_DATA_TYPE_E_AC3;
-            mRateMultiplier = EAC3_RATE_MULTIPLIER;
-        }
-    }
-    ALOGI_IF((mFormatDumpCount == 0),
-            "AC3 frame rate = %d * %d, size = %zu, audioBlocksPerSyncFrame = %d",
-            mSampleRate, mRateMultiplier, mFrameSizeBytes, mAudioBlocksPerSyncFrame);
-    mFormatDumpCount++;
-    return true;
-}
-
-}  // namespace android
diff --git a/src/spdif/AC3FrameScanner.h b/src/spdif/AC3FrameScanner.h
deleted file mode 100644
index a73a860..0000000
--- a/src/spdif/AC3FrameScanner.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 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_AUDIO_AC3_FRAME_SCANNER_H
-#define ANDROID_AUDIO_AC3_FRAME_SCANNER_H
-
-#include <stdint.h>
-#include <system/audio.h>
-#include <audio_utils/spdif/FrameScanner.h>
-
-namespace android {
-
-#define AC3_NUM_SAMPLE_RATE_TABLE_ENTRIES          3
-#define AC3_NUM_FRAME_SIZE_TABLE_ENTRIES          38
-#define AC3_PCM_FRAMES_PER_BLOCK                 256
-#define AC3_MAX_BLOCKS_PER_SYNC_FRAME_BLOCK        6
-#define EAC3_RATE_MULTIPLIER                       4
-#define EAC3_NUM_SAMPLE_RATE_TABLE_ENTRIES         3
-#define EAC3_NUM_BLOCKS_PER_FRAME_TABLE_ENTRIES   38
-#define EAC3_MAX_SUBSTREAMS                        8
-
-class AC3FrameScanner : public FrameScanner
-{
-public:
-    explicit AC3FrameScanner(audio_format_t format);
-    virtual ~AC3FrameScanner();
-
-    virtual int getMaxChannels()   const { return 5 + 1; } // 5.1 surround
-
-    virtual int getMaxSampleFramesPerSyncFrame() const { return EAC3_RATE_MULTIPLIER
-            * AC3_MAX_BLOCKS_PER_SYNC_FRAME_BLOCK * AC3_PCM_FRAMES_PER_BLOCK; }
-    virtual int getSampleFramesPerSyncFrame() const;
-
-    virtual bool isFirstInBurst();
-    virtual bool isLastInBurst();
-    virtual void resetBurst();
-
-    virtual uint16_t convertBytesToLengthCode(uint16_t numBytes) const;
-
-protected:
-    // Keep track of how many of each substream blocks have been accumulated.
-    // We need all of each substream before sending block data burst.
-    uint8_t   mSubstreamBlockCounts[EAC3_MAX_SUBSTREAMS];
-    int       mAudioBlocksPerSyncFrame;
-    // The type of EAC3 stream as per EAC3 spec paragraph 2.3.1.1
-    uint32_t  mStreamType;
-    // substream index
-    uint32_t  mSubstreamID;
-    audio_format_t mFormat;
-
-    // used to recognize the start of an AC3 sync frame
-    static const uint8_t  kSyncBytes[];
-    // sample rates from AC3 spec table 5.1
-    static const uint16_t kAC3SampleRateTable[AC3_NUM_SAMPLE_RATE_TABLE_ENTRIES];
-    // frame sizes from AC3 spec table 5.13
-    static const uint16_t kAC3FrameSizeTable[AC3_NUM_FRAME_SIZE_TABLE_ENTRIES]
-            [AC3_NUM_SAMPLE_RATE_TABLE_ENTRIES];
-    // sample rates from EAC3 spec table E2.3
-    static const uint16_t kEAC3ReducedSampleRateTable[AC3_NUM_SAMPLE_RATE_TABLE_ENTRIES];
-    // audio blocks per frame from EAC3 spec table E2.4
-    static const uint16_t kEAC3BlocksPerFrameTable[EAC3_NUM_BLOCKS_PER_FRAME_TABLE_ENTRIES];
-
-    virtual bool parseHeader();
-};
-
-}  // namespace android
-
-#endif  // ANDROID_AUDIO_AC3_FRAME_SCANNER_H
diff --git a/src/spdif/BitFieldParser.cpp b/src/spdif/BitFieldParser.cpp
deleted file mode 100644
index d513320..0000000
--- a/src/spdif/BitFieldParser.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2015, 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.
- */
-
-#define LOG_TAG "AudioSPDIF"
-//#define LOG_NDEBUG 0
-
-#include <string.h>
-#include <assert.h>
-
-#include <cutils/log.h>
-#include "BitFieldParser.h"
-
-namespace android {
-
-BitFieldParser::BitFieldParser(uint8_t *data)
- : mData(data)
- , mBitCursor(0)
-{
-}
-
-BitFieldParser::~BitFieldParser()
-{
-}
-
-uint32_t BitFieldParser::readBits(uint32_t numBits)
-{
-    ALOG_ASSERT(numBits <= 32);
-
-    // Extract some bits from the current byte.
-    uint32_t byteCursor = mBitCursor >> 3; // 8 bits per byte
-    uint8_t byte = mData[byteCursor];
-
-    uint32_t bitsLeftInByte = 8 - (mBitCursor & 7);
-    uint32_t bitsFromByte = (bitsLeftInByte < numBits) ? bitsLeftInByte : numBits;
-    uint32_t result = byte >> (bitsLeftInByte - bitsFromByte);
-    result &= (1 << bitsFromByte) - 1; // mask
-    mBitCursor += bitsFromByte;
-
-    uint32_t bitsRemaining = numBits - bitsFromByte;
-    if (bitsRemaining == 0) {
-        return result;
-    } else {
-        // Use recursion to get remaining bits.
-        return (result << bitsRemaining) | readBits(bitsRemaining);
-    }
-}
-
-}  // namespace android
diff --git a/src/spdif/BitFieldParser.h b/src/spdif/BitFieldParser.h
deleted file mode 100644
index 3f6fe59..0000000
--- a/src/spdif/BitFieldParser.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2015, 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_BIT_FIELD_PARSER_H
-#define ANDROID_AUDIO_BIT_FIELD_PARSER_H
-
-#include <stdint.h>
-
-namespace android {
-
-/**
- * Extract bit fields from a byte array.
- */
-class BitFieldParser {
-public:
-
-    explicit BitFieldParser(uint8_t *data);
-    virtual ~BitFieldParser();
-
-    /**
-     * Read numBits bits from the data array.
-     * Fields may span byte boundaries but may not exceed 32-bits.
-     * Note that the caller must ensure that there is suffcient data.
-     * Assume data is organized as BigEndian format.
-     */
-    uint32_t readBits(uint32_t numBits);
-
-    /*
-     * When the cursor is zero it points to a position right before
-     * the most significant bit.
-     * When the cursor is seven it points to a position right before
-     * the least significant bit.
-     */
-    uint32_t getBitCursor() const { return mBitCursor; }
-
-private:
-    uint8_t *mData;
-    uint32_t mBitCursor;
-};
-
-
-}  // namespace android
-
-#endif  // ANDROID_AUDIO_BIT_FIELD_PARSER_H
diff --git a/src/spdif/DTSFrameScanner.cpp b/src/spdif/DTSFrameScanner.cpp
deleted file mode 100644
index 941e8b9..0000000
--- a/src/spdif/DTSFrameScanner.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2015, 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.
- */
-
-#define LOG_TAG "AudioSPDIF"
-//#define LOG_NDEBUG 0
-
-#include <assert.h>
-#include <string.h>
-
-#include <cutils/log.h>
-#include <audio_utils/spdif/FrameScanner.h>
-
-#include "BitFieldParser.h"
-#include "DTSFrameScanner.h"
-
-namespace android {
-
-// TODO Handle termination frames.
-// TODO assert if parse past end of header buffer
-// TODO Handle DTS_HD
-
-const uint8_t DTSFrameScanner::kSyncBytes[] =
-        { 0x7F, 0xFE, 0x80, 0x01 };
-
-const int32_t DTSFrameScanner::kDTSSampleRateTable[DTS_NUM_SAMPLE_RATE_TABLE_ENTRIES]
-        = { -1, 8000, 16000, 32000, -1, -1,
-        11025, 22050, 44100, -1, -1, 12000, 24000, 48000, -1, -1 };
-
-// Defined in IEC61937-2
-#define IEC61937_DATA_TYPE_DTS_I        11
-#define IEC61937_DATA_TYPE_DTS_II       12
-#define IEC61937_DATA_TYPE_DTS_III      13
-#define IEC61937_DATA_TYPE_DTS_IV       17
-
-#define IEC61937_MAX_SAMPLES_TYPE_I    512
-#define IEC61937_MAX_SAMPLES_TYPE_II  1024
-#define IEC61937_MAX_SAMPLES_TYPE_III 2048
-
-// Limits defined in DTS spec paragraph 5.3.1
-#define DTS_MINIMUM_NBLKS                5
-#define DTS_MINIMUM_FSIZE               95
-
-#define DTS_HEADER_BYTES_NEEDED         12
-
-// Scanner for DTS byte streams.
-DTSFrameScanner::DTSFrameScanner()
- : FrameScanner(IEC61937_DATA_TYPE_DTS_I,
-    DTSFrameScanner::kSyncBytes,
-    sizeof(DTSFrameScanner::kSyncBytes),
-    DTS_HEADER_BYTES_NEEDED)
- , mSampleFramesPerSyncFrame(0)
-{
-}
-
-DTSFrameScanner::~DTSFrameScanner()
-{
-}
-
-// Parse DTS header.
-// Detect whether the stream is DTS or DTS_HD. Extract data depending on type.
-// Sets mDataType, mFrameSizeBytes,
-//      mSampleRate, mRateMultiplier, mLengthCode.
-//
-// @return true if valid
-bool DTSFrameScanner::parseHeader()
-{
-    BitFieldParser parser(&mHeaderBuffer[mSyncLength]);
-
-    // These variables are named after the fields in the DTS spec 5.3.1
-    // Extract field in order.
-    (void) /* uint32_t ftype = */ parser.readBits(1);
-    (void) /* uint32_t deficit = */ parser.readBits(5); // "short"
-    uint32_t cpf = parser.readBits(1);
-    uint32_t nblks = parser.readBits(7);
-    uint32_t fsize = parser.readBits(14);
-    (void) /* uint32_t amode = */ parser.readBits(6);
-    uint32_t sfreq = parser.readBits(4);
-    // make sure we did not read past collected data
-    ALOG_ASSERT((mSyncLength + ((parser.getBitCursor() + 7) >> 3))
-            <= mHeaderLength);
-
-    // Validate fields.
-    if (cpf != 0) {
-        ALOGE("DTSFrameScanner: ERROR - CPF not zero!");
-        return false;
-    }
-    if (nblks < DTS_MINIMUM_NBLKS) {
-        ALOGE("DTSFrameScanner: ERROR - nblks = %u", nblks);
-        return false;
-    }
-    if (fsize < DTS_MINIMUM_FSIZE) {
-        ALOGE("DTSFrameScanner: ERROR - fsize = %u", fsize);
-        return false;
-    }
-
-    int32_t sampleRate = kDTSSampleRateTable[sfreq];
-    if (sampleRate < 0) {
-        ALOGE("DTSFrameScanner: ERROR - invalid sampleRate[%u] = %d", sfreq, sampleRate);
-        return false;
-    }
-    mSampleRate = (uint32_t) sampleRate;
-
-    mSampleFramesPerSyncFrame = (nblks + 1) * DTS_PCM_FRAMES_PER_BLOCK;
-    if (mSampleFramesPerSyncFrame <= IEC61937_MAX_SAMPLES_TYPE_I) {
-        mDataType = IEC61937_DATA_TYPE_DTS_I;
-    } else if (mSampleFramesPerSyncFrame <= IEC61937_MAX_SAMPLES_TYPE_II) {
-        mDataType = IEC61937_DATA_TYPE_DTS_II;
-    } else if (mSampleFramesPerSyncFrame <= IEC61937_MAX_SAMPLES_TYPE_III) {
-        mDataType = IEC61937_DATA_TYPE_DTS_III;
-    } else {
-        mDataType = IEC61937_DATA_TYPE_DTS_IV;
-        // TODO set bits 8,10
-    }
-
-    mFrameSizeBytes = fsize + 1;
-
-    mRateMultiplier = 1; // TODO what about "frequency extension"?
-    ALOGI_IF((mFormatDumpCount == 0),
-            "DTS frame rate = %d * %d, size = %zu",
-            mSampleRate, mRateMultiplier, mFrameSizeBytes);
-    mFormatDumpCount++;
-    return true;
-}
-
-
-}  // namespace android
diff --git a/src/spdif/DTSFrameScanner.h b/src/spdif/DTSFrameScanner.h
deleted file mode 100644
index 883ded9..0000000
--- a/src/spdif/DTSFrameScanner.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2015, 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_DTS_FRAME_SCANNER_H
-#define ANDROID_AUDIO_DTS_FRAME_SCANNER_H
-
-#include <stdint.h>
-#include <audio_utils/spdif/FrameScanner.h>
-
-namespace android {
-
-#define DTS_NUM_SAMPLE_RATE_TABLE_ENTRIES      16
-#define DTS_PCM_FRAMES_PER_BLOCK               32
-#define DTS_MAX_BLOCKS_PER_SYNC_FRAME_BLOCK   128
-
-class DTSFrameScanner : public FrameScanner
-{
-public:
-    DTSFrameScanner();
-    virtual ~DTSFrameScanner();
-
-    virtual int getMaxChannels()   const { return 5 + 1; }
-
-    virtual int getMaxSampleFramesPerSyncFrame() const {
-        return  DTS_MAX_BLOCKS_PER_SYNC_FRAME_BLOCK * DTS_PCM_FRAMES_PER_BLOCK;
-    }
-
-    virtual int getSampleFramesPerSyncFrame() const {
-        return mSampleFramesPerSyncFrame;
-    }
-
-    virtual bool isFirstInBurst() { return true; }
-    virtual bool isLastInBurst() { return true; }
-    virtual void resetBurst()  { }
-
-protected:
-
-    int mSampleFramesPerSyncFrame;
-
-    virtual bool parseHeader();
-
-    static const uint8_t kSyncBytes[];
-    static const int32_t kDTSSampleRateTable[];
-
-};
-
-}  // namespace android
-#endif  // ANDROID_AUDIO_DTS_FRAME_SCANNER_H
diff --git a/src/spdif/FrameScanner.cpp b/src/spdif/FrameScanner.cpp
deleted file mode 100644
index c13d960..0000000
--- a/src/spdif/FrameScanner.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#define LOG_TAG "AudioSPDIF"
-
-#include <string.h>
-#include <assert.h>
-
-#include <cutils/log.h>
-#include <audio_utils/spdif/FrameScanner.h>
-
-namespace android {
-
-FrameScanner::FrameScanner(int dataType,
-            const uint8_t *syncBytes,
-            uint32_t syncLength,
-            uint32_t headerLength)
- : mBytesSkipped(0)
- , mSyncBytes(syncBytes)
- , mSyncLength(syncLength)
- , mHeaderLength(headerLength)
- , mCursor(0)
- , mFormatDumpCount(0)
- , mSampleRate(0)
- , mRateMultiplier(1)
- , mFrameSizeBytes(0)
- , mDataType(dataType)
- , mDataTypeInfo(0)
-{
-}
-
-FrameScanner::~FrameScanner()
-{
-}
-
-// State machine that scans for headers in a byte stream.
-// @return true if we have detected a complete and valid header.
-bool FrameScanner::scan(uint8_t byte)
-{
-    bool result = false;
-    ALOGV("FrameScanner: byte = 0x%02X, mCursor = %d", byte, mCursor);
-    assert(mCursor < sizeof(mHeaderBuffer));
-    if (mCursor < mSyncLength) {
-        // match sync word
-        if (byte == mSyncBytes[mCursor]) {
-            mHeaderBuffer[mCursor++] = byte;
-        } else {
-            mBytesSkipped += 1; // skip unsynchronized data
-            mCursor = 0;
-        }
-    } else if (mCursor < mHeaderLength) {
-        // gather header for parsing
-        mHeaderBuffer[mCursor++] = byte;
-        if (mCursor >= mHeaderLength) {
-            if (parseHeader()) {
-                result = true;
-            } else {
-                ALOGE("FrameScanner: ERROR - parseHeader() failed.");
-            }
-            mCursor = 0;
-        }
-    }
-    return result;
-}
-
-}  // namespace android
diff --git a/src/spdif/MatFrameScanner.cpp b/src/spdif/MatFrameScanner.cpp
deleted file mode 100644
index 31c8380..0000000
--- a/src/spdif/MatFrameScanner.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright 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.
- */
-
-#define LOG_TAG "AudioSPDIF"
-//#define LOG_NDEBUG 0
-
-#include <string.h>
-#include <assert.h>
-
-#include <cutils/log.h>
-#include <audio_utils/spdif/FrameScanner.h>
-
-#include "MatFrameScanner.h"
-
-namespace android {
-
-// MAT Transport stream sync word
-const uint8_t MatFrameScanner::kSyncBytes[] = { 0x07, 0x9E };
-
-// Defined in IEC61937-9
-#define SPDIF_DATA_TYPE_MAT 22
-
-#define MAT_MAX_CHUNK_SIZE 30720
-
-// MAT transport format
-// { Syncword (16 bits) }
-// { metadata_payload_length   (16 bits), Metadata Payload, Payload CRC (16 bits) }
-// { top_of_channels_length    (16 bits), Top of Channels Audio Chunk, Payload CRC (16 bits) }
-// { bottom_of_channels_length (16 bits), Bottom of Channels Audio Chunk, Payload CRC (16 bits) }
-// Length does not include bytes for length itself and the CRC after payload.
-
-// For frame parsing, we use three frame chunks for a single IEC61937 frame
-// 1. {syncword, metadata_payload_length, Metadata Payload}
-// 2. {metadata_payload_crc, top_of_channels_length, Top of Channels Audio Chunk}
-// 3. {Top channels chunk crc, bottom_of_channels_length, Bottom of Channels Audio Chunk, Bottom Channels Chunk crc}
-// such that the header buffer for the three "virtual" frames have fixed 4 bytes size (mHeaderLength = 4)
-// and we can control the frame size to collect in each chunk state.
-
-#define CHUNK_TYPE_METADATA 0
-#define CHUNK_TYPE_TOP      1
-#define CHUNK_TYPE_BOTTOM   2
-
-MatFrameScanner::MatFrameScanner()
- : FrameScanner(SPDIF_DATA_TYPE_MAT,
-        MatFrameScanner::kSyncBytes,
-        sizeof(MatFrameScanner::kSyncBytes), 4)
- , mChunkType(CHUNK_TYPE_METADATA)
- , mLastChunk(false)
-{
-}
-
-MatFrameScanner::~MatFrameScanner()
-{
-}
-
-void MatFrameScanner::resetBurst()
-{
-    mChunkType = CHUNK_TYPE_METADATA;
-}
-
-// Per IEC 61973-9:5.3.1, for MAT burst-length shall be in bytes.
-uint16_t MatFrameScanner::convertBytesToLengthCode(uint16_t numBytes) const
-{
-    return numBytes;
-}
-
-bool MatFrameScanner::isLastInBurst()
-{
-    return mLastChunk;
-}
-
-bool MatFrameScanner::parseHeader()
-{
-    size_t payload_length = ((size_t)(mHeaderBuffer[2]) << 8) | mHeaderBuffer[3];
-
-    if ((payload_length <= 0) || (payload_length > MAT_MAX_CHUNK_SIZE))
-        return false;
-
-    payload_length <<= 1;   // convert to bytes
-
-    if (mChunkType == CHUNK_TYPE_METADATA) {
-        mFrameSizeBytes = mHeaderLength;    // sync word, metadata length
-        mFrameSizeBytes += payload_length;
-        mChunkType = CHUNK_TYPE_TOP;
-        mLastChunk = false;
-    } else if (mChunkType == CHUNK_TYPE_TOP) {
-        mFrameSizeBytes = mHeaderLength;    // metadata crc, top length
-        mFrameSizeBytes += payload_length;
-        mChunkType = CHUNK_TYPE_BOTTOM;
-        mLastChunk = false;
-    } else {
-        mFrameSizeBytes = mHeaderLength;    // top crc, bottom length
-        mFrameSizeBytes += payload_length;
-        mFrameSizeBytes += 2;               // bottom crc
-        mChunkType = CHUNK_TYPE_METADATA;
-        mLastChunk = true;
-    }
-
-    return true;
-}
-
-// State machine that scans for headers in a byte stream.
-// @return true if we have detected a complete and valid header.
-bool MatFrameScanner::scan(uint8_t byte)
-{
-    bool result = false;
-
-    //ALOGV("MatFrameScanner: byte = 0x%02X, mCursor = %d", byte, mCursor);
-    assert(mCursor < sizeof(mHeaderBuffer));
-
-    if ((mChunkType == CHUNK_TYPE_METADATA) && (mCursor < mSyncLength)) {
-        // match sync word
-        if (byte == mSyncBytes[mCursor]) {
-            mHeaderBuffer[mCursor++] = byte;
-        } else {
-            mBytesSkipped += 1; // skip unsynchronized data
-            mCursor = 0;
-        }
-    } else if (mCursor < mHeaderLength) {
-        // gather header for parsing metadata payload length
-        mHeaderBuffer[mCursor++] = byte;
-        if (mCursor >= mHeaderLength) {
-            if (parseHeader()) {
-                result = true;
-            } else {
-                ALOGE("MatFrameScanner: ERROR - parseHeader() failed.");
-            }
-            mCursor = 0;
-        }
-    }
-
-    return result;
-}
-
-}  // namespace android
diff --git a/src/spdif/MatFrameScanner.h b/src/spdif/MatFrameScanner.h
deleted file mode 100644
index c4ce825..0000000
--- a/src/spdif/MatFrameScanner.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 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_AUDIO_MAT_FRAME_SCANNER_H
-#define ANDROID_AUDIO_MAT_FRAME_SCANNER_H
-
-#include <stdint.h>
-#include <system/audio.h>
-#include <audio_utils/spdif/FrameScanner.h>
-
-namespace android {
-
-#define MAT_PCM_FRAMES                          1536
-#define MAT_RATE_MULTIPLIER                       10
-
-class MatFrameScanner : public FrameScanner
-{
-public:
-    MatFrameScanner();
-    virtual ~MatFrameScanner();
-
-    virtual int getMaxChannels()   const { return 5 + 1 + 2; } // 5.1.2 surround
-
-    virtual int getMaxSampleFramesPerSyncFrame() const { return MAT_RATE_MULTIPLIER
-            * MAT_PCM_FRAMES; }
-    virtual int getSampleFramesPerSyncFrame() const { return MAT_RATE_MULTIPLIER
-            * MAT_PCM_FRAMES; }
-
-    virtual bool isFirstInBurst() { return false; }
-    virtual bool isLastInBurst();
-    virtual void resetBurst();
-
-    virtual uint16_t convertBytesToLengthCode(uint16_t numBytes) const;
-    virtual bool scan(uint8_t byte);
-
-protected:
-    // used to recognize the start of a MAT sync frame
-    static const uint8_t kSyncBytes[];
-    int mChunkType;
-    bool mLastChunk;
-
-    virtual bool parseHeader();
-};
-
-}  // namespace android
-
-#endif  // ANDROID_AUDIO_MAT_FRAME_SCANNER_H
diff --git a/src/spdif/SPDIFEncoder.cpp b/src/spdif/SPDIFEncoder.cpp
deleted file mode 100644
index da7bea7..0000000
--- a/src/spdif/SPDIFEncoder.cpp
+++ /dev/null
@@ -1,280 +0,0 @@
-/*
- * Copyright 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 <stdint.h>
-#include <string.h>
-
-#define LOG_TAG "AudioSPDIF"
-#include <cutils/log.h>
-#include <audio_utils/spdif/SPDIFEncoder.h>
-
-#include "AC3FrameScanner.h"
-#include "DTSFrameScanner.h"
-#include "MatFrameScanner.h"
-
-namespace android {
-
-// Burst Preamble defined in IEC61937-1
-const uint16_t SPDIFEncoder::kSPDIFSync1 = 0xF872; // Pa
-const uint16_t SPDIFEncoder::kSPDIFSync2 = 0x4E1F; // Pb
-
-static int32_t sEndianDetector = 1;
-#define isLittleEndian()  (*((uint8_t *)&sEndianDetector))
-
-SPDIFEncoder::SPDIFEncoder(audio_format_t format)
-  : mFramer(NULL)
-  , mSampleRate(48000)
-  , mBurstBuffer(NULL)
-  , mBurstBufferSizeBytes(0)
-  , mRateMultiplier(1)
-  , mBurstFrames(0)
-  , mByteCursor(0)
-  , mBitstreamNumber(0)
-  , mPayloadBytesPending(0)
-  , mScanning(true)
-  , mFrameSize(0)
-{
-    switch(format) {
-        case AUDIO_FORMAT_AC3:
-        case AUDIO_FORMAT_E_AC3:
-            mFramer = new AC3FrameScanner(format);
-            break;
-        case AUDIO_FORMAT_DTS:
-        case AUDIO_FORMAT_DTS_HD:
-            mFramer = new DTSFrameScanner();
-            break;
-        case AUDIO_FORMAT_MAT:
-            mFramer = new MatFrameScanner();
-            break;
-        default:
-            break;
-    }
-
-    // This a programmer error. Call isFormatSupported() first.
-    LOG_ALWAYS_FATAL_IF((mFramer == NULL),
-        "SPDIFEncoder: invalid audio format = 0x%08X", format);
-
-    mBurstBufferSizeBytes = sizeof(uint16_t)
-            * SPDIF_ENCODED_CHANNEL_COUNT
-            * mFramer->getMaxSampleFramesPerSyncFrame();
-
-    ALOGI("SPDIFEncoder: mBurstBufferSizeBytes = %zu, littleEndian = %d",
-            mBurstBufferSizeBytes, isLittleEndian());
-    mBurstBuffer = new uint16_t[mBurstBufferSizeBytes >> 1];
-    clearBurstBuffer();
-}
-
-SPDIFEncoder::SPDIFEncoder()
-    : SPDIFEncoder(AUDIO_FORMAT_AC3)
-{
-}
-
-SPDIFEncoder::~SPDIFEncoder()
-{
-    delete[] mBurstBuffer;
-    delete mFramer;
-}
-
-bool SPDIFEncoder::isFormatSupported(audio_format_t format)
-{
-    switch(format) {
-        case AUDIO_FORMAT_AC3:
-        case AUDIO_FORMAT_E_AC3:
-        case AUDIO_FORMAT_DTS:
-        case AUDIO_FORMAT_DTS_HD:
-            return true;
-        default:
-            return false;
-    }
-}
-
-int SPDIFEncoder::getBytesPerOutputFrame()
-{
-    return SPDIF_ENCODED_CHANNEL_COUNT * sizeof(int16_t);
-}
-
-void SPDIFEncoder::writeBurstBufferShorts(const uint16_t *buffer, size_t numShorts)
-{
-    // avoid static analyser warning
-    LOG_ALWAYS_FATAL_IF((mBurstBuffer == NULL), "mBurstBuffer never allocated");
-    mByteCursor = (mByteCursor + 1) & ~1; // round up to even byte
-    size_t bytesToWrite = numShorts * sizeof(uint16_t);
-    if ((mByteCursor + bytesToWrite) > mBurstBufferSizeBytes) {
-        ALOGE("SPDIFEncoder: Burst buffer overflow!");
-        reset();
-        return;
-    }
-    memcpy(&mBurstBuffer[mByteCursor >> 1], buffer, bytesToWrite);
-    mByteCursor += bytesToWrite;
-}
-
-// Pack the bytes into the short buffer in the order:
-//   byte[0] -> short[0] MSB
-//   byte[1] -> short[0] LSB
-//   byte[2] -> short[1] MSB
-//   byte[3] -> short[1] LSB
-//   etcetera
-// This way they should come out in the correct order for SPDIF on both
-// Big and Little Endian CPUs.
-void SPDIFEncoder::writeBurstBufferBytes(const uint8_t *buffer, size_t numBytes)
-{
-    size_t bytesToWrite = numBytes;
-    if ((mByteCursor + bytesToWrite) > mBurstBufferSizeBytes) {
-        ALOGE("SPDIFEncoder: Burst buffer overflow!");
-        clearBurstBuffer();
-        return;
-    }
-    uint16_t pad = mBurstBuffer[mByteCursor >> 1];
-    for (size_t i = 0; i < bytesToWrite; i++) {
-        if (mByteCursor & 1 ) {
-            pad |= *buffer++; // put second byte in LSB
-            mBurstBuffer[mByteCursor >> 1] = pad;
-            pad = 0;
-        } else {
-            pad |= (*buffer++) << 8; // put first byte in MSB
-        }
-        mByteCursor++;
-    }
-    // Save partially filled short.
-    if (mByteCursor & 1 ){
-        mBurstBuffer[mByteCursor >> 1] = pad;
-    }
-}
-
-void SPDIFEncoder::sendZeroPad()
-{
-    // Pad remainder of burst with zeros.
-    size_t burstSize = mFramer->getSampleFramesPerSyncFrame() * sizeof(uint16_t)
-            * SPDIF_ENCODED_CHANNEL_COUNT;
-    if (mByteCursor > burstSize) {
-        ALOGE("SPDIFEncoder: Burst buffer, contents too large!");
-        clearBurstBuffer();
-    } else {
-        // We don't have to write zeros because buffer already set to zero
-        // by clearBurstBuffer(). Just pretend we wrote zeros by
-        // incrementing cursor.
-        mByteCursor = burstSize;
-    }
-}
-
-void SPDIFEncoder::reset()
-{
-    ALOGV("SPDIFEncoder: reset()");
-    clearBurstBuffer();
-    if (mFramer != NULL) {
-        mFramer->resetBurst();
-    }
-    mPayloadBytesPending = 0;
-    mScanning = true;
-}
-
-void SPDIFEncoder::flushBurstBuffer()
-{
-    const int preambleSize = 4 * sizeof(uint16_t);
-    if (mByteCursor > preambleSize) {
-        // Set lengthCode for valid payload before zeroPad.
-        uint16_t numBytes = (mByteCursor - preambleSize);
-        mBurstBuffer[3] = mFramer->convertBytesToLengthCode(numBytes);
-
-        sendZeroPad();
-        writeOutput(mBurstBuffer, mByteCursor);
-    }
-    reset();
-}
-
-void SPDIFEncoder::clearBurstBuffer()
-{
-    if (mBurstBuffer) {
-        memset(mBurstBuffer, 0, mBurstBufferSizeBytes);
-    }
-    mByteCursor = 0;
-}
-
-void SPDIFEncoder::startDataBurst()
-{
-    // Encode IEC61937-1 Burst Preamble
-    uint16_t preamble[4];
-
-    uint16_t burstInfo = (mBitstreamNumber << 13)
-        | (mFramer->getDataTypeInfo() << 8)
-        | mFramer->getDataType();
-
-    mRateMultiplier = mFramer->getRateMultiplier();
-
-    preamble[0] = kSPDIFSync1;
-    preamble[1] = kSPDIFSync2;
-    preamble[2] = burstInfo;
-    preamble[3] = 0; // lengthCode - This will get set after the buffer is full.
-    writeBurstBufferShorts(preamble, 4);
-}
-
-size_t SPDIFEncoder::startSyncFrame()
-{
-    // Write start of encoded frame that was buffered in frame detector.
-    size_t syncSize = mFramer->getHeaderSizeBytes();
-    writeBurstBufferBytes(mFramer->getHeaderAddress(), syncSize);
-    return mFramer->getFrameSizeBytes() - syncSize;
-}
-
-// Wraps raw encoded data into a data burst.
-ssize_t SPDIFEncoder::write( const void *buffer, size_t numBytes )
-{
-    size_t bytesLeft = numBytes;
-    const uint8_t *data = (const uint8_t *)buffer;
-    ALOGV("SPDIFEncoder: mScanning = %d, write(buffer[0] = 0x%02X, numBytes = %zu)",
-        mScanning, (uint) *data, numBytes);
-    while (bytesLeft > 0) {
-        if (mScanning) {
-        // Look for beginning of next encoded frame.
-            if (mFramer->scan(*data)) {
-                if (mByteCursor == 0) {
-                    startDataBurst();
-                } else if (mFramer->isFirstInBurst()) {
-                    // Make sure that this frame is at the beginning of the data burst.
-                    flushBurstBuffer();
-                    startDataBurst();
-                }
-                mPayloadBytesPending = startSyncFrame();
-                mScanning = false;
-            }
-            data++;
-            bytesLeft--;
-        } else {
-            // Write payload until we hit end of frame.
-            size_t bytesToWrite = bytesLeft;
-            // Only write as many as we need to finish the frame.
-            if (bytesToWrite > mPayloadBytesPending) {
-                bytesToWrite = mPayloadBytesPending;
-            }
-            writeBurstBufferBytes(data, bytesToWrite);
-
-            data += bytesToWrite;
-            bytesLeft -= bytesToWrite;
-            mPayloadBytesPending -= bytesToWrite;
-
-            // If we have all the payload then send a data burst.
-            if (mPayloadBytesPending == 0) {
-                if (mFramer->isLastInBurst()) {
-                    flushBurstBuffer();
-                }
-                mScanning = true;
-            }
-        }
-    }
-    return numBytes;
-}
-
-}  // namespace android