diff --git a/audio/Android.mk b/audio/Android.mk
deleted file mode 100644
index 90c18fa..0000000
--- a/audio/Android.mk
+++ /dev/null
@@ -1,43 +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.
-
-LOCAL_PATH := $(call my-dir)
-
-# The default audio HAL module, which is a stub, that is loaded if no other
-# device specific modules are present. The exact load order can be seen in
-# libhardware/hardware.c
-#
-# The format of the name is audio.<type>.<hardware/etc>.so where the only
-# required type is 'primary'. Other possibilites are 'a2dp', 'usb', etc.
-include $(CLEAR_VARS)
-
-LOCAL_HEADER_LIBRARIES += libhardware_headers
-LOCAL_MODULE := audio.primary.$(TARGET_BOARD_PLATFORM)
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_VENDOR_MODULE := true
-
-LOCAL_SRC_FILES := audio_hw.c \
-    audio_aec.c \
-    fifo_wrapper.cpp \
-    fir_filter.c
-LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa libaudioroute libaudioutils
-LOCAL_CFLAGS := -Wno-unused-parameter
-LOCAL_C_INCLUDES += \
-        external/tinyalsa/include \
-        external/expat/lib \
-        $(call include-path-for, audio-route) \
-        system/media/audio_utils/include \
-        system/media/audio_effects/include
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/audio/audio_aec.c b/audio/audio_aec.c
deleted file mode 100644
index ab99c93..0000000
--- a/audio/audio_aec.c
+++ /dev/null
@@ -1,700 +0,0 @@
-/*
- * Copyright (C) 2019 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.
- */
-
-// clang-format off
-/*
- * Typical AEC signal flow:
- *
- *                          Microphone Audio
- *                          Timestamps
- *                        +--------------------------------------+
- *                        |                                      |       +---------------+
- *                        |    Microphone +---------------+      |       |               |
- *             O|======   |    Audio      | Sample Rate   |      +------->               |
- *    (from         .  +--+    Samples    | +             |              |               |
- *     mic          .  +==================> Format        |==============>               |
- *     codec)       .                     | Conversion    |              |               |   Cleaned
- *             O|======                   | (if required) |              |   Acoustic    |   Audio
- *                                        +---------------+              |   Echo        |   Samples
- *                                                                       |   Canceller   |===================>
- *                                                                       |   (AEC)       |
- *                            Reference   +---------------+              |               |
- *                            Audio       | Sample Rate   |              |               |
- *                            Samples     | +             |              |               |
- *                          +=============> Format        |==============>               |
- *                          |             | Conversion    |              |               |
- *                          |             | (if required) |      +------->               |
- *                          |             +---------------+      |       |               |
- *                          |                                    |       +---------------+
- *                          |    +-------------------------------+
- *                          |    |  Reference Audio
- *                          |    |  Timestamps
- *                          |    |
- *                       +--+----+---------+                                                       AUDIO CAPTURE
- *                       | Speaker         |
- *          +------------+ Audio/Timestamp +---------------------------------------------------------------------------+
- *                       | Buffer          |
- *                       +--^----^---------+                                                       AUDIO PLAYBACK
- *                          |    |
- *                          |    |
- *                          |    |
- *                          |    |
- *                |\        |    |
- *                | +-+     |    |
- *      (to       | | +-----C----+
- *       speaker  | | |     |                                                                  Playback
- *       codec)   | | <=====+================================================================+ Audio
- *                | +-+                                                                        Samples
- *                |/
- *
- */
-// clang-format on
-
-#define LOG_TAG "audio_hw_aec"
-// #define LOG_NDEBUG 0
-
-#include <audio_utils/primitives.h>
-#include <stdio.h>
-#include <inttypes.h>
-#include <errno.h>
-#include <malloc.h>
-#include <sys/time.h>
-#include <tinyalsa/asoundlib.h>
-#include <unistd.h>
-#include <log/log.h>
-#include "audio_aec.h"
-
-#ifdef AEC_HAL
-#include "audio_aec_process.h"
-#else
-#define aec_spk_mic_init(...) ((int)0)
-#define aec_spk_mic_reset(...) ((void)0)
-#define aec_spk_mic_process(...) ((int32_t)0)
-#define aec_spk_mic_release(...) ((void)0)
-#endif
-
-#define MAX_TIMESTAMP_DIFF_USEC 200000
-
-#define MAX_READ_WAIT_TIME_MSEC 80
-
-uint64_t timespec_to_usec(struct timespec ts) {
-    return (ts.tv_sec * 1e6L + ts.tv_nsec/1000);
-}
-
-void get_reference_audio_in_place(struct aec_t *aec, size_t frames) {
-    if (aec->num_reference_channels == aec->spk_num_channels) {
-        /* Reference count equals speaker channels, nothing to do here. */
-        return;
-    } else if (aec->num_reference_channels != 1) {
-        /* We don't have  a rule for non-mono references, show error on log */
-        ALOGE("Invalid reference count - must be 1 or match number of playback channels!");
-        return;
-    }
-    int16_t *src_Nch = &aec->spk_buf_playback_format[0];
-    int16_t *dst_1ch = &aec->spk_buf_playback_format[0];
-    int32_t num_channels = (int32_t)aec->spk_num_channels;
-    size_t frame, ch;
-    for (frame = 0; frame < frames; frame++) {
-        int32_t acc = 0;
-        for (ch = 0; ch < aec->spk_num_channels; ch++) {
-            acc += src_Nch[ch];
-        }
-        *dst_1ch++ = clamp16(acc/num_channels);
-        src_Nch += aec->spk_num_channels;
-    }
-}
-
-void print_queue_status_to_log(struct aec_t *aec, bool write_side) {
-    ssize_t q1 = fifo_available_to_read(aec->spk_fifo);
-    ssize_t q2 = fifo_available_to_read(aec->ts_fifo);
-
-    ALOGV("Queue available %s: Spk %zd (count %zd) TS %zd (count %zd)",
-        (write_side) ? "(POST-WRITE)" : "(PRE-READ)",
-        q1, q1/aec->spk_frame_size_bytes/PLAYBACK_PERIOD_SIZE,
-        q2, q2/sizeof(struct aec_info));
-}
-
-void flush_aec_fifos(struct aec_t *aec) {
-    if (aec == NULL) {
-        return;
-    }
-    if (aec->spk_fifo != NULL) {
-        ALOGV("Flushing AEC Spk FIFO...");
-        fifo_flush(aec->spk_fifo);
-    }
-    if (aec->ts_fifo != NULL) {
-        ALOGV("Flushing AEC Timestamp FIFO...");
-        fifo_flush(aec->ts_fifo);
-    }
-    /* Reset FIFO read-write offset tracker */
-    aec->read_write_diff_bytes = 0;
-}
-
-void aec_set_spk_running_no_lock(struct aec_t* aec, bool state) {
-    aec->spk_running = state;
-}
-
-bool aec_get_spk_running_no_lock(struct aec_t* aec) {
-    return aec->spk_running;
-}
-
-void destroy_aec_reference_config_no_lock(struct aec_t* aec) {
-    if (!aec->spk_initialized) {
-        return;
-    }
-    aec_set_spk_running_no_lock(aec, false);
-    fifo_release(aec->spk_fifo);
-    fifo_release(aec->ts_fifo);
-    memset(&aec->last_spk_info, 0, sizeof(struct aec_info));
-    aec->spk_initialized = false;
-}
-
-void destroy_aec_mic_config_no_lock(struct aec_t* aec) {
-    if (!aec->mic_initialized) {
-        return;
-    }
-    release_resampler(aec->spk_resampler);
-    free(aec->mic_buf);
-    free(aec->spk_buf);
-    free(aec->spk_buf_playback_format);
-    free(aec->spk_buf_resampler_out);
-    memset(&aec->last_mic_info, 0, sizeof(struct aec_info));
-    aec->mic_initialized = false;
-}
-
-struct aec_t *init_aec_interface() {
-    ALOGV("%s enter", __func__);
-    struct aec_t *aec = (struct aec_t *)calloc(1, sizeof(struct aec_t));
-    if (aec == NULL) {
-        ALOGE("Failed to allocate memory for AEC interface!");
-    } else {
-        pthread_mutex_init(&aec->lock, NULL);
-    }
-
-    ALOGV("%s exit", __func__);
-    return aec;
-}
-
-void release_aec_interface(struct aec_t *aec) {
-    ALOGV("%s enter", __func__);
-    pthread_mutex_lock(&aec->lock);
-    destroy_aec_mic_config_no_lock(aec);
-    destroy_aec_reference_config_no_lock(aec);
-    pthread_mutex_unlock(&aec->lock);
-    free(aec);
-    ALOGV("%s exit", __func__);
-}
-
-int init_aec(int sampling_rate, int num_reference_channels,
-                int num_microphone_channels, struct aec_t **aec_ptr) {
-    ALOGV("%s enter", __func__);
-    int ret = 0;
-    int aec_ret = aec_spk_mic_init(
-                    sampling_rate,
-                    num_reference_channels,
-                    num_microphone_channels);
-    if (aec_ret) {
-        ALOGE("AEC object failed to initialize!");
-        ret = -EINVAL;
-    }
-    struct aec_t *aec = init_aec_interface();
-    if (!ret) {
-        aec->num_reference_channels = num_reference_channels;
-        /* Set defaults, will be overridden by settings in init_aec_(mic|referece_config) */
-        /* Capture uses 2-ch, 32-bit frames */
-        aec->mic_sampling_rate = CAPTURE_CODEC_SAMPLING_RATE;
-        aec->mic_frame_size_bytes = CHANNEL_STEREO * sizeof(int32_t);
-        aec->mic_num_channels = CHANNEL_STEREO;
-
-        /* Playback uses 2-ch, 16-bit frames */
-        aec->spk_sampling_rate = PLAYBACK_CODEC_SAMPLING_RATE;
-        aec->spk_frame_size_bytes = CHANNEL_STEREO * sizeof(int16_t);
-        aec->spk_num_channels = CHANNEL_STEREO;
-    }
-
-    (*aec_ptr) = aec;
-    ALOGV("%s exit", __func__);
-    return ret;
-}
-
-void release_aec(struct aec_t *aec) {
-    ALOGV("%s enter", __func__);
-    if (aec == NULL) {
-        return;
-    }
-    release_aec_interface(aec);
-    aec_spk_mic_release();
-    ALOGV("%s exit", __func__);
-}
-
-int init_aec_reference_config(struct aec_t *aec, struct alsa_stream_out *out) {
-    ALOGV("%s enter", __func__);
-    if (!aec) {
-        ALOGE("AEC: No valid interface found!");
-        return -EINVAL;
-    }
-
-    int ret = 0;
-    pthread_mutex_lock(&aec->lock);
-    if (aec->spk_initialized) {
-        destroy_aec_reference_config_no_lock(aec);
-    }
-
-    aec->spk_fifo = fifo_init(
-            out->config.period_count * out->config.period_size *
-                audio_stream_out_frame_size(&out->stream),
-            false /* reader_throttles_writer */);
-    if (aec->spk_fifo == NULL) {
-        ALOGE("AEC: Speaker loopback FIFO Init failed!");
-        ret = -EINVAL;
-        goto exit;
-    }
-    aec->ts_fifo = fifo_init(
-            out->config.period_count * sizeof(struct aec_info),
-            false /* reader_throttles_writer */);
-    if (aec->ts_fifo == NULL) {
-        ALOGE("AEC: Speaker timestamp FIFO Init failed!");
-        ret = -EINVAL;
-        fifo_release(aec->spk_fifo);
-        goto exit;
-    }
-
-    aec->spk_sampling_rate = out->config.rate;
-    aec->spk_frame_size_bytes = audio_stream_out_frame_size(&out->stream);
-    aec->spk_num_channels = out->config.channels;
-    aec->spk_initialized = true;
-exit:
-    pthread_mutex_unlock(&aec->lock);
-    ALOGV("%s exit", __func__);
-    return ret;
-}
-
-void destroy_aec_reference_config(struct aec_t* aec) {
-    ALOGV("%s enter", __func__);
-    if (aec == NULL) {
-        ALOGV("%s exit", __func__);
-        return;
-    }
-    pthread_mutex_lock(&aec->lock);
-    destroy_aec_reference_config_no_lock(aec);
-    pthread_mutex_unlock(&aec->lock);
-    ALOGV("%s exit", __func__);
-}
-
-int write_to_reference_fifo(struct aec_t* aec, void* buffer, struct aec_info* info) {
-    ALOGV("%s enter", __func__);
-    int ret = 0;
-    size_t bytes = info->bytes;
-
-    /* Write audio samples to FIFO */
-    ssize_t written_bytes = fifo_write(aec->spk_fifo, buffer, bytes);
-    if (written_bytes != bytes) {
-        ALOGE("Could only write %zu of %zu bytes", written_bytes, bytes);
-        ret = -ENOMEM;
-    }
-
-    /* Write timestamp to FIFO */
-    info->bytes = written_bytes;
-    ALOGV("Speaker timestamp: %ld s, %ld nsec", info->timestamp.tv_sec, info->timestamp.tv_nsec);
-    ssize_t ts_bytes = fifo_write(aec->ts_fifo, info, sizeof(struct aec_info));
-    ALOGV("Wrote TS bytes: %zu", ts_bytes);
-    print_queue_status_to_log(aec, true);
-    ALOGV("%s exit", __func__);
-    return ret;
-}
-
-void get_spk_timestamp(struct aec_t* aec, ssize_t read_bytes, uint64_t* spk_time) {
-    *spk_time = 0;
-    uint64_t spk_time_offset = 0;
-    float usec_per_byte = 1E6 / ((float)(aec->spk_frame_size_bytes * aec->spk_sampling_rate));
-    if (aec->read_write_diff_bytes < 0) {
-        /* We're still reading a previous write packet. (We only need the first sample's timestamp,
-         * so even if we straddle packets we only care about the first one)
-         * So we just use the previous timestamp, with an appropriate offset
-         * based on the number of bytes remaining to be read from that write packet. */
-        spk_time_offset = (aec->last_spk_info.bytes + aec->read_write_diff_bytes) * usec_per_byte;
-        ALOGV("Reusing previous timestamp, calculated offset (usec) %" PRIu64, spk_time_offset);
-    } else {
-        /* If read_write_diff_bytes > 0, there are no new writes, so there won't be timestamps in
-         * the FIFO, and the check below will fail. */
-        if (!fifo_available_to_read(aec->ts_fifo)) {
-            ALOGE("Timestamp error: no new timestamps!");
-            return;
-        }
-        /* We just read valid data, so if we're here, we should have a valid timestamp to use. */
-        ssize_t ts_bytes = fifo_read(aec->ts_fifo, &aec->last_spk_info, sizeof(struct aec_info));
-        ALOGV("Read TS bytes: %zd, expected %zu", ts_bytes, sizeof(struct aec_info));
-        aec->read_write_diff_bytes -= aec->last_spk_info.bytes;
-    }
-
-    *spk_time = timespec_to_usec(aec->last_spk_info.timestamp) + spk_time_offset;
-
-    aec->read_write_diff_bytes += read_bytes;
-    struct aec_info spk_info = aec->last_spk_info;
-    while (aec->read_write_diff_bytes > 0) {
-        /* If read_write_diff_bytes > 0, it means that there are more write packet timestamps
-         * in FIFO (since there we read more valid data the size of the current timestamp's
-         * packet). Keep reading timestamps from FIFO to get to the most recent one. */
-        if (!fifo_available_to_read(aec->ts_fifo)) {
-            /* There are no more timestamps, we have the most recent one. */
-            ALOGV("At the end of timestamp FIFO, breaking...");
-            break;
-        }
-        fifo_read(aec->ts_fifo, &spk_info, sizeof(struct aec_info));
-        ALOGV("Fast-forwarded timestamp by %zd bytes, remaining bytes: %zd,"
-              " new timestamp (usec) %" PRIu64,
-              spk_info.bytes, aec->read_write_diff_bytes, timespec_to_usec(spk_info.timestamp));
-        aec->read_write_diff_bytes -= spk_info.bytes;
-    }
-    aec->last_spk_info = spk_info;
-}
-
-int get_reference_samples(struct aec_t* aec, void* buffer, struct aec_info* info) {
-    ALOGV("%s enter", __func__);
-
-    if (!aec->spk_initialized) {
-        ALOGE("%s called with no reference initialized", __func__);
-        return -EINVAL;
-    }
-
-    size_t bytes = info->bytes;
-    const size_t frames = bytes / aec->mic_frame_size_bytes;
-    const size_t sample_rate_ratio = aec->spk_sampling_rate / aec->mic_sampling_rate;
-
-    /* Read audio samples from FIFO */
-    const size_t req_bytes = frames * sample_rate_ratio * aec->spk_frame_size_bytes;
-    ssize_t available_bytes = 0;
-    unsigned int wait_count = MAX_READ_WAIT_TIME_MSEC;
-    while (true) {
-        available_bytes = fifo_available_to_read(aec->spk_fifo);
-        if (available_bytes >= req_bytes) {
-            break;
-        } else if (available_bytes < 0) {
-            ALOGE("fifo_read returned code %zu ", available_bytes);
-            return -ENOMEM;
-        }
-
-        ALOGV("Sleeping, required bytes: %zu, available bytes: %zd", req_bytes, available_bytes);
-        usleep(1000);
-        if ((wait_count--) == 0) {
-            ALOGE("Timed out waiting for read from reference FIFO");
-            return -ETIMEDOUT;
-        }
-    }
-
-    const size_t read_bytes = fifo_read(aec->spk_fifo, aec->spk_buf_playback_format, req_bytes);
-
-    /* Get timestamp*/
-    get_spk_timestamp(aec, read_bytes, &info->timestamp_usec);
-
-    /* Get reference - could be mono, downmixed from multichannel.
-     * Reference stored at spk_buf_playback_format */
-    const size_t resampler_in_frames = frames * sample_rate_ratio;
-    get_reference_audio_in_place(aec, resampler_in_frames);
-
-    int16_t* resampler_out_buf;
-    /* Resample to mic sampling rate (16-bit resampler) */
-    if (aec->spk_resampler != NULL) {
-        size_t in_frame_count = resampler_in_frames;
-        size_t out_frame_count = frames;
-        aec->spk_resampler->resample_from_input(aec->spk_resampler, aec->spk_buf_playback_format,
-                                                &in_frame_count, aec->spk_buf_resampler_out,
-                                                &out_frame_count);
-        resampler_out_buf = aec->spk_buf_resampler_out;
-    } else {
-        if (sample_rate_ratio != 1) {
-            ALOGE("Speaker sample rate %d, mic sample rate %d but no resampler defined!",
-                  aec->spk_sampling_rate, aec->mic_sampling_rate);
-        }
-        resampler_out_buf = aec->spk_buf_playback_format;
-    }
-
-    /* Convert to 32 bit */
-    int16_t* src16 = resampler_out_buf;
-    int32_t* dst32 = buffer;
-    size_t frame, ch;
-    for (frame = 0; frame < frames; frame++) {
-        for (ch = 0; ch < aec->num_reference_channels; ch++) {
-            *dst32++ = ((int32_t)*src16++) << 16;
-        }
-    }
-
-    info->bytes = bytes;
-
-    ALOGV("%s exit", __func__);
-    return 0;
-}
-
-int init_aec_mic_config(struct aec_t *aec, struct alsa_stream_in *in) {
-    ALOGV("%s enter", __func__);
-#if DEBUG_AEC
-    remove("/data/local/traces/aec_in.pcm");
-    remove("/data/local/traces/aec_out.pcm");
-    remove("/data/local/traces/aec_ref.pcm");
-    remove("/data/local/traces/aec_timestamps.txt");
-#endif /* #if DEBUG_AEC */
-
-    if (!aec) {
-        ALOGE("AEC: No valid interface found!");
-        return -EINVAL;
-    }
-
-    int ret = 0;
-    pthread_mutex_lock(&aec->lock);
-    if (aec->mic_initialized) {
-        destroy_aec_mic_config_no_lock(aec);
-    }
-    aec->mic_sampling_rate = in->config.rate;
-    aec->mic_frame_size_bytes = audio_stream_in_frame_size(&in->stream);
-    aec->mic_num_channels = in->config.channels;
-
-    aec->mic_buf_size_bytes = in->config.period_size * audio_stream_in_frame_size(&in->stream);
-    aec->mic_buf = (int32_t *)malloc(aec->mic_buf_size_bytes);
-    if (aec->mic_buf == NULL) {
-        ret = -ENOMEM;
-        goto exit;
-    }
-    memset(aec->mic_buf, 0, aec->mic_buf_size_bytes);
-    /* Reference buffer is the same number of frames as mic,
-     * only with a different number of channels in the frame. */
-    aec->spk_buf_size_bytes = in->config.period_size * aec->spk_frame_size_bytes;
-    aec->spk_buf = (int32_t *)malloc(aec->spk_buf_size_bytes);
-    if (aec->spk_buf == NULL) {
-        ret = -ENOMEM;
-        goto exit_1;
-    }
-    memset(aec->spk_buf, 0, aec->spk_buf_size_bytes);
-
-    /* Pre-resampler buffer */
-    size_t spk_frame_out_format_bytes = aec->spk_sampling_rate / aec->mic_sampling_rate *
-                                            aec->spk_buf_size_bytes;
-    aec->spk_buf_playback_format = (int16_t *)malloc(spk_frame_out_format_bytes);
-    if (aec->spk_buf_playback_format == NULL) {
-        ret = -ENOMEM;
-        goto exit_2;
-    }
-    /* Resampler is 16-bit */
-    aec->spk_buf_resampler_out = (int16_t *)malloc(aec->spk_buf_size_bytes);
-    if (aec->spk_buf_resampler_out == NULL) {
-        ret = -ENOMEM;
-        goto exit_3;
-    }
-
-    /* Don't use resampler if it's not required */
-    if (in->config.rate == aec->spk_sampling_rate) {
-        aec->spk_resampler = NULL;
-    } else {
-        int resampler_ret = create_resampler(
-                aec->spk_sampling_rate, in->config.rate, aec->num_reference_channels,
-                RESAMPLER_QUALITY_MAX - 1, /* MAX - 1 is the real max */
-                NULL,                      /* resampler_buffer_provider */
-                &aec->spk_resampler);
-        if (resampler_ret) {
-            ALOGE("AEC: Resampler initialization failed! Error code %d", resampler_ret);
-            ret = resampler_ret;
-            goto exit_4;
-        }
-    }
-
-    flush_aec_fifos(aec);
-    aec_spk_mic_reset();
-    aec->mic_initialized = true;
-
-exit:
-    pthread_mutex_unlock(&aec->lock);
-    ALOGV("%s exit", __func__);
-    return ret;
-
-exit_4:
-    free(aec->spk_buf_resampler_out);
-exit_3:
-    free(aec->spk_buf_playback_format);
-exit_2:
-    free(aec->spk_buf);
-exit_1:
-    free(aec->mic_buf);
-    pthread_mutex_unlock(&aec->lock);
-    ALOGV("%s exit", __func__);
-    return ret;
-}
-
-void aec_set_spk_running(struct aec_t *aec, bool state) {
-    ALOGV("%s enter", __func__);
-    pthread_mutex_lock(&aec->lock);
-    aec_set_spk_running_no_lock(aec, state);
-    pthread_mutex_unlock(&aec->lock);
-    ALOGV("%s exit", __func__);
-}
-
-bool aec_get_spk_running(struct aec_t *aec) {
-    ALOGV("%s enter", __func__);
-    pthread_mutex_lock(&aec->lock);
-    bool state = aec_get_spk_running_no_lock(aec);
-    pthread_mutex_unlock(&aec->lock);
-    ALOGV("%s exit", __func__);
-    return state;
-}
-
-void destroy_aec_mic_config(struct aec_t* aec) {
-    ALOGV("%s enter", __func__);
-    if (aec == NULL) {
-        ALOGV("%s exit", __func__);
-        return;
-    }
-
-    pthread_mutex_lock(&aec->lock);
-    destroy_aec_mic_config_no_lock(aec);
-    pthread_mutex_unlock(&aec->lock);
-    ALOGV("%s exit", __func__);
-}
-
-#ifdef AEC_HAL
-int process_aec(struct aec_t *aec, void* buffer, struct aec_info *info) {
-    ALOGV("%s enter", __func__);
-    int ret = 0;
-
-    if (aec == NULL) {
-        ALOGE("AEC: Interface uninitialized! Cannot process.");
-        return -EINVAL;
-    }
-
-    if ((!aec->mic_initialized) || (!aec->spk_initialized)) {
-        ALOGE("%s called with initialization: mic: %d, spk: %d", __func__, aec->mic_initialized,
-              aec->spk_initialized);
-        return -EINVAL;
-    }
-
-    size_t bytes = info->bytes;
-
-    size_t frame_size = aec->mic_frame_size_bytes;
-    size_t in_frames = bytes / frame_size;
-
-    /* Copy raw mic samples to AEC input buffer */
-    memcpy(aec->mic_buf, buffer, bytes);
-
-    uint64_t mic_time = timespec_to_usec(info->timestamp);
-    uint64_t spk_time = 0;
-
-    /*
-     * Only run AEC if there is speaker playback.
-     * The first time speaker state changes to running, flush FIFOs, so we're not stuck
-     * processing stale reference input.
-     */
-    bool spk_running = aec_get_spk_running(aec);
-
-    if (!spk_running) {
-        /* No new playback samples, so don't run AEC.
-         * 'buffer' already contains input samples. */
-        ALOGV("Speaker not running, skipping AEC..");
-        goto exit;
-    }
-
-    if (!aec->prev_spk_running) {
-        flush_aec_fifos(aec);
-    }
-
-    /* If there's no data in FIFO, exit */
-    if (fifo_available_to_read(aec->spk_fifo) <= 0) {
-        ALOGV("Echo reference buffer empty, zeroing reference....");
-        goto exit;
-    }
-
-    print_queue_status_to_log(aec, false);
-
-    /* Get reference, with format and sample rate required by AEC */
-    struct aec_info spk_info;
-    spk_info.bytes = bytes;
-    int ref_ret = get_reference_samples(aec, aec->spk_buf, &spk_info);
-    spk_time = spk_info.timestamp_usec;
-
-    if (ref_ret) {
-        ALOGE("get_reference_samples returned code %d", ref_ret);
-        ret = -ENOMEM;
-        goto exit;
-    }
-
-    int64_t time_diff = (mic_time > spk_time) ? (mic_time - spk_time) : (spk_time - mic_time);
-    if ((spk_time == 0) || (mic_time == 0) || (time_diff > MAX_TIMESTAMP_DIFF_USEC)) {
-        ALOGV("Speaker-mic timestamps diverged, skipping AEC");
-        flush_aec_fifos(aec);
-        aec_spk_mic_reset();
-        goto exit;
-    }
-
-    ALOGV("Mic time: %"PRIu64", spk time: %"PRIu64, mic_time, spk_time);
-
-    /*
-     * AEC processing call - output stored at 'buffer'
-     */
-    int32_t aec_status = aec_spk_mic_process(
-        aec->spk_buf, spk_time,
-        aec->mic_buf, mic_time,
-        in_frames,
-        buffer);
-
-    if (!aec_status) {
-        ALOGE("AEC processing failed!");
-        ret = -EINVAL;
-    }
-
-exit:
-    aec->prev_spk_running = spk_running;
-    ALOGV("Mic time: %"PRIu64", spk time: %"PRIu64, mic_time, spk_time);
-    if (ret) {
-        /* Best we can do is copy over the raw mic signal */
-        memcpy(buffer, aec->mic_buf, bytes);
-        flush_aec_fifos(aec);
-        aec_spk_mic_reset();
-    }
-
-#if DEBUG_AEC
-    /* ref data is 32-bit at this point */
-    size_t ref_bytes = in_frames*aec->num_reference_channels*sizeof(int32_t);
-
-    FILE *fp_in = fopen("/data/local/traces/aec_in.pcm", "a+");
-    if (fp_in) {
-        fwrite((char *)aec->mic_buf, 1, bytes, fp_in);
-        fclose(fp_in);
-    } else {
-        ALOGE("AEC debug: Could not open file aec_in.pcm!");
-    }
-    FILE *fp_out = fopen("/data/local/traces/aec_out.pcm", "a+");
-    if (fp_out) {
-        fwrite((char *)buffer, 1, bytes, fp_out);
-        fclose(fp_out);
-    } else {
-        ALOGE("AEC debug: Could not open file aec_out.pcm!");
-    }
-    FILE *fp_ref = fopen("/data/local/traces/aec_ref.pcm", "a+");
-    if (fp_ref) {
-        fwrite((char *)aec->spk_buf, 1, ref_bytes, fp_ref);
-        fclose(fp_ref);
-    } else {
-        ALOGE("AEC debug: Could not open file aec_ref.pcm!");
-    }
-    FILE *fp_ts = fopen("/data/local/traces/aec_timestamps.txt", "a+");
-    if (fp_ts) {
-        fprintf(fp_ts, "%"PRIu64",%"PRIu64"\n", mic_time, spk_time);
-        fclose(fp_ts);
-    } else {
-        ALOGE("AEC debug: Could not open file aec_timestamps.txt!");
-    }
-#endif /* #if DEBUG_AEC */
-    ALOGV("%s exit", __func__);
-    return ret;
-}
-
-#endif /*#ifdef AEC_HAL*/
diff --git a/audio/audio_aec.h b/audio/audio_aec.h
deleted file mode 100644
index ac7a1dd..0000000
--- a/audio/audio_aec.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2019 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.
- */
-
-/*
- * Definitions and interface related to HAL implementations of Acoustic Echo Canceller (AEC).
- *
- * AEC cleans the microphone signal by removing from it audio data corresponding to loudspeaker
- * playback. Note that this process can be nonlinear.
- *
- */
-
-#ifndef _AUDIO_AEC_H_
-#define _AUDIO_AEC_H_
-
-#include <stdint.h>
-#include <pthread.h>
-#include <sys/time.h>
-#include <hardware/audio.h>
-#include <audio_utils/resampler.h>
-#include "audio_hw.h"
-#include "fifo_wrapper.h"
-
-struct aec_t {
-    pthread_mutex_t lock;
-    size_t num_reference_channels;
-    bool mic_initialized;
-    int32_t *mic_buf;
-    size_t mic_num_channels;
-    size_t mic_buf_size_bytes;
-    size_t mic_frame_size_bytes;
-    uint32_t mic_sampling_rate;
-    struct aec_info last_mic_info;
-    bool spk_initialized;
-    int32_t *spk_buf;
-    size_t spk_num_channels;
-    size_t spk_buf_size_bytes;
-    size_t spk_frame_size_bytes;
-    uint32_t spk_sampling_rate;
-    struct aec_info last_spk_info;
-    int16_t *spk_buf_playback_format;
-    int16_t *spk_buf_resampler_out;
-    void *spk_fifo;
-    void *ts_fifo;
-    ssize_t read_write_diff_bytes;
-    struct resampler_itfe *spk_resampler;
-    bool spk_running;
-    bool prev_spk_running;
-};
-
-/* Initialize AEC object.
- * This must be called when the audio device is opened.
- * ALSA device mutex must be held before calling this API.
- * Returns -EINVAL if AEC object fails to initialize, else returns 0. */
-int init_aec (int sampling_rate, int num_reference_channels,
-                int num_microphone_channels, struct aec_t **);
-
-/* Release AEC object.
- * This must be called when the audio device is closed. */
-void release_aec(struct aec_t* aec);
-
-/* Initialize reference configuration for AEC.
- * Must be called when a new output stream is opened.
- * Returns -EINVAL if any processing block fails to initialize,
- * else returns 0. */
-int init_aec_reference_config (struct aec_t *aec, struct alsa_stream_out *out);
-
-/* Clear reference configuration for AEC.
- * Must be called when the output stream is closed. */
-void destroy_aec_reference_config (struct aec_t *aec);
-
-/* Initialize microphone configuration for AEC.
- * Must be called when a new input stream is opened.
- * Returns -EINVAL if any processing block fails to initialize,
- * else returns 0. */
-int init_aec_mic_config(struct aec_t* aec, struct alsa_stream_in* in);
-
-/* Clear microphone configuration for AEC.
- * Must be called when the input stream is closed. */
-void destroy_aec_mic_config (struct aec_t *aec);
-
-/* Used to communicate playback state (running or not) to AEC interface.
- * This is used by process_aec() to determine if AEC processing is to be run. */
-void aec_set_spk_running (struct aec_t *aec, bool state);
-
-/* Used to communicate playback state (running or not) to the caller. */
-bool aec_get_spk_running(struct aec_t* aec);
-
-/* Write audio samples to AEC reference FIFO for use in AEC.
- * Both audio samples and timestamps are added in FIFO fashion.
- * Must be called after every write to PCM.
- * Returns -ENOMEM if the write fails, else returns 0. */
-int write_to_reference_fifo(struct aec_t* aec, void* buffer, struct aec_info* info);
-
-/* Get reference audio samples + timestamp, in the format expected by AEC,
- * i.e. same sample rate and bit rate as microphone audio.
- * Timestamp is updated in field 'timestamp_usec', and not in 'timestamp'.
- * Returns:
- *  -EINVAL    if the AEC object is invalid.
- *  -ENOMEM    if the reference FIFO overflows or is corrupted.
- *  -ETIMEDOUT if we timed out waiting for the requested number of bytes
- *  0          otherwise */
-int get_reference_samples(struct aec_t* aec, void* buffer, struct aec_info* info);
-
-#ifdef AEC_HAL
-
-/* Processing function call for AEC.
- * AEC output is updated at location pointed to by 'buffer'.
- * This function does not run AEC when there is no playback -
- * as communicated to this AEC interface using aec_set_spk_running().
- * Returns -EINVAL if processing fails, else returns 0. */
-int process_aec(struct aec_t* aec, void* buffer, struct aec_info* info);
-
-#else /* #ifdef AEC_HAL */
-
-#define process_aec(...) ((int)0)
-
-#endif /* #ifdef AEC_HAL */
-
-#endif /* _AUDIO_AEC_H_ */
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
deleted file mode 100644
index c7341ef..0000000
--- a/audio/audio_hw.c
+++ /dev/null
@@ -1,1225 +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.
- *
- * Copied as it is from device/amlogic/generic/hal/audio/
- */
-
-#define LOG_TAG "audio_hw_generic"
-//#define LOG_NDEBUG 0
-
-#include <errno.h>
-#include <inttypes.h>
-#include <malloc.h>
-#include <pthread.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <unistd.h>
-
-#include <log/log.h>
-#include <cutils/str_parms.h>
-#include <cutils/properties.h>
-
-#include <hardware/hardware.h>
-#include <system/audio.h>
-#include <hardware/audio.h>
-
-#include <audio_effects/effect_aec.h>
-#include <audio_route/audio_route.h>
-#include <audio_utils/clock.h>
-#include <audio_utils/echo_reference.h>
-#include <audio_utils/resampler.h>
-#include <hardware/audio_alsaops.h>
-#include <hardware/audio_effect.h>
-#include <sound/asound.h>
-#include <tinyalsa/asoundlib.h>
-
-#include <sys/ioctl.h>
-
-#include "audio_aec.h"
-#include "audio_hw.h"
-
-static int adev_get_mic_mute(const struct audio_hw_device* dev, bool* state);
-static int adev_get_microphones(const struct audio_hw_device* dev,
-                                struct audio_microphone_characteristic_t* mic_array,
-                                size_t* mic_count);
-static size_t out_get_buffer_size(const struct audio_stream* stream);
-
-static bool is_aec_input(const struct alsa_stream_in* in) {
-    /* If AEC is in the app, only configure based on ECHO_REFERENCE spec.
-     * If AEC is in the HAL, configure using the given mic stream. */
-    bool aec_input = true;
-#if !defined(AEC_HAL)
-    aec_input = (in->source == AUDIO_SOURCE_ECHO_REFERENCE);
-#endif
-    return aec_input;
-}
-
-static int get_audio_output_port(audio_devices_t devices) {
-    /* Default to internal speaker */
-    int port = PORT_INTERNAL_SPEAKER;
-    if (devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
-        port = PORT_HEADSET;
-    }
-
-    ALOGI("CA:: %s: port = %d", __func__, port);
-    return port;
-}
-
-static char* get_mixer_path_for_port(int port) {
-    switch (port)
-    {
-    case PORT_INTERNAL_SPEAKER:
-        return "speaker";
-        break;
-    case PORT_HEADSET:
-        return "headset";
-        break;    
-    default:
-        return NULL;
-        break;
-    }
-}
-
-static void timestamp_adjust(struct timespec* ts, ssize_t frames, uint32_t sampling_rate) {
-    /* This function assumes the adjustment (in nsec) is less than the max value of long,
-     * which for 32-bit long this is 2^31 * 1e-9 seconds, slightly over 2 seconds.
-     * For 64-bit long it is  9e+9 seconds. */
-    long adj_nsec = (frames / (float) sampling_rate) * 1E9L;
-    ts->tv_nsec += adj_nsec;
-    while (ts->tv_nsec > 1E9L) {
-        ts->tv_sec++;
-        ts->tv_nsec -= 1E9L;
-    }
-    if (ts->tv_nsec < 0) {
-        ts->tv_sec--;
-        ts->tv_nsec += 1E9L;
-    }
-}
-
-/* Helper function to get PCM hardware timestamp.
- * Only the field 'timestamp' of argument 'ts' is updated. */
-static int get_pcm_timestamp(struct pcm* pcm, uint32_t sample_rate, struct aec_info* info,
-                             bool isOutput) {
-    int ret = 0;
-    if (pcm_get_htimestamp(pcm, &info->available, &info->timestamp) < 0) {
-        ALOGE("Error getting PCM timestamp!");
-        info->timestamp.tv_sec = 0;
-        info->timestamp.tv_nsec = 0;
-        return -EINVAL;
-    }
-    ssize_t frames;
-    if (isOutput) {
-        frames = pcm_get_buffer_size(pcm) - info->available;
-    } else {
-        frames = -info->available; /* rewind timestamp */
-    }
-    timestamp_adjust(&info->timestamp, frames, sample_rate);
-    return ret;
-}
-
-static int read_filter_from_file(const char* filename, int16_t* filter, int max_length) {
-    FILE* fp = fopen(filename, "r");
-    if (fp == NULL) {
-        ALOGI("%s: File %s not found.", __func__, filename);
-        return 0;
-    }
-    int num_taps = 0;
-    char* line = NULL;
-    size_t len = 0;
-    while (!feof(fp)) {
-        size_t size = getline(&line, &len, fp);
-        if ((line[0] == '#') || (size < 2)) {
-            continue;
-        }
-        int n = sscanf(line, "%" SCNd16 "\n", &filter[num_taps++]);
-        if (n < 1) {
-            ALOGE("Could not find coefficient %d! Exiting...", num_taps - 1);
-            return 0;
-        }
-        ALOGI("CA:: Coeff %d : %" PRId16, num_taps, filter[num_taps - 1]);
-        if (num_taps == max_length) {
-            ALOGI("%s: max tap length %d reached.", __func__, max_length);
-            break;
-        }
-    }
-    free(line);
-    fclose(fp);
-    return num_taps;
-}
-
-static void out_set_eq(struct alsa_stream_out* out) {
-    out->speaker_eq = NULL;
-    int16_t* speaker_eq_coeffs = (int16_t*)calloc(SPEAKER_MAX_EQ_LENGTH, sizeof(int16_t));
-    if (speaker_eq_coeffs == NULL) {
-        ALOGE("%s: Failed to allocate speaker EQ", __func__);
-        return;
-    }
-    int num_taps = read_filter_from_file(SPEAKER_EQ_FILE, speaker_eq_coeffs, SPEAKER_MAX_EQ_LENGTH);
-    if (num_taps == 0) {
-        ALOGI("%s: Empty filter file or 0 taps set.", __func__);
-        free(speaker_eq_coeffs);
-        return;
-    }
-    out->speaker_eq = fir_init(
-            out->config.channels, FIR_SINGLE_FILTER, num_taps,
-            out_get_buffer_size(&out->stream.common) / out->config.channels / sizeof(int16_t),
-            speaker_eq_coeffs);
-    free(speaker_eq_coeffs);
-}
-
-/* must be called with hw device and output stream mutexes locked */
-static int start_output_stream(struct alsa_stream_out *out)
-{
-    struct alsa_audio_device *adev = out->dev;
-
-    /* default to low power: will be corrected in out_write if necessary before first write to
-     * tinyalsa.
-     */
-    out->write_threshold = PLAYBACK_PERIOD_COUNT * PLAYBACK_PERIOD_SIZE;
-    out->config.start_threshold = PLAYBACK_PERIOD_START_THRESHOLD * PLAYBACK_PERIOD_SIZE;
-    out->config.avail_min = PLAYBACK_PERIOD_SIZE;
-    out->unavailable = true;
-    unsigned int pcm_retry_count = PCM_OPEN_RETRIES;
-    int out_port = get_audio_output_port(out->devices);
-
-    while (1) {
-        out->pcm = pcm_open(CARD_OUT, out_port, PCM_OUT | PCM_MONOTONIC, &out->config);
-        if ((out->pcm != NULL) && pcm_is_ready(out->pcm)) {
-            break;
-        } else {
-            ALOGE("cannot open pcm_out driver: %s", pcm_get_error(out->pcm));
-            if (out->pcm != NULL) {
-                pcm_close(out->pcm);
-                out->pcm = NULL;
-            }
-            if (--pcm_retry_count == 0) {
-                ALOGE("Failed to open pcm_out after %d tries", PCM_OPEN_RETRIES);
-                return -ENODEV;
-            }
-            usleep(PCM_OPEN_WAIT_TIME_MS * 1000);
-        }
-    }
-    out->unavailable = false;
-    adev->active_output = out;
-    return 0;
-}
-
-static uint32_t out_get_sample_rate(const struct audio_stream *stream)
-{
-    struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
-    return out->config.rate;
-}
-
-static int out_set_sample_rate(struct audio_stream *stream, uint32_t rate)
-{
-    ALOGI("CA:: out_set_sample_rate: %d", 0);
-    return -ENOSYS;
-}
-
-static size_t out_get_buffer_size(const struct audio_stream *stream)
-{
-    ALOGI("CA:: out_get_buffer_size: %d", 4096);
-
-    /* return the closest majoring multiple of 16 frames, as
-     * audioflinger expects audio buffers to be a multiple of 16 frames */
-    size_t size = PLAYBACK_PERIOD_SIZE;
-    size = ((size + 15) / 16) * 16;
-    return size * audio_stream_out_frame_size((struct audio_stream_out *)stream);
-}
-
-static audio_channel_mask_t out_get_channels(const struct audio_stream *stream)
-{
-    ALOGI("CA:: out_get_channels");
-    struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
-    return audio_channel_out_mask_from_count(out->config.channels);
-}
-
-static audio_format_t out_get_format(const struct audio_stream *stream)
-{
-    ALOGI("CA:: out_get_format");
-    struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
-    return audio_format_from_pcm_format(out->config.format);
-}
-
-static int out_set_format(struct audio_stream *stream, audio_format_t format)
-{
-    ALOGI("CA:: out_set_format: %d",format);
-    return -ENOSYS;
-}
-
-static int do_output_standby(struct alsa_stream_out *out)
-{
-    struct alsa_audio_device *adev = out->dev;
-
-    fir_reset(out->speaker_eq);
-
-    if (!out->standby) {
-        pcm_close(out->pcm);
-        out->pcm = NULL;
-        adev->active_output = NULL;
-        out->standby = 1;
-    }
-    aec_set_spk_running(adev->aec, false);
-    return 0;
-}
-
-static int out_standby(struct audio_stream *stream)
-{
-    ALOGI("CA:: out_standby");
-    struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
-    int status;
-
-    pthread_mutex_lock(&out->dev->lock);
-    pthread_mutex_lock(&out->lock);
-    status = do_output_standby(out);
-    pthread_mutex_unlock(&out->lock);
-    pthread_mutex_unlock(&out->dev->lock);
-    return status;
-}
-
-static int out_dump(const struct audio_stream *stream, int fd)
-{
-    ALOGI("CA:: out_dump");
-    return 0;
-}
-
-static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
-{
-    ALOGI("CA:: out_set_parameters");
-    struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
-    struct alsa_audio_device *adev = out->dev;
-    struct str_parms *parms;
-    char value[32];
-    int ret, val = 0;
-
-    parms = str_parms_create_str(kvpairs);
-
-    ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING, value, sizeof(value));
-    if (ret >= 0) {
-        val = atoi(value);
-        pthread_mutex_lock(&adev->lock);
-        pthread_mutex_lock(&out->lock);
-        if (((out->devices & AUDIO_DEVICE_OUT_ALL) != val) && (val != 0)) {
-            out->devices &= ~AUDIO_DEVICE_OUT_ALL;
-            out->devices |= val;
-        }
-        pthread_mutex_unlock(&out->lock);
-        pthread_mutex_unlock(&adev->lock);
-    }
-
-    str_parms_destroy(parms);
-    return 0;
-}
-
-static char * out_get_parameters(const struct audio_stream *stream, const char *keys)
-{
-    ALOGI("CA:: out_get_parameters");
-    return strdup("");
-}
-
-static uint32_t out_get_latency(const struct audio_stream_out *stream)
-{
-    ALOGI("CA:: out_get_latency");
-    struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
-    return (PLAYBACK_PERIOD_SIZE * PLAYBACK_PERIOD_COUNT * 1000) / out->config.rate;
-}
-
-static int out_set_volume(struct audio_stream_out *stream, float left,
-        float right)
-{
-    ALOGI("CA:: out_set_volume: Left:%f Right:%f", left, right);
-    return -ENOSYS;
-}
-
-static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
-        size_t bytes)
-{
-    int ret;
-    struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
-    struct alsa_audio_device *adev = out->dev;
-    size_t frame_size = audio_stream_out_frame_size(stream);
-    size_t out_frames = bytes / frame_size;
-    int out_port = get_audio_output_port(out->devices);
-    char* route_active_path_name = get_mixer_path_for_port(out_port);
-
-    if (out_port != adev->active_port) {
-        audio_route_reset(adev->audio_route);
-        ret = audio_route_reset_and_update_path(adev->audio_route, route_active_path_name);
-        adev->active_port = out_port;
-        if (ret < 0) {
-            ALOGE("CA:: %s() failed to set path %s", __func__, route_active_path_name);
-        }
-    }
-
-    ALOGI("CA:: %s: devices: %d, bytes %zu", __func__, out->devices, bytes);
-
-    /* acquiring hw device mutex systematically is useful if a low priority thread is waiting
-     * on the output stream mutex - e.g. executing select_mode() while holding the hw device
-     * mutex
-     */
-    pthread_mutex_lock(&adev->lock);
-    pthread_mutex_lock(&out->lock);
-    if (out->standby) {
-        ret = start_output_stream(out);
-        if (ret != 0) {
-            pthread_mutex_unlock(&adev->lock);
-            goto exit;
-        }
-        out->standby = 0;
-        aec_set_spk_running(adev->aec, true);
-    }
-
-    pthread_mutex_unlock(&adev->lock);
-
-    if (out->speaker_eq != NULL) {
-        fir_process_interleaved(out->speaker_eq, (int16_t*)buffer, (int16_t*)buffer, out_frames);
-    }
-
-    ret = pcm_write(out->pcm, buffer, out_frames * frame_size);
-    if (ret == 0) {
-        out->frames_written += out_frames;
-
-        struct aec_info info;
-        get_pcm_timestamp(out->pcm, out->config.rate, &info, true /*isOutput*/);
-        out->timestamp = info.timestamp;
-        info.bytes = out_frames * frame_size;
-        int aec_ret = write_to_reference_fifo(adev->aec, (void *)buffer, &info);
-        if (aec_ret) {
-            ALOGE("AEC: Write to speaker loopback FIFO failed!");
-        }
-    }
-
-exit:
-    pthread_mutex_unlock(&out->lock);
-
-    if (ret != 0) {
-        usleep((int64_t)bytes * 1000000 / audio_stream_out_frame_size(stream) /
-                out_get_sample_rate(&stream->common));
-    }
-
-    return bytes;
-}
-
-static int out_get_render_position(const struct audio_stream_out *stream,
-        uint32_t *dsp_frames)
-{
-    ALOGI("CA:: out_get_render_position: dsp_frames: %p", dsp_frames);
-    return -ENOSYS;
-}
-
-static int out_get_presentation_position(const struct audio_stream_out *stream,
-                                   uint64_t *frames, struct timespec *timestamp)
-{
-    if (stream == NULL || frames == NULL || timestamp == NULL) {
-        return -EINVAL;
-    }
-    struct alsa_stream_out* out = (struct alsa_stream_out*)stream;
-
-    *frames = out->frames_written;
-    *timestamp = out->timestamp;
-    ALOGI("CA:: %s: frames: %" PRIu64 ", timestamp (nsec): %" PRIu64, __func__, *frames,
-          audio_utils_ns_from_timespec(timestamp));
-
-    return 0;
-}
-
-
-static int out_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
-{
-    ALOGI("CA:: out_add_audio_effect: %p", effect);
-    return 0;
-}
-
-static int out_remove_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
-{
-    ALOGI("CA:: out_remove_audio_effect: %p", effect);
-    return 0;
-}
-
-static int out_get_next_write_timestamp(const struct audio_stream_out *stream,
-        int64_t *timestamp)
-{
-    *timestamp = 0;
-    ALOGI("CA:: out_get_next_write_timestamp: %ld", (long int)(*timestamp));
-    return -ENOSYS;
-}
-
-/** audio_stream_in implementation **/
-
-/* must be called with hw device and input stream mutexes locked */
-static int start_input_stream(struct alsa_stream_in *in)
-{
-    struct alsa_audio_device *adev = in->dev;
-    in->unavailable = true;
-    unsigned int pcm_retry_count = PCM_OPEN_RETRIES;
-
-    while (1) {
-        in->pcm = pcm_open(CARD_IN, PORT_BUILTIN_MIC, PCM_IN | PCM_MONOTONIC, &in->config);
-        if ((in->pcm != NULL) && pcm_is_ready(in->pcm)) {
-            break;
-        } else {
-            ALOGE("cannot open pcm_in driver: %s", pcm_get_error(in->pcm));
-            if (in->pcm != NULL) {
-                pcm_close(in->pcm);
-                in->pcm = NULL;
-            }
-            if (--pcm_retry_count == 0) {
-                ALOGE("Failed to open pcm_in after %d tries", PCM_OPEN_RETRIES);
-                return -ENODEV;
-            }
-            usleep(PCM_OPEN_WAIT_TIME_MS * 1000);
-        }
-    }
-    in->unavailable = false;
-    adev->active_input = in;
-    return 0;
-}
-
-static void get_mic_characteristics(struct audio_microphone_characteristic_t* mic_data,
-                                    size_t* mic_count) {
-    *mic_count = 1;
-    memset(mic_data, 0, sizeof(struct audio_microphone_characteristic_t));
-    strlcpy(mic_data->device_id, "builtin_mic", AUDIO_MICROPHONE_ID_MAX_LEN - 1);
-    strlcpy(mic_data->address, "top", AUDIO_DEVICE_MAX_ADDRESS_LEN - 1);
-    memset(mic_data->channel_mapping, AUDIO_MICROPHONE_CHANNEL_MAPPING_UNUSED,
-           sizeof(mic_data->channel_mapping));
-    mic_data->device = AUDIO_DEVICE_IN_BUILTIN_MIC;
-    mic_data->sensitivity = -37.0;
-    mic_data->max_spl = AUDIO_MICROPHONE_SPL_UNKNOWN;
-    mic_data->min_spl = AUDIO_MICROPHONE_SPL_UNKNOWN;
-    mic_data->orientation.x = 0.0f;
-    mic_data->orientation.y = 0.0f;
-    mic_data->orientation.z = 0.0f;
-    mic_data->geometric_location.x = AUDIO_MICROPHONE_COORDINATE_UNKNOWN;
-    mic_data->geometric_location.y = AUDIO_MICROPHONE_COORDINATE_UNKNOWN;
-    mic_data->geometric_location.z = AUDIO_MICROPHONE_COORDINATE_UNKNOWN;
-}
-
-static uint32_t in_get_sample_rate(const struct audio_stream *stream)
-{
-    struct alsa_stream_in *in = (struct alsa_stream_in *)stream;
-    return in->config.rate;
-}
-
-static int in_set_sample_rate(struct audio_stream *stream, uint32_t rate)
-{
-    ALOGI("CA:: in_set_sample_rate: %d", rate);
-    return -ENOSYS;
-}
-
-static size_t get_input_buffer_size(size_t frames, audio_format_t format,
-                                    audio_channel_mask_t channel_mask) {
-    /* return the closest majoring multiple of 16 frames, as
-     * audioflinger expects audio buffers to be a multiple of 16 frames */
-    frames = ((frames + 15) / 16) * 16;
-    size_t bytes_per_frame = audio_channel_count_from_in_mask(channel_mask) *
-                            audio_bytes_per_sample(format);
-    size_t buffer_size = frames * bytes_per_frame;
-    return buffer_size;
-}
-
-static audio_channel_mask_t in_get_channels(const struct audio_stream *stream)
-{
-    struct alsa_stream_in *in = (struct alsa_stream_in *)stream;
-    ALOGI("CA:: in_get_channels: %d", in->config.channels);
-    return audio_channel_in_mask_from_count(in->config.channels);
-}
-
-static audio_format_t in_get_format(const struct audio_stream *stream)
-{
-    struct alsa_stream_in *in = (struct alsa_stream_in *)stream;
-    ALOGI("CA:: in_get_format: %d", in->config.format);
-    return audio_format_from_pcm_format(in->config.format);
-}
-
-static int in_set_format(struct audio_stream *stream, audio_format_t format)
-{
-    return -ENOSYS;
-}
-
-static size_t in_get_buffer_size(const struct audio_stream *stream)
-{
-    struct alsa_stream_in* in = (struct alsa_stream_in*)stream;
-    size_t frames = CAPTURE_PERIOD_SIZE;
-    if (in->source == AUDIO_SOURCE_ECHO_REFERENCE) {
-        frames = CAPTURE_PERIOD_SIZE * PLAYBACK_CODEC_SAMPLING_RATE / CAPTURE_CODEC_SAMPLING_RATE;
-    }
-
-    size_t buffer_size =
-            get_input_buffer_size(frames, stream->get_format(stream), stream->get_channels(stream));
-    ALOGI("CA:: in_get_buffer_size: %zu", buffer_size);
-    return buffer_size;
-}
-
-static int in_get_active_microphones(const struct audio_stream_in* stream,
-                                     struct audio_microphone_characteristic_t* mic_array,
-                                     size_t* mic_count) {
-    ALOGI("CA:: in_get_active_microphones");
-    if ((mic_array == NULL) || (mic_count == NULL)) {
-        return -EINVAL;
-    }
-    struct alsa_stream_in* in = (struct alsa_stream_in*)stream;
-    struct audio_hw_device* dev = (struct audio_hw_device*)in->dev;
-    bool mic_muted = false;
-    adev_get_mic_mute(dev, &mic_muted);
-    if ((in->source == AUDIO_SOURCE_ECHO_REFERENCE) || mic_muted) {
-        *mic_count = 0;
-        return 0;
-    }
-    adev_get_microphones(dev, mic_array, mic_count);
-    return 0;
-}
-
-static int do_input_standby(struct alsa_stream_in *in)
-{
-    struct alsa_audio_device *adev = in->dev;
-
-    if (!in->standby) {
-        pcm_close(in->pcm);
-        in->pcm = NULL;
-        adev->active_input = NULL;
-        in->standby = true;
-    }
-    return 0;
-}
-
-static int in_standby(struct audio_stream *stream)
-{
-    struct alsa_stream_in *in = (struct alsa_stream_in *)stream;
-    int status;
-
-    pthread_mutex_lock(&in->lock);
-    pthread_mutex_lock(&in->dev->lock);
-    status = do_input_standby(in);
-    pthread_mutex_unlock(&in->dev->lock);
-    pthread_mutex_unlock(&in->lock);
-    return status;
-}
-
-static int in_dump(const struct audio_stream *stream, int fd)
-{
-    struct alsa_stream_in* in = (struct alsa_stream_in*)stream;
-    if (in->source == AUDIO_SOURCE_ECHO_REFERENCE) {
-        return 0;
-    }
-
-    struct audio_microphone_characteristic_t mic_array[AUDIO_MICROPHONE_MAX_COUNT];
-    size_t mic_count;
-
-    get_mic_characteristics(mic_array, &mic_count);
-
-    dprintf(fd, "  Microphone count: %zd\n", mic_count);
-    size_t idx;
-    for (idx = 0; idx < mic_count; idx++) {
-        dprintf(fd, "  Microphone: %zd\n", idx);
-        dprintf(fd, "    Address: %s\n", mic_array[idx].address);
-        dprintf(fd, "    Device: %d\n", mic_array[idx].device);
-        dprintf(fd, "    Sensitivity (dB): %.2f\n", mic_array[idx].sensitivity);
-    }
-
-    return 0;
-}
-
-static int in_set_parameters(struct audio_stream *stream, const char *kvpairs)
-{
-    return 0;
-}
-
-static char * in_get_parameters(const struct audio_stream *stream,
-        const char *keys)
-{
-    return strdup("");
-}
-
-static int in_set_gain(struct audio_stream_in *stream, float gain)
-{
-    return 0;
-}
-
-static ssize_t in_read(struct audio_stream_in *stream, void* buffer,
-        size_t bytes)
-{
-    int ret;
-    struct alsa_stream_in *in = (struct alsa_stream_in *)stream;
-    struct alsa_audio_device *adev = in->dev;
-    size_t frame_size = audio_stream_in_frame_size(stream);
-    size_t in_frames = bytes / frame_size;
-
-    ALOGI("CA:: in_read: stream: %d, bytes %zu", in->source, bytes);
-
-    /* Special handling for Echo Reference: simply get the reference from FIFO.
-     * The format and sample rate should be specified by arguments to adev_open_input_stream. */
-    if (in->source == AUDIO_SOURCE_ECHO_REFERENCE) {
-        struct aec_info info;
-        info.bytes = bytes;
-
-        const uint64_t time_increment_nsec = (uint64_t)bytes * NANOS_PER_SECOND /
-                                             audio_stream_in_frame_size(stream) /
-                                             in_get_sample_rate(&stream->common);
-        if (!aec_get_spk_running(adev->aec)) {
-            if (in->timestamp_nsec == 0) {
-                struct timespec now;
-                clock_gettime(CLOCK_MONOTONIC, &now);
-                const uint64_t timestamp_nsec = audio_utils_ns_from_timespec(&now);
-                in->timestamp_nsec = timestamp_nsec;
-            } else {
-                in->timestamp_nsec += time_increment_nsec;
-            }
-            memset(buffer, 0, bytes);
-            const uint64_t time_increment_usec = time_increment_nsec / 1000;
-            usleep(time_increment_usec);
-        } else {
-            int ref_ret = get_reference_samples(adev->aec, buffer, &info);
-            if ((ref_ret) || (info.timestamp_usec == 0)) {
-                memset(buffer, 0, bytes);
-                in->timestamp_nsec += time_increment_nsec;
-            } else {
-                in->timestamp_nsec = 1000 * info.timestamp_usec;
-            }
-        }
-        in->frames_read += in_frames;
-
-#if DEBUG_AEC
-        FILE* fp_ref = fopen("/data/local/traces/aec_ref.pcm", "a+");
-        if (fp_ref) {
-            fwrite((char*)buffer, 1, bytes, fp_ref);
-            fclose(fp_ref);
-        } else {
-            ALOGE("AEC debug: Could not open file aec_ref.pcm!");
-        }
-        FILE* fp_ref_ts = fopen("/data/local/traces/aec_ref_timestamps.txt", "a+");
-        if (fp_ref_ts) {
-            fprintf(fp_ref_ts, "%" PRIu64 "\n", in->timestamp_nsec);
-            fclose(fp_ref_ts);
-        } else {
-            ALOGE("AEC debug: Could not open file aec_ref_timestamps.txt!");
-        }
-#endif
-        return info.bytes;
-    }
-
-    /* Microphone input stream read */
-
-    /* acquiring hw device mutex systematically is useful if a low priority thread is waiting
-     * on the input stream mutex - e.g. executing select_mode() while holding the hw device
-     * mutex
-     */
-    pthread_mutex_lock(&in->lock);
-    pthread_mutex_lock(&adev->lock);
-    if (in->standby) {
-        ret = start_input_stream(in);
-        if (ret != 0) {
-            pthread_mutex_unlock(&adev->lock);
-            ALOGE("start_input_stream failed with code %d", ret);
-            goto exit;
-        }
-        in->standby = false;
-    }
-
-    pthread_mutex_unlock(&adev->lock);
-
-    ret = pcm_read(in->pcm, buffer, in_frames * frame_size);
-    struct aec_info info;
-    get_pcm_timestamp(in->pcm, in->config.rate, &info, false /*isOutput*/);
-    if (ret == 0) {
-        in->frames_read += in_frames;
-        in->timestamp_nsec = audio_utils_ns_from_timespec(&info.timestamp);
-    }
-    else {
-        ALOGE("pcm_read failed with code %d", ret);
-    }
-
-exit:
-    pthread_mutex_unlock(&in->lock);
-
-    bool mic_muted = false;
-    adev_get_mic_mute((struct audio_hw_device*)adev, &mic_muted);
-    if (mic_muted) {
-        memset(buffer, 0, bytes);
-    }
-
-    if (ret != 0) {
-        usleep((int64_t)bytes * 1000000 / audio_stream_in_frame_size(stream) /
-                in_get_sample_rate(&stream->common));
-    } else {
-        /* Process AEC if available */
-        /* TODO move to a separate thread */
-        if (!mic_muted) {
-            info.bytes = bytes;
-            int aec_ret = process_aec(adev->aec, buffer, &info);
-            if (aec_ret) {
-                ALOGE("process_aec returned error code %d", aec_ret);
-            }
-        }
-    }
-
-#if DEBUG_AEC && !defined(AEC_HAL)
-    FILE* fp_in = fopen("/data/local/traces/aec_in.pcm", "a+");
-    if (fp_in) {
-        fwrite((char*)buffer, 1, bytes, fp_in);
-        fclose(fp_in);
-    } else {
-        ALOGE("AEC debug: Could not open file aec_in.pcm!");
-    }
-    FILE* fp_mic_ts = fopen("/data/local/traces/aec_in_timestamps.txt", "a+");
-    if (fp_mic_ts) {
-        fprintf(fp_mic_ts, "%" PRIu64 "\n", in->timestamp_nsec);
-        fclose(fp_mic_ts);
-    } else {
-        ALOGE("AEC debug: Could not open file aec_in_timestamps.txt!");
-    }
-#endif
-
-    return bytes;
-}
-
-static int in_get_capture_position(const struct audio_stream_in* stream, int64_t* frames,
-                                   int64_t* time) {
-    if (stream == NULL || frames == NULL || time == NULL) {
-        return -EINVAL;
-    }
-    struct alsa_stream_in* in = (struct alsa_stream_in*)stream;
-
-    *frames = in->frames_read;
-    *time = in->timestamp_nsec;
-    ALOGI("CA:: %s: source: %d, timestamp (nsec): %" PRIu64, __func__, in->source, *time);
-
-    return 0;
-}
-
-static uint32_t in_get_input_frames_lost(struct audio_stream_in *stream)
-{
-    return 0;
-}
-
-static int in_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
-{
-    return 0;
-}
-
-static int in_remove_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
-{
-    return 0;
-}
-
-static int adev_open_output_stream(struct audio_hw_device *dev,
-        audio_io_handle_t handle,
-        audio_devices_t devices,
-        audio_output_flags_t flags,
-        struct audio_config *config,
-        struct audio_stream_out **stream_out,
-        const char *address __unused)
-{
-    ALOGI("CA:: adev_open_output_stream...");
-    
-    struct alsa_audio_device *ladev = (struct alsa_audio_device *)dev;
-    int out_port = get_audio_output_port(devices);
-    char* route_active_path_name = get_mixer_path_for_port(out_port);
-    struct pcm_params* params = pcm_params_get(CARD_OUT, out_port, PCM_OUT);
-    if (!params) {
-        return -ENOSYS;
-    }
-
-    if (audio_route_apply_and_update_path(ladev->audio_route, route_active_path_name) < 0) {
-        ALOGE("CA:: %s() Failed to apply path %s", __func__, route_active_path_name);
-    }
-    ladev->active_port = out_port;
-
-    struct alsa_stream_out* out =
-            (struct alsa_stream_out*)calloc(1, sizeof(struct alsa_stream_out));
-    if (!out) {
-        return -ENOMEM;
-    }
-
-    out->stream.common.get_sample_rate = out_get_sample_rate;
-    out->stream.common.set_sample_rate = out_set_sample_rate;
-    out->stream.common.get_buffer_size = out_get_buffer_size;
-    out->stream.common.get_channels = out_get_channels;
-    out->stream.common.get_format = out_get_format;
-    out->stream.common.set_format = out_set_format;
-    out->stream.common.standby = out_standby;
-    out->stream.common.dump = out_dump;
-    out->stream.common.set_parameters = out_set_parameters;
-    out->stream.common.get_parameters = out_get_parameters;
-    out->stream.common.add_audio_effect = out_add_audio_effect;
-    out->stream.common.remove_audio_effect = out_remove_audio_effect;
-    out->stream.get_latency = out_get_latency;
-    out->stream.set_volume = out_set_volume;
-    out->stream.write = out_write;
-    out->stream.get_render_position = out_get_render_position;
-    out->stream.get_next_write_timestamp = out_get_next_write_timestamp;
-    out->stream.get_presentation_position = out_get_presentation_position;
-
-    out->config.channels = CHANNEL_STEREO;
-    out->config.rate = PLAYBACK_CODEC_SAMPLING_RATE;
-    out->config.format = PCM_FORMAT_S16_LE;
-    out->config.period_size = PLAYBACK_PERIOD_SIZE;
-    out->config.period_count = PLAYBACK_PERIOD_COUNT;
-
-    if (out->config.rate != config->sample_rate ||
-           audio_channel_count_from_out_mask(config->channel_mask) != CHANNEL_STEREO ||
-               out->config.format !=  pcm_format_from_audio_format(config->format) ) {
-        config->sample_rate = out->config.rate;
-        config->format = audio_format_from_pcm_format(out->config.format);
-        config->channel_mask = audio_channel_out_mask_from_count(CHANNEL_STEREO);
-        goto error_1;
-    }
-
-    ALOGI("adev_open_output_stream selects channels=%d rate=%d format=%d, devices=%d",
-          out->config.channels, out->config.rate, out->config.format, devices);
-
-    out->dev = ladev;
-    out->standby = 1;
-    out->unavailable = false;
-    out->devices = devices;
-
-    config->format = out_get_format(&out->stream.common);
-    config->channel_mask = out_get_channels(&out->stream.common);
-    config->sample_rate = out_get_sample_rate(&out->stream.common);
-
-    out->speaker_eq = NULL;
-    if (out_port == PORT_INTERNAL_SPEAKER) {
-        out_set_eq(out);
-        if (out->speaker_eq == NULL) {
-            ALOGE("%s: Failed to initialize speaker EQ", __func__);
-        }
-    }
-
-    int aec_ret = init_aec_reference_config(ladev->aec, out);
-    if (aec_ret) {
-        ALOGE("AEC: Speaker config init failed!");
-        goto error_2;
-    }
-
-    *stream_out = &out->stream;
-    return 0;
-
-error_2:
-    fir_release(out->speaker_eq);
-error_1:
-    free(out);
-    return -EINVAL;
-}
-
-static void adev_close_output_stream(struct audio_hw_device *dev,
-        struct audio_stream_out *stream)
-{
-    ALOGI("CA:: adev_close_output_stream...");
-    struct alsa_audio_device *adev = (struct alsa_audio_device *)dev;
-    destroy_aec_reference_config(adev->aec);
-    struct alsa_stream_out* out = (struct alsa_stream_out*)stream;
-    fir_release(out->speaker_eq);
-    free(stream);
-}
-
-static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
-{
-    ALOGI("CA:: adev_set_parameters: %s", kvpairs);
-    return -ENOSYS;
-}
-
-static char * adev_get_parameters(const struct audio_hw_device *dev,
-        const char *keys)
-{
-    ALOGI("CA:: adev_get_parameters");
-    return strdup("");
-}
-
-static int adev_get_microphones(const struct audio_hw_device* dev,
-                                struct audio_microphone_characteristic_t* mic_array,
-                                size_t* mic_count) {
-    ALOGI("CA:: adev_get_microphones");
-    if ((mic_array == NULL) || (mic_count == NULL)) {
-        return -EINVAL;
-    }
-    get_mic_characteristics(mic_array, mic_count);
-    return 0;
-}
-
-static int adev_init_check(const struct audio_hw_device *dev)
-{
-    ALOGI("CA:: adev_init_check");
-    return 0;
-}
-
-static int adev_set_voice_volume(struct audio_hw_device *dev, float volume)
-{
-    ALOGI("CA:: adev_set_voice_volume: %f", volume);
-    return -ENOSYS;
-}
-
-static int adev_set_master_volume(struct audio_hw_device *dev, float volume)
-{
-    ALOGI("CA:: adev_set_master_volume: %f", volume);
-    return -ENOSYS;
-}
-
-static int adev_get_master_volume(struct audio_hw_device *dev, float *volume)
-{
-    ALOGI("CA:: adev_get_master_volume: %f", *volume);
-    return -ENOSYS;
-}
-
-static int adev_set_master_mute(struct audio_hw_device *dev, bool muted)
-{
-    ALOGI("CA:: adev_set_master_mute: %d", muted);
-    return -ENOSYS;
-}
-
-static int adev_get_master_mute(struct audio_hw_device *dev, bool *muted)
-{
-    ALOGI("CA:: adev_get_master_mute: %d", *muted);
-    return -ENOSYS;
-}
-
-static int adev_set_mode(struct audio_hw_device *dev, audio_mode_t mode)
-{
-    ALOGI("CA:: adev_set_mode: %d", mode);
-    return 0;
-}
-
-static int adev_set_mic_mute(struct audio_hw_device *dev, bool state)
-{
-    ALOGI("CA:: adev_set_mic_mute: %d",state);
-    struct alsa_audio_device *adev = (struct alsa_audio_device *)dev;
-    pthread_mutex_lock(&adev->lock);
-    adev->mic_mute = state;
-    pthread_mutex_unlock(&adev->lock);
-    return 0;
-}
-
-static int adev_get_mic_mute(const struct audio_hw_device *dev, bool *state)
-{
-    ALOGI("CA:: adev_get_mic_mute");
-    struct alsa_audio_device *adev = (struct alsa_audio_device *)dev;
-    pthread_mutex_lock(&adev->lock);
-    *state = adev->mic_mute;
-    pthread_mutex_unlock(&adev->lock);
-    return 0;
-}
-
-static size_t adev_get_input_buffer_size(const struct audio_hw_device *dev,
-        const struct audio_config *config)
-{
-    size_t buffer_size =
-            get_input_buffer_size(CAPTURE_PERIOD_SIZE, config->format, config->channel_mask);
-    ALOGI("CA:: adev_get_input_buffer_size: %zu", buffer_size);
-    return buffer_size;
-}
-
-static int adev_open_input_stream(struct audio_hw_device* dev, audio_io_handle_t handle,
-                                  audio_devices_t devices, struct audio_config* config,
-                                  struct audio_stream_in** stream_in,
-                                  audio_input_flags_t flags __unused, const char* address __unused,
-                                  audio_source_t source) {
-    ALOGI("CA:: adev_open_input_stream...");
-
-    struct alsa_audio_device *ladev = (struct alsa_audio_device *)dev;
-
-    struct pcm_params* params = pcm_params_get(CARD_IN, PORT_BUILTIN_MIC, PCM_IN);
-    if (!params) {
-        return -ENOSYS;
-    }
-
-    struct alsa_stream_in* in = (struct alsa_stream_in*)calloc(1, sizeof(struct alsa_stream_in));
-    if (!in) {
-        return -ENOMEM;
-    }
-
-    in->stream.common.get_sample_rate = in_get_sample_rate;
-    in->stream.common.set_sample_rate = in_set_sample_rate;
-    in->stream.common.get_buffer_size = in_get_buffer_size;
-    in->stream.common.get_channels = in_get_channels;
-    in->stream.common.get_format = in_get_format;
-    in->stream.common.set_format = in_set_format;
-    in->stream.common.standby = in_standby;
-    in->stream.common.dump = in_dump;
-    in->stream.common.set_parameters = in_set_parameters;
-    in->stream.common.get_parameters = in_get_parameters;
-    in->stream.common.add_audio_effect = in_add_audio_effect;
-    in->stream.common.remove_audio_effect = in_remove_audio_effect;
-    in->stream.set_gain = in_set_gain;
-    in->stream.read = in_read;
-    in->stream.get_input_frames_lost = in_get_input_frames_lost;
-    in->stream.get_capture_position = in_get_capture_position;
-    in->stream.get_active_microphones = in_get_active_microphones;
-
-    in->config.channels = CHANNEL_STEREO;
-    if (source == AUDIO_SOURCE_ECHO_REFERENCE) {
-        in->config.rate = PLAYBACK_CODEC_SAMPLING_RATE;
-    } else {
-        in->config.rate = CAPTURE_CODEC_SAMPLING_RATE;
-    }
-    in->config.format = PCM_FORMAT_S32_LE;
-    in->config.period_size = CAPTURE_PERIOD_SIZE;
-    in->config.period_count = CAPTURE_PERIOD_COUNT;
-
-    if (in->config.rate != config->sample_rate ||
-           audio_channel_count_from_in_mask(config->channel_mask) != CHANNEL_STEREO ||
-               in->config.format !=  pcm_format_from_audio_format(config->format) ) {
-        config->format = in_get_format(&in->stream.common);
-        config->channel_mask = in_get_channels(&in->stream.common);
-        config->sample_rate = in_get_sample_rate(&in->stream.common);
-        goto error_1;
-    }
-
-    ALOGI("adev_open_input_stream selects channels=%d rate=%d format=%d source=%d",
-          in->config.channels, in->config.rate, in->config.format, source);
-
-    in->dev = ladev;
-    in->standby = true;
-    in->unavailable = false;
-    in->source = source;
-    in->devices = devices;
-
-    if (is_aec_input(in)) {
-        int aec_ret = init_aec_mic_config(ladev->aec, in);
-        if (aec_ret) {
-            ALOGE("AEC: Mic config init failed!");
-            goto error_1;
-        }
-    }
-
-#if DEBUG_AEC
-    remove("/data/local/traces/aec_ref.pcm");
-    remove("/data/local/traces/aec_in.pcm");
-    remove("/data/local/traces/aec_ref_timestamps.txt");
-    remove("/data/local/traces/aec_in_timestamps.txt");
-#endif
-
-    *stream_in = &in->stream;
-    return 0;
-
-error_1:
-    free(in);
-    return -EINVAL;
-}
-
-static void adev_close_input_stream(struct audio_hw_device *dev,
-        struct audio_stream_in *stream)
-{
-    ALOGI("CA:: adev_close_input_stream...");
-    struct alsa_stream_in* in = (struct alsa_stream_in*)stream;
-    if (is_aec_input(in)) {
-        destroy_aec_mic_config(in->dev->aec);
-    }
-    free(stream);
-    return;
-}
-
-static int adev_dump(const audio_hw_device_t *device, int fd)
-{
-    ALOGI("CA:: adev_dump");
-    return 0;
-}
-
-static int adev_close(hw_device_t *device)
-{
-    ALOGI("CA:: adev_close");
-
-    struct alsa_audio_device *adev = (struct alsa_audio_device *)device;
-    release_aec(adev->aec);
-    audio_route_free(adev->audio_route);
-    mixer_close(adev->mixer);
-    free(device);
-    return 0;
-}
-
-static int adev_open(const hw_module_t* module, const char* name,
-        hw_device_t** device)
-{
-    ALOGI("CA:: adev_open: %s", name);
-
-    if (strcmp(name, AUDIO_HARDWARE_INTERFACE) != 0) {
-        return -EINVAL;
-    }
-
-    struct alsa_audio_device* adev = calloc(1, sizeof(struct alsa_audio_device));
-    if (!adev) {
-        return -ENOMEM;
-    }
-
-    adev->hw_device.common.tag = HARDWARE_DEVICE_TAG;
-    adev->hw_device.common.version = AUDIO_DEVICE_API_VERSION_2_0;
-    adev->hw_device.common.module = (struct hw_module_t *) module;
-    adev->hw_device.common.close = adev_close;
-    adev->hw_device.init_check = adev_init_check;
-    adev->hw_device.set_voice_volume = adev_set_voice_volume;
-    adev->hw_device.set_master_volume = adev_set_master_volume;
-    adev->hw_device.get_master_volume = adev_get_master_volume;
-    adev->hw_device.set_master_mute = adev_set_master_mute;
-    adev->hw_device.get_master_mute = adev_get_master_mute;
-    adev->hw_device.set_mode = adev_set_mode;
-    adev->hw_device.set_mic_mute = adev_set_mic_mute;
-    adev->hw_device.get_mic_mute = adev_get_mic_mute;
-    adev->hw_device.set_parameters = adev_set_parameters;
-    adev->hw_device.get_parameters = adev_get_parameters;
-    adev->hw_device.get_input_buffer_size = adev_get_input_buffer_size;
-    adev->hw_device.open_output_stream = adev_open_output_stream;
-    adev->hw_device.close_output_stream = adev_close_output_stream;
-    adev->hw_device.open_input_stream = adev_open_input_stream;
-    adev->hw_device.close_input_stream = adev_close_input_stream;
-    adev->hw_device.dump = adev_dump;
-    adev->hw_device.get_microphones = adev_get_microphones;
-
-    *device = &adev->hw_device.common;
-
-    adev->mixer = mixer_open(CARD_OUT);
-    if (!adev->mixer) {
-        ALOGE("Unable to open the mixer, aborting.");
-        goto error_1;
-    }
-
-    adev->audio_route = audio_route_init(CARD_OUT, MIXER_XML_PATH);
-    if (!adev->audio_route) {
-        ALOGE("%s: Failed to init audio route controls, aborting.", __func__);
-        goto error_2;
-    }
-
-    pthread_mutex_lock(&adev->lock);
-    if (init_aec(CAPTURE_CODEC_SAMPLING_RATE, NUM_AEC_REFERENCE_CHANNELS,
-                    CHANNEL_STEREO, &adev->aec)) {
-        pthread_mutex_unlock(&adev->lock);
-        goto error_3;
-    }
-    pthread_mutex_unlock(&adev->lock);
-
-    return 0;
-
-error_3:
-    audio_route_free(adev->audio_route);
-error_2:
-    mixer_close(adev->mixer);
-error_1:
-    free(adev);
-    return -EINVAL;
-}
-
-static struct hw_module_methods_t hal_module_methods = {
-    .open = adev_open,
-};
-
-struct audio_module HAL_MODULE_INFO_SYM = {
-    .common = {
-        .tag = HARDWARE_MODULE_TAG,
-        .module_api_version = AUDIO_MODULE_API_VERSION_0_1,
-        .hal_api_version = HARDWARE_HAL_API_VERSION,
-        .id = AUDIO_HARDWARE_MODULE_ID,
-        .name = "Generic audio HW HAL",
-        .author = "The Android Open Source Project",
-        .methods = &hal_module_methods,
-    },
-};
diff --git a/audio/audio_hw.h b/audio/audio_hw.h
deleted file mode 100644
index ce7e3c7..0000000
--- a/audio/audio_hw.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2019 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 _YUKAWA_AUDIO_HW_H_
-#define _YUKAWA_AUDIO_HW_H_
-
-#include <hardware/audio.h>
-#include <tinyalsa/asoundlib.h>
-
-#include "fir_filter.h"
-
-#define CARD_OUT 0
-#define PORT_INTERNAL_SPEAKER 0
-#define PORT_HEADSET 1
-#define CARD_IN 0
-#define PORT_BUILTIN_MIC 3
-
-#define MIXER_XML_PATH "/vendor/etc/mixer_paths.xml"
-/* Minimum granularity - Arbitrary but small value */
-#define CODEC_BASE_FRAME_COUNT 32
-
-#define CHANNEL_STEREO 2
-
-#ifdef AEC_HAL
-#define NUM_AEC_REFERENCE_CHANNELS 1
-#else
-/* App AEC uses 2-channel reference */
-#define NUM_AEC_REFERENCE_CHANNELS 2
-#endif /* #ifdef AEC_HAL */
-
-#define DEBUG_AEC 0
-
-#define PCM_OPEN_RETRIES 100
-#define PCM_OPEN_WAIT_TIME_MS 20
-
-/* Capture codec parameters */
-/* Set up a capture period of 32 ms:
- * CAPTURE_PERIOD = PERIOD_SIZE / SAMPLE_RATE, so (32e-3) = PERIOD_SIZE / (16e3)
- * => PERIOD_SIZE = 512 frames, where each "frame" consists of 1 sample of every channel (here, 2ch) */
-#define CAPTURE_PERIOD_MULTIPLIER 16
-#define CAPTURE_PERIOD_SIZE (CODEC_BASE_FRAME_COUNT * CAPTURE_PERIOD_MULTIPLIER)
-#define CAPTURE_PERIOD_COUNT 4
-#define CAPTURE_PERIOD_START_THRESHOLD 0
-#define CAPTURE_CODEC_SAMPLING_RATE 16000
-
-/* Playback codec parameters */
-/* number of base blocks in a short period (low latency) */
-#define PLAYBACK_PERIOD_MULTIPLIER 32  /* 21 ms */
-/* number of frames per short period (low latency) */
-#define PLAYBACK_PERIOD_SIZE (CODEC_BASE_FRAME_COUNT * PLAYBACK_PERIOD_MULTIPLIER)
-/* number of pseudo periods for low latency playback */
-#define PLAYBACK_PERIOD_COUNT 4
-#define PLAYBACK_PERIOD_START_THRESHOLD 2
-#define PLAYBACK_CODEC_SAMPLING_RATE 48000
-#define MIN_WRITE_SLEEP_US      5000
-
-#define SPEAKER_EQ_FILE "/vendor/etc/speaker_eq_sei610.fir"
-#define SPEAKER_MAX_EQ_LENGTH 512
-
-struct alsa_audio_device {
-    struct audio_hw_device hw_device;
-
-    pthread_mutex_t lock;   /* see notes in in_read/out_write on mutex acquisition order */
-    struct alsa_stream_in *active_input;
-    struct alsa_stream_out *active_output;
-    struct audio_route *audio_route;
-    struct mixer *mixer;
-    bool mic_mute;
-    struct aec_t *aec;
-    int active_port;
-};
-
-struct alsa_stream_in {
-    struct audio_stream_in stream;
-
-    pthread_mutex_t lock;   /* see note in in_read() on mutex acquisition order */
-    audio_devices_t devices;
-    struct pcm_config config;
-    struct pcm *pcm;
-    bool unavailable;
-    bool standby;
-    struct alsa_audio_device *dev;
-    int read_threshold;
-    unsigned int frames_read;
-    uint64_t timestamp_nsec;
-    audio_source_t source;
-};
-
-struct alsa_stream_out {
-    struct audio_stream_out stream;
-
-    pthread_mutex_t lock;   /* see note in out_write() on mutex acquisition order */
-    audio_devices_t devices;
-    struct pcm_config config;
-    struct pcm *pcm;
-    bool unavailable;
-    int standby;
-    struct alsa_audio_device *dev;
-    int write_threshold;
-    unsigned int frames_written;
-    struct timespec timestamp;
-    fir_filter_t* speaker_eq;
-};
-
-/* 'bytes' are the number of bytes written to audio FIFO, for which 'timestamp' is valid.
- * 'available' is the number of frames available to read (for input) or yet to be played
- * (for output) frames in the PCM buffer.
- * timestamp and available are updated by pcm_get_htimestamp(), so they use the same
- * datatypes as the corresponding arguments to that function. */
-struct aec_info {
-    struct timespec timestamp;
-    uint64_t timestamp_usec;
-    unsigned int available;
-    size_t bytes;
-};
-
-#endif /* #ifndef _YUKAWA_AUDIO_HW_H_ */
diff --git a/audio/fifo_wrapper.cpp b/audio/fifo_wrapper.cpp
deleted file mode 100644
index 7bc9079..0000000
--- a/audio/fifo_wrapper.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2019 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 "audio_utils_fifo_wrapper"
-// #define LOG_NDEBUG 0
-
-#include <stdint.h>
-#include <errno.h>
-#include <log/log.h>
-#include <audio_utils/fifo.h>
-#include "fifo_wrapper.h"
-
-struct audio_fifo_itfe {
-    audio_utils_fifo *p_fifo;
-    audio_utils_fifo_reader *p_fifo_reader;
-    audio_utils_fifo_writer *p_fifo_writer;
-    int8_t *p_buffer;
-};
-
-void *fifo_init(uint32_t bytes, bool reader_throttles_writer) {
-    struct audio_fifo_itfe *interface = new struct audio_fifo_itfe;
-    interface->p_buffer = new int8_t[bytes];
-    if (interface->p_buffer == NULL) {
-        ALOGE("Failed to allocate fifo buffer!");
-        return NULL;
-    }
-    interface->p_fifo = new audio_utils_fifo(bytes, 1, interface->p_buffer, reader_throttles_writer);
-    interface->p_fifo_writer = new audio_utils_fifo_writer(*interface->p_fifo);
-    interface->p_fifo_reader = new audio_utils_fifo_reader(*interface->p_fifo);
-
-    return (void *)interface;
-}
-
-void fifo_release(void *fifo_itfe) {
-    struct audio_fifo_itfe *interface = static_cast<struct audio_fifo_itfe *>(fifo_itfe);
-    delete interface->p_fifo_writer;
-    delete interface->p_fifo_reader;
-    delete interface->p_fifo;
-    delete[] interface->p_buffer;
-    delete interface;
-}
-
-ssize_t fifo_read(void *fifo_itfe, void *buffer, size_t bytes) {
-    struct audio_fifo_itfe *interface = static_cast<struct audio_fifo_itfe *>(fifo_itfe);
-    return interface->p_fifo_reader->read(buffer, bytes);
-}
-
-ssize_t fifo_write(void *fifo_itfe, void *buffer, size_t bytes) {
-    struct audio_fifo_itfe *interface = static_cast<struct audio_fifo_itfe *>(fifo_itfe);
-    return interface->p_fifo_writer->write(buffer, bytes);
-}
-
-ssize_t fifo_available_to_read(void *fifo_itfe) {
-    struct audio_fifo_itfe *interface = static_cast<struct audio_fifo_itfe *>(fifo_itfe);
-    return interface->p_fifo_reader->available();
-}
-
-ssize_t fifo_available_to_write(void *fifo_itfe) {
-    struct audio_fifo_itfe *interface = static_cast<struct audio_fifo_itfe *>(fifo_itfe);
-    return interface->p_fifo_writer->available();
-}
-
-ssize_t fifo_flush(void *fifo_itfe) {
-    struct audio_fifo_itfe *interface = static_cast<struct audio_fifo_itfe *>(fifo_itfe);
-    return interface->p_fifo_reader->flush();
-}
diff --git a/audio/fifo_wrapper.h b/audio/fifo_wrapper.h
deleted file mode 100644
index e9469ef..0000000
--- a/audio/fifo_wrapper.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2019 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 _AUDIO_FIFO_WRAPPER_H_
-#define _AUDIO_FIFO_WRAPPER_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void *fifo_init(uint32_t bytes, bool reader_throttles_writer);
-void fifo_release(void *fifo_itfe);
-ssize_t fifo_read(void *fifo_itfe, void *buffer, size_t bytes);
-ssize_t fifo_write(void *fifo_itfe, void *buffer, size_t bytes);
-ssize_t fifo_available_to_read(void *fifo_itfe);
-ssize_t fifo_available_to_write(void *fifo_itfe);
-ssize_t fifo_flush(void *fifo_itfe);
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* #ifndef _AUDIO_FIFO_WRAPPER_H_ */
diff --git a/audio/fir_filter.c b/audio/fir_filter.c
deleted file mode 100644
index c648fc0..0000000
--- a/audio/fir_filter.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (C) 2020 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 "audio_hw_fir_filter"
-//#define LOG_NDEBUG 0
-
-#include <assert.h>
-#include <audio_utils/primitives.h>
-#include <errno.h>
-#include <inttypes.h>
-#include <log/log.h>
-#include <malloc.h>
-#include <string.h>
-
-#include "fir_filter.h"
-
-#ifdef __ARM_NEON
-#include "arm_neon.h"
-#endif /* #ifdef __ARM_NEON */
-
-fir_filter_t* fir_init(uint32_t channels, fir_filter_mode_t mode, uint32_t filter_length,
-                       uint32_t input_length, int16_t* coeffs) {
-    if ((channels == 0) || (filter_length == 0) || (coeffs == NULL)) {
-        ALOGE("%s: Invalid channel count, filter length or coefficient array.", __func__);
-        return NULL;
-    }
-
-    fir_filter_t* fir = (fir_filter_t*)calloc(1, sizeof(fir_filter_t));
-    if (fir == NULL) {
-        ALOGE("%s: Unable to allocate memory for fir_filter.", __func__);
-        return NULL;
-    }
-
-    fir->channels = channels;
-    fir->filter_length = filter_length;
-    /* Default: same filter coeffs for all channels */
-    fir->mode = FIR_SINGLE_FILTER;
-    uint32_t coeff_bytes = fir->filter_length * sizeof(int16_t);
-    if (mode == FIR_PER_CHANNEL_FILTER) {
-        fir->mode = FIR_PER_CHANNEL_FILTER;
-        coeff_bytes = fir->filter_length * fir->channels * sizeof(int16_t);
-    }
-
-    fir->coeffs = (int16_t*)malloc(coeff_bytes);
-    if (fir->coeffs == NULL) {
-        ALOGE("%s: Unable to allocate memory for FIR coeffs", __func__);
-        goto exit_1;
-    }
-    memcpy(fir->coeffs, coeffs, coeff_bytes);
-
-    fir->buffer_size = (input_length + fir->filter_length) * fir->channels;
-    fir->state = (int16_t*)malloc(fir->buffer_size * sizeof(int16_t));
-    if (fir->state == NULL) {
-        ALOGE("%s: Unable to allocate memory for FIR state", __func__);
-        goto exit_2;
-    }
-
-#ifdef __ARM_NEON
-    ALOGI("%s: Using ARM Neon", __func__);
-#endif /* #ifdef __ARM_NEON */
-
-    fir_reset(fir);
-    return fir;
-
-exit_2:
-    free(fir->coeffs);
-exit_1:
-    free(fir);
-    return NULL;
-}
-
-void fir_release(fir_filter_t* fir) {
-    if (fir == NULL) {
-        return;
-    }
-    free(fir->state);
-    free(fir->coeffs);
-    free(fir);
-}
-
-void fir_reset(fir_filter_t* fir) {
-    if (fir == NULL) {
-        return;
-    }
-    memset(fir->state, 0, fir->buffer_size * sizeof(int16_t));
-}
-
-void fir_process_interleaved(fir_filter_t* fir, int16_t* input, int16_t* output, uint32_t samples) {
-    assert(fir != NULL);
-
-    int start_offset = (fir->filter_length - 1) * fir->channels;
-    memcpy(&fir->state[start_offset], input, samples * fir->channels * sizeof(int16_t));
-    // int ch;
-    bool use_2nd_set_coeffs = (fir->channels > 1) && (fir->mode == FIR_PER_CHANNEL_FILTER);
-    int16_t* p_coeff_A = &fir->coeffs[0];
-    int16_t* p_coeff_B = use_2nd_set_coeffs ? &fir->coeffs[fir->filter_length] : &fir->coeffs[0];
-    int16_t* p_output;
-    for (int ch = 0; ch < fir->channels; ch += 2) {
-        p_output = &output[ch];
-        int offset = start_offset + ch;
-        for (int s = 0; s < samples; s++) {
-            int32_t acc_A = 0;
-            int32_t acc_B = 0;
-
-#ifdef __ARM_NEON
-            int32x4_t acc_vec = vdupq_n_s32(0);
-            for (int k = 0; k < fir->filter_length; k++, offset -= fir->channels) {
-                int16x4_t coeff_vec = vdup_n_s16(p_coeff_A[k]);
-                coeff_vec = vset_lane_s16(p_coeff_B[k], coeff_vec, 1);
-                int16x4_t input_vec = vld1_s16(&fir->state[offset]);
-                acc_vec = vmlal_s16(acc_vec, coeff_vec, input_vec);
-            }
-            acc_A = vgetq_lane_s32(acc_vec, 0);
-            acc_B = vgetq_lane_s32(acc_vec, 1);
-#else
-            for (int k = 0; k < fir->filter_length; k++, offset -= fir->channels) {
-                int32_t input_A = (int32_t)(fir->state[offset]);
-                int32_t coeff_A = (int32_t)(p_coeff_A[k]);
-                int32_t input_B = (int32_t)(fir->state[offset + 1]);
-                int32_t coeff_B = (int32_t)(p_coeff_B[k]);
-                acc_A += (input_A * coeff_A);
-                acc_B += (input_B * coeff_B);
-            }
-#endif /* #ifdef __ARM_NEON */
-
-            *p_output = clamp16(acc_A >> 15);
-            if (ch < fir->channels - 1) {
-                *(p_output + 1) = clamp16(acc_B >> 15);
-            }
-            /* Move to next sample */
-            p_output += fir->channels;
-            offset += (fir->filter_length + 1) * fir->channels;
-        }
-        if (use_2nd_set_coeffs) {
-            p_coeff_A += (fir->filter_length << 1);
-            p_coeff_B += (fir->filter_length << 1);
-        }
-    }
-    memmove(fir->state, &fir->state[samples * fir->channels],
-            (fir->filter_length - 1) * fir->channels * sizeof(int16_t));
-}
diff --git a/audio/fir_filter.h b/audio/fir_filter.h
deleted file mode 100644
index d8c6e91..0000000
--- a/audio/fir_filter.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2020 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 FIR_FILTER_H
-#define FIR_FILTER_H
-
-#include <stdint.h>
-
-typedef enum fir_filter_mode { FIR_SINGLE_FILTER = 0, FIR_PER_CHANNEL_FILTER } fir_filter_mode_t;
-
-typedef struct fir_filter {
-    fir_filter_mode_t mode;
-    uint32_t channels;
-    uint32_t filter_length;
-    uint32_t buffer_size;
-    int16_t* coeffs;
-    int16_t* state;
-} fir_filter_t;
-
-fir_filter_t* fir_init(uint32_t channels, fir_filter_mode_t mode, uint32_t filter_length,
-                       uint32_t input_length, int16_t* coeffs);
-void fir_release(fir_filter_t* fir);
-void fir_reset(fir_filter_t* fir);
-void fir_process_interleaved(fir_filter_t* fir, int16_t* input, int16_t* output, uint32_t samples);
-
-#endif /* #ifndef FIR_FILTER_H */
diff --git a/audio/speaker_eq_sei610.fir b/audio/speaker_eq_sei610.fir
deleted file mode 100644
index 2352c32..0000000
--- a/audio/speaker_eq_sei610.fir
+++ /dev/null
@@ -1,523 +0,0 @@
-# FIR speaker EQ file for SEI-610
-# This filter attenuates 200-400Hz by 18dB,
-# and some 6dB notch attenuation at 2.25kHz, 3.8kHz, 6.6kHz.
-# Script to generate this file: https://drive.google.com/file/d/1_qvkZ8nU-c6tD6XrH80et2P12paardAz/view?usp=sharing
-
-# Full frequency response here: https://b.corp.google.com/issues/159714063#comment3
-
-# Each FIR coefficient is specified on one line (no leading spaces).
-# First line is 0th coefficient.
-# Values must be 16-bit integers. Currently, a max of 512 taps is supported.
-
-18976
-9870
--12520
-2452
--766
--1023
-1122
--2509
-316
--1464
-95
--817
--1191
--1882
--2299
--1806
--1180
--310
--68
--303
--957
--1544
--1738
--1490
--973
--517
--285
--261
--247
--68
-305
-729
-983
-931
-612
-210
--63
--100
-48
-234
-313
-244
-99
-3
-36
-183
-350
-435
-398
-286
-191
-188
-282
-409
-483
-454
-336
-192
-92
-63
-83
-100
-73
-2
--75
--114
--93
--27
-41
-73
-55
-9
--30
--38
--14
-18
-30
-9
--34
--78
--100
--94
--75
--62
--68
--91
--116
--124
--109
--79
--50
--35
--37
--47
--53
--48
--33
--19
--14
--22
--38
--51
--55
--49
--38
--31
--32
--38
--45
--45
--38
--26
--17
--14
--16
--21
--23
--21
--16
--12
--13
--17
--25
--30
--32
--31
--29
--28
--30
--33
--36
--37
--35
--32
--30
--31
--33
--36
--38
--38
--37
--37
--38
--40
--43
--46
--47
--47
--46
--46
--47
--49
--50
--50
--50
--49
--48
--49
--50
--51
--51
--51
--51
--51
--51
--52
--53
--54
--54
--54
--54
--54
--54
--55
--55
--55
--54
--54
--54
--54
--54
--55
--55
--55
--55
--55
--55
--55
--56
--56
--56
--56
--56
--56
--56
--56
--56
--56
--56
--55
--55
--55
--56
--56
--56
--56
--55
--55
--55
--56
--56
--56
--55
--55
--55
--55
--55
--55
--55
--55
--55
--54
--54
--54
--54
--54
--54
--54
--53
--53
--53
--53
--53
--53
--52
--52
--52
--52
--51
--51
--51
--51
--50
--50
--50
--50
--49
--49
--49
--48
--48
--48
--48
--47
--47
--47
--46
--46
--46
--45
--45
--45
--44
--44
--44
--43
--43
--43
--42
--42
--41
--41
--41
--40
--40
--40
--39
--39
--38
--38
--38
--37
--37
--36
--36
--36
--35
--35
--34
--34
--33
--33
--33
--32
--32
--31
--31
--31
--30
--30
--29
--29
--28
--28
--27
--27
--27
--26
--26
--25
--25
--24
--24
--24
--23
--23
--22
--22
--21
--21
--20
--20
--20
--19
--19
--18
--18
--17
--17
--17
--16
--16
--15
--15
--14
--14
--14
--13
--13
--12
--12
--11
--11
--11
--10
--10
--9
--9
--9
--8
--8
--7
--7
--7
--6
--6
--5
--5
--5
--4
--4
--3
--3
--3
--2
--2
--1
--1
--1
-0
-0
-0
-0
-0
-0
-1
-1
-1
-2
-2
-2
-3
-3
-3
-4
-4
-4
-5
-5
-5
-6
-6
-6
-7
-7
-7
-7
-8
-8
-8
-9
-9
-9
-9
-10
-10
-10
-10
-11
-11
-11
-11
-12
-12
-12
-12
-13
-13
-13
-13
-13
-14
-14
-14
-14
-14
-15
-15
-15
-15
-15
-16
-16
-16
-16
-16
-16
-17
-17
-17
-17
-17
-17
-17
-18
-18
-18
-18
-18
-18
-18
-18
-19
-19
-19
-19
-19
-19
-19
-19
-19
-19
-19
-20
-20
-20
-20
-20
-20
-20
-20
-20
-20
-20
-20
-20
-20
-20
-20
-20
-20
-21
-21
-21
-21
-21
-21
-21
-21
-21
-21
-21
-21
-21
-21
-21
-21
-21
-21
-21
-21
-21
-21
-21
-21
-21
-20
-20
-20
-20
-20
-20
