/*************************************************************************** * * Copyright 2015-2019 BES. * All rights reserved. All unpublished rights reserved. * * No part of this work may be used or reproduced in any form or by any * means, or stored in a database or retrieval system, without prior written * permission of BES. * * Use of this work is governed by a license granted by BES. * This work contains confidential and proprietary information of * BES. which is protected by copyright, trade secret, * trademark and other intellectual property rights. * ****************************************************************************/ #include "cmsis_os.h" #include "app_utils.h" #include "audioflinger.h" #include "hal_timer.h" #include "hal_trace.h" #include "string.h" #include "audio_dump.h" // #include "local_wav.h" #define CHANNEL_NUM (2) #define CHAR_BYTES (1) #define SHORT_BYTES (2) #define INT_BYTES (4) #define SAMPLE_BITS (16) #define SAMPLE_BYTES (SAMPLE_BITS / 8) #define TX_SAMPLE_RATE (16000) #define RX_SAMPLE_RATE (16000) #define TX_FRAME_LEN (256) #define RX_FRAME_LEN (256) #define TX_BUF_SIZE (TX_FRAME_LEN * CHANNEL_NUM * SAMPLE_BYTES * 2) #define RX_BUF_SIZE (RX_FRAME_LEN * CHANNEL_NUM * SAMPLE_BYTES * 2) #if SAMPLE_BYTES == SHORT_BYTES typedef short VOICE_PCM_T; #elif SAMPLE_BYTES == INT_BYTES typedef int VOICE_PCM_T; #else #error "Invalid SAMPLE_BYTES!!!" #endif static uint8_t POSSIBLY_UNUSED codec_capture_buf[TX_BUF_SIZE]; static uint8_t POSSIBLY_UNUSED codec_playback_buf[RX_BUF_SIZE]; static uint32_t POSSIBLY_UNUSED codec_capture_cnt = 0; static uint32_t POSSIBLY_UNUSED codec_playback_cnt = 0; #define CODEC_STREAM_ID AUD_STREAM_ID_0 static uint32_t codec_capture_callback(uint8_t *buf, uint32_t len) { int POSSIBLY_UNUSED pcm_len = len / sizeof(VOICE_PCM_T) / CHANNEL_NUM; VOICE_PCM_T POSSIBLY_UNUSED *pcm_buf[CHANNEL_NUM]; int interval_len = len * 2 / CHANNEL_NUM; for (int i=0; i