1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 #if defined(APP_LINEIN_A2DP_SOURCE)||defined(APP_I2S_A2DP_SOURCE) 5 #ifndef __APP_A2DP_SOURCE_H__ 6 #define __APP_A2DP_SOURCE_H__ 7 8 #include <stdio.h> 9 #include "cmsis_os.h" 10 #include "hal_uart.h" 11 #include "hal_timer.h" 12 #include "audioflinger.h" 13 #include "lockcqueue.h" 14 #include "hal_trace.h" 15 #include "hal_cmu.h" 16 #include "analog.h" 17 #include "bt_drv.h" 18 #include "app_audio.h" 19 #include "bt_drv_interface.h" 20 #include "app_bt_stream.h" 21 #include "nvrecord.h" 22 #include "nvrecord_env.h" 23 #include "nvrecord_dev.h" 24 #include "a2dp_api.h" 25 #include "avrcp_api.h" 26 27 #include "besbt.h" 28 29 #include "cqueue.h" 30 #include "btapp.h" 31 #include "apps.h" 32 #include "resources.h" 33 #include "app_bt_media_manager.h" 34 #include "tgt_hardware.h" 35 #include "app_utils.h" 36 #include "app_bt_func.h" 37 #include "a2dp_api.h" 38 39 #define APP_SOURCE_DEBUG 40 #ifdef APP_SOURCE_DEBUG 41 #define SOURCE_DBLOG TRACE 42 #else 43 #define SOURCE_DBLOG(...) 44 #endif 45 46 47 extern struct BT_DEVICE_T app_bt_device; 48 49 50 //#define A2DP_LINEIN_SIZE (48*2*1024) 51 //#define A2DP_TRANS_SIZE 2048 52 53 #define A2DP_LINEIN_SIZE (10*2*1024) 54 #define A2DP_TRANS_SIZE 1024*2 55 56 typedef struct { 57 osSemaphoreId _osSemaphoreId; 58 osSemaphoreDef_t _osSemaphoreDef; 59 #ifdef CMSIS_OS_RTX 60 uint32_t _semaphore_data[2]; 61 #endif 62 63 } a2dp_source_lock_t; 64 65 66 typedef struct{ 67 CQueue pcm_queue; 68 osThreadId sbc_send_id; 69 a2dp_source_lock_t data_lock; 70 a2dp_source_lock_t sbc_send_lock; 71 enum AUD_SAMPRATE_T sample_rate; 72 uint8_t sbcen_samplerate; 73 74 75 }A2DP_SOURCE_STRUCT; 76 77 78 typedef struct sbcpack{ 79 btif_a2dp_sbc_packet_t sbcPacket; 80 char buffer[A2DP_TRANS_SIZE]; 81 int free; 82 }sbcpack_t; 83 84 typedef struct sbcbank{ 85 sbcpack_t sbcpacks[1]; 86 int free; 87 }sbcbank_t; 88 89 extern A2DP_SOURCE_STRUCT a2dp_source; 90 extern void a2dp_source_notify_send(void); 91 extern uint32_t a2dp_source_linein_more_pcm_data(uint8_t * pcm_buf, uint32_t len); 92 #endif 93 #endif 94