component/bt: transport btif_media_task, btif_avrc

This commit is contained in:
wangmengyang
2017-03-02 11:47:59 +08:00
parent e8464e0f61
commit 8c84bcba72
10 changed files with 366 additions and 366 deletions

View File

@ -23,7 +23,7 @@
#include "bt_defs.h"
#include "allocator.h"
#include "btif_common.h"
#include "btc_common.h"
#include "btc_sm.h"
#include "gki.h"

View File

@ -17,8 +17,19 @@
#define __BTC_COMMON_H__
#include "bt_trace.h"
#include "bt_types.h"
#include "osi.h"
#define BTC_ASSERTC(cond, msg, val) if (!(cond)) { LOG_ERROR( \
"### ASSERT : %s line %d %s (%d) ###", __FILE__, __LINE__, msg, val);}
#define BTC_HAL_CBACK(P_CB, P_CBACK, ...)\
if (P_CB && P_CB->P_CBACK) { \
LOG_INFO("HAL %s->%s", #P_CB, #P_CBACK); \
P_CB->P_CBACK(__VA_ARGS__); \
} \
else { \
BTC_ASSERTC(0, "Callback is NULL", 0); \
}
#endif /* __BTC_COMMON_H__ */

View File

@ -31,7 +31,7 @@
#include "btif_util.h"
#include "btc_profile_queue.h"
#include "bta_api.h"
#include "btif_media.h"
#include "btc_media.h"
#include "bta_av_api.h"
#include "gki.h"
#include "btu.h"
@ -91,7 +91,7 @@ static btc_av_cb_t btc_av_cb = {0};
static TIMER_LIST_ENT tle_av_open_on_rc;
// TODO: need protection against race
#define BTIF_A2D_CB_TO_APP(_event, _param) do { \
#define BTC_A2D_CB_TO_APP(_event, _param) do { \
if (bt_av_sink_callback) { \
bt_av_sink_callback(_event, _param); \
} \
@ -241,7 +241,7 @@ static void btc_report_connection_state(esp_a2d_connection_state_t state, bt_bda
param.conn_stat.disc_rsn = (disc_rsn == 0) ? ESP_A2D_DISC_RSN_NORMAL :
ESP_A2D_DISC_RSN_ABNORMAL;
}
BTIF_A2D_CB_TO_APP(ESP_A2D_CONNECTION_STATE_EVT, &param);
BTC_A2D_CB_TO_APP(ESP_A2D_CONNECTION_STATE_EVT, &param);
}
static void btc_report_audio_state(esp_a2d_audio_state_t state, bt_bdaddr_t *bd_addr)
@ -253,7 +253,7 @@ static void btc_report_audio_state(esp_a2d_audio_state_t state, bt_bdaddr_t *bd_
if (bd_addr) {
memcpy(param.audio_stat.remote_bda, bd_addr, sizeof(esp_bd_addr_t));
}
BTIF_A2D_CB_TO_APP(ESP_A2D_AUDIO_STATE_EVT, &param);
BTC_A2D_CB_TO_APP(ESP_A2D_AUDIO_STATE_EVT, &param);
}
/*****************************************************************************
@ -277,7 +277,7 @@ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data)
memset(&btc_av_cb.peer_bda, 0, sizeof(bt_bdaddr_t));
btc_av_cb.flags = 0;
btc_av_cb.edr = 0;
btif_a2dp_on_idle();
btc_a2dp_on_idle();
break;
case BTC_SM_EXIT_EVT:
@ -393,7 +393,7 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
btc_av_cb.edr = p_bta_data->open.edr;
btc_av_cb.peer_sep = p_bta_data->open.sep;
btif_a2dp_set_peer_sep(p_bta_data->open.sep);
btc_a2dp_set_peer_sep(p_bta_data->open.sep);
} else {
LOG_WARN("BTA_AV_OPEN_EVT::FAILED status: %d\n",
p_bta_data->open.status );
@ -423,7 +423,7 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
esp_a2d_cb_param_t param;
memcpy(param.audio_cfg.remote_bda, &btc_av_cb.peer_bda, sizeof(esp_bd_addr_t));
memcpy(&param.audio_cfg.mcc, p_data, sizeof(esp_a2d_mcc_t));
BTIF_A2D_CB_TO_APP(ESP_A2D_AUDIO_CFG_EVT, &param);
BTC_A2D_CB_TO_APP(ESP_A2D_AUDIO_CFG_EVT, &param);
}
} break;
@ -484,17 +484,17 @@ static BOOLEAN btc_av_state_closing_handler(btc_sm_event_t event, void *p_data)
switch (event) {
case BTC_SM_ENTER_EVT:
if (btc_av_cb.peer_sep == AVDT_TSEP_SRC) {
btif_a2dp_set_rx_flush(TRUE);
btc_a2dp_set_rx_flush(TRUE);
}
break;
case BTA_AV_STOP_EVT:
case BTC_AV_STOP_STREAM_REQ_EVT:
if (btc_av_cb.peer_sep == AVDT_TSEP_SRC) {
btif_a2dp_set_rx_flush(TRUE);
btc_a2dp_set_rx_flush(TRUE);
}
btif_a2dp_on_stopped(NULL);
btc_a2dp_on_stopped(NULL);
break;
case BTC_SM_EXIT_EVT:
@ -576,7 +576,7 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data)
}
if (btc_av_cb.peer_sep == AVDT_TSEP_SRC) {
btif_a2dp_set_rx_flush(FALSE); /* remove flush state, ready for streaming*/
btc_a2dp_set_rx_flush(FALSE); /* remove flush state, ready for streaming*/
}
/* change state to started, send acknowledgement if start is pending */
@ -600,7 +600,7 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data)
case BTA_AV_CLOSE_EVT: {
/* avdtp link is closed */
btif_a2dp_on_stopped(NULL);
btc_a2dp_on_stopped(NULL);
tBTA_AV_CLOSE *close = (tBTA_AV_CLOSE *)p_data;
/* inform the application that we are disconnected */
@ -692,7 +692,7 @@ static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *p_data)
case BTC_AV_STOP_STREAM_REQ_EVT:
case BTC_AV_SUSPEND_STREAM_REQ_EVT:
/* set pending flag to ensure btif task is not trying to restart
/* set pending flag to ensure btc task is not trying to restart
stream while suspend is in progress */
btc_av_cb.flags |= BTC_AV_FLAG_LOCAL_SUSPEND_PENDING;
@ -701,8 +701,8 @@ static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *p_data)
btc_av_cb.flags &= ~BTC_AV_FLAG_REMOTE_SUSPEND;
if (btc_av_cb.peer_sep == AVDT_TSEP_SRC) {
btif_a2dp_set_rx_flush(TRUE);
btif_a2dp_on_stopped(NULL);
btc_a2dp_set_rx_flush(TRUE);
btc_a2dp_on_stopped(NULL);
}
BTA_AvStop(TRUE);
@ -729,7 +729,7 @@ static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *p_data)
p_av->suspend.status, p_av->suspend.initiator);
/* a2dp suspended, stop media task until resumed */
btif_a2dp_on_suspended(&p_av->suspend);
btc_a2dp_on_suspended(&p_av->suspend);
/* if not successful, remain in current state */
if (p_av->suspend.status != BTA_AV_SUCCESS) {
@ -762,7 +762,7 @@ static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *p_data)
case BTA_AV_STOP_EVT:
btc_av_cb.flags |= BTC_AV_FLAG_PENDING_STOP;
btif_a2dp_on_stopped(&p_av->suspend);
btc_a2dp_on_stopped(&p_av->suspend);
btc_report_audio_state(ESP_A2D_AUDIO_STATE_STOPPED, &(btc_av_cb.peer_bda));
@ -778,7 +778,7 @@ static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *p_data)
btc_av_cb.flags |= BTC_AV_FLAG_PENDING_STOP;
/* avdtp link is closed */
btif_a2dp_on_stopped(NULL);
btc_a2dp_on_stopped(NULL);
tBTA_AV_CLOSE *close = (tBTA_AV_CLOSE *)p_data;
/* inform the application that we are disconnected */
@ -887,11 +887,11 @@ static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
tA2D_STATUS a2d_status;
tA2D_SBC_CIE sbc_cie;
if (event == BTA_AV_MEDIA_DATA_EVT) { /* Switch to BTIF_MEDIA context */
if (event == BTA_AV_MEDIA_DATA_EVT) { /* Switch to BTC_MEDIA context */
state = btc_sm_get_state(btc_av_cb.sm_handle);
if ( (state == BTC_AV_STATE_STARTED) || /* send SBC packets only in Started State */
(state == BTC_AV_STATE_OPENED) ) {
que_len = btif_media_sink_enque_buf((BT_HDR *)p_data);
que_len = btc_media_sink_enque_buf((BT_HDR *)p_data);
LOG_DEBUG(" Packets in Que %d\n", que_len);
} else {
return;
@ -900,7 +900,7 @@ static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
if (event == BTA_AV_MEDIA_SINK_CFG_EVT) {
/* send a command to BT Media Task */
btif_reset_decoder((UINT8 *)p_data);
btc_reset_decoder((UINT8 *)p_data);
/* currently only supportes SBC */
a2d_status = A2D_ParsSbcInfo(&sbc_cie, (UINT8 *)p_data, FALSE);
@ -925,7 +925,7 @@ static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
**
** Function btc_av_init
**
** Description Initializes btif AV if not already done
** Description Initializes btc AV if not already done
**
** Returns bt_status_t
**
@ -934,7 +934,7 @@ static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
bt_status_t btc_av_init()
{
if (btc_av_cb.sm_handle == NULL) {
if (!btif_a2dp_start_media_task()) {
if (!btc_a2dp_start_media_task()) {
return BT_STATUS_FAIL;
}
@ -947,7 +947,7 @@ bt_status_t btc_av_init()
btc_dm_enable_service(BTA_A2DP_SINK_SERVICE_ID);
#endif
btif_a2dp_on_init();
btc_a2dp_on_init();
}
return BT_STATUS_SUCCESS;
@ -1037,7 +1037,7 @@ esp_err_t esp_a2d_sink_disconnect(esp_bd_addr_t remote_bda)
LOG_INFO("%s\n", __FUNCTION__);
CHECK_BTAV_INIT();
memcpy(&(arg.disconnect), remote_bda, sizeof(bt_bdaddr_t));
/* Switch to BTIF context */
/* Switch to BTC context */
stat = btc_transfer_context(&msg, &arg, sizeof(btc_av_args_t), NULL);
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
}
@ -1054,11 +1054,11 @@ static void cleanup(void)
{
LOG_INFO("%s\n", __FUNCTION__);
btif_a2dp_stop_media_task();
btc_a2dp_stop_media_task();
btif_disable_service(BTA_A2DP_SOURCE_SERVICE_ID);
btc_dm_disable_service(BTA_A2DP_SOURCE_SERVICE_ID);
#if (BTA_AV_SINK_INCLUDED == TRUE)
btif_disable_service(BTA_A2DP_SINK_SERVICE_ID);
btc_dm_disable_service(BTA_A2DP_SINK_SERVICE_ID);
#endif
/* Also shut down the AV state machine */
@ -1108,12 +1108,13 @@ BOOLEAN btc_av_stream_ready(void)
LOG_DEBUG("btc_av_stream_ready : sm hdl %d, state %d, flags %x\n",
(int)btc_av_cb.sm_handle, state, btc_av_cb.flags);
#if 0 /* karl */
/* also make sure main adapter is enabled */
if (btif_is_enabled() == 0) {
LOG_INFO("main adapter not enabled");
return FALSE;
}
#endif
/* check if we are remotely suspended or stop is pending */
if (btc_av_cb.flags & (BTC_AV_FLAG_REMOTE_SUSPEND | BTC_AV_FLAG_PENDING_STOP)) {
return FALSE;
@ -1258,7 +1259,7 @@ BOOLEAN btc_av_is_peer_edr(void)
**
** Function btc_av_clear_remote_suspend_flag
**
** Description Clears btif_av_cd.flags if BTC_AV_FLAG_REMOTE_SUSPEND is set
** Description Clears btc_av_cb.flags if BTC_AV_FLAG_REMOTE_SUSPEND is set
**
** Returns void
******************************************************************************/

View File

@ -1,26 +1,22 @@
/******************************************************************************
*
* Copyright (C) 2009-2012 Broadcom Corporation
*
* 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.
*
******************************************************************************/
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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.
/******************************************************************************
**
** Name: btif_media_task.c
** Name: btc_media_task.c
**
** Description: This is the multimedia module for the BTIF system. It
** Description: This is the multimedia module for the BTC system. It
** contains task implementations AV, HS and HF profiles
** audio & video processing
**
@ -48,7 +44,7 @@
#include "l2c_api.h"
#include "btif_av_co.h"
#include "btif_media.h"
#include "btc_media.h"
#include "alarm.h"
#include "bt_trace.h"
@ -64,7 +60,6 @@
#endif
#include "stdio.h"
#include "btif_media.h"
#include "allocator.h"
#include "bt_utils.h"
#include "esp_a2dp_api.h"
@ -88,22 +83,22 @@ OI_INT16 pcmData[15 * SBC_MAX_SAMPLES_PER_FRAME * SBC_MAX_CHANNELS];
#define AUDIO_CHANNEL_OUT_STEREO 0x03
#endif
/* BTIF media cmd event definition : BTIF_MEDIA_TASK_CMD */
/* BTC media cmd event definition : BTC_MEDIA_TASK_CMD */
enum {
BTIF_MEDIA_START_AA_TX = 1,
BTIF_MEDIA_STOP_AA_TX,
BTIF_MEDIA_AA_RX_RDY,
BTIF_MEDIA_UIPC_RX_RDY,
BTIF_MEDIA_SBC_ENC_INIT,
BTIF_MEDIA_SBC_ENC_UPDATE,
BTIF_MEDIA_SBC_DEC_INIT,
BTIF_MEDIA_VIDEO_DEC_INIT,
BTIF_MEDIA_FLUSH_AA_TX,
BTIF_MEDIA_FLUSH_AA_RX,
BTIF_MEDIA_AUDIO_FEEDING_INIT,
BTIF_MEDIA_AUDIO_RECEIVING_INIT,
BTIF_MEDIA_AUDIO_SINK_CFG_UPDATE,
BTIF_MEDIA_AUDIO_SINK_CLEAR_TRACK
BTC_MEDIA_START_AA_TX = 1,
BTC_MEDIA_STOP_AA_TX,
BTC_MEDIA_AA_RX_RDY,
BTC_MEDIA_UIPC_RX_RDY,
BTC_MEDIA_SBC_ENC_INIT,
BTC_MEDIA_SBC_ENC_UPDATE,
BTC_MEDIA_SBC_DEC_INIT,
BTC_MEDIA_VIDEO_DEC_INIT,
BTC_MEDIA_FLUSH_AA_TX,
BTC_MEDIA_FLUSH_AA_RX,
BTC_MEDIA_AUDIO_FEEDING_INIT,
BTC_MEDIA_AUDIO_RECEIVING_INIT,
BTC_MEDIA_AUDIO_SINK_CFG_UPDATE,
BTC_MEDIA_AUDIO_SINK_CLEAR_TRACK
};
enum {
@ -121,39 +116,39 @@ enum {
};
/* Macro to multiply the media task tick */
#ifndef BTIF_MEDIA_NUM_TICK
#define BTIF_MEDIA_NUM_TICK 1
#ifndef BTC_MEDIA_NUM_TICK
#define BTC_MEDIA_NUM_TICK 1
#endif
/* Media task tick in milliseconds, must be set to multiple of
(1000/TICKS_PER_SEC) (10) */
#define BTIF_MEDIA_TIME_TICK (20 * BTIF_MEDIA_NUM_TICK)
#define A2DP_DATA_READ_POLL_MS (BTIF_MEDIA_TIME_TICK / 2)
#define BTIF_SINK_MEDIA_TIME_TICK (20 * BTIF_MEDIA_NUM_TICK)
#define BTC_MEDIA_TIME_TICK (20 * BTC_MEDIA_NUM_TICK)
#define A2DP_DATA_READ_POLL_MS (BTC_MEDIA_TIME_TICK / 2)
#define BTC_SINK_MEDIA_TIME_TICK (20 * BTC_MEDIA_NUM_TICK)
/* buffer pool */
#define BTIF_MEDIA_AA_POOL_ID GKI_POOL_ID_3
#define BTIF_MEDIA_AA_BUF_SIZE GKI_BUF3_SIZE
#define BTC_MEDIA_AA_POOL_ID GKI_POOL_ID_3
#define BTC_MEDIA_AA_BUF_SIZE GKI_BUF3_SIZE
/* offset */
#if (BTA_AV_CO_CP_SCMS_T == TRUE)
#define BTIF_MEDIA_AA_SBC_OFFSET (AVDT_MEDIA_OFFSET + BTA_AV_SBC_HDR_SIZE + 1)
#define BTC_MEDIA_AA_SBC_OFFSET (AVDT_MEDIA_OFFSET + BTA_AV_SBC_HDR_SIZE + 1)
#else
#define BTIF_MEDIA_AA_SBC_OFFSET (AVDT_MEDIA_OFFSET + BTA_AV_SBC_HDR_SIZE)
#define BTC_MEDIA_AA_SBC_OFFSET (AVDT_MEDIA_OFFSET + BTA_AV_SBC_HDR_SIZE)
#endif
/* Define the bitrate step when trying to match bitpool value */
#ifndef BTIF_MEDIA_BITRATE_STEP
#define BTIF_MEDIA_BITRATE_STEP 5
#ifndef BTC_MEDIA_BITRATE_STEP
#define BTC_MEDIA_BITRATE_STEP 5
#endif
/* Middle quality quality setting @ 44.1 khz */
#define DEFAULT_SBC_BITRATE 328
#ifndef BTIF_A2DP_NON_EDR_MAX_RATE
#define BTIF_A2DP_NON_EDR_MAX_RATE 229
#ifndef BTC_A2DP_NON_EDR_MAX_RATE
#define BTC_A2DP_NON_EDR_MAX_RATE 229
#endif
#define USEC_PER_SEC 1000000L
@ -205,11 +200,11 @@ typedef struct {
INT32 aa_feed_residue;
UINT32 counter;
UINT32 bytes_per_tick; /* pcm bytes read each media task tick */
} tBTIF_AV_MEDIA_FEEDINGS_PCM_STATE;
} tBTC_AV_MEDIA_FEEDINGS_PCM_STATE;
typedef union {
tBTIF_AV_MEDIA_FEEDINGS_PCM_STATE pcm;
} tBTIF_AV_MEDIA_FEEDINGS_STATE;
tBTC_AV_MEDIA_FEEDINGS_PCM_STATE pcm;
} tBTC_AV_MEDIA_FEEDINGS_STATE;
typedef struct {
#if (BTA_AV_INCLUDED == TRUE)
@ -228,7 +223,7 @@ typedef struct {
UINT8 channel_count;
#endif
} tBTIF_MEDIA_CB;
} tBTC_MEDIA_CB;
typedef struct {
long long rx;
@ -251,37 +246,37 @@ extern OI_STATUS OI_CODEC_SBC_DecoderReset(OI_CODEC_SBC_DECODER_CONTEXT *context
OI_UINT8 pcmStride,
OI_BOOL enhanced);
#endif
static void btif_media_flush_q(BUFFER_Q *p_q);
static void btif_media_task_aa_rx_flush(void);
static void btc_media_flush_q(BUFFER_Q *p_q);
static void btc_media_task_aa_rx_flush(void);
static const char *dump_media_event(UINT16 event);
static void btif_media_thread_handle_cmd(fixed_queue_t *queue);
static void btc_media_thread_handle_cmd(fixed_queue_t *queue);
/* Handle incoming media packets A2DP SINK streaming*/
#if (BTA_AV_SINK_INCLUDED == TRUE)
static void btif_media_task_handle_inc_media(tBT_SBC_HDR *p_msg);
static void btc_media_task_handle_inc_media(tBT_SBC_HDR *p_msg);
#endif
#if (BTA_AV_INCLUDED == TRUE)
#if (BTA_AV_SINK_INCLUDED == TRUE)
static void btif_media_task_aa_handle_decoder_reset(BT_HDR *p_msg);
static void btif_media_task_aa_handle_clear_track(void);
static void btc_media_task_aa_handle_decoder_reset(BT_HDR *p_msg);
static void btc_media_task_aa_handle_clear_track(void);
#endif
#endif
BOOLEAN btif_media_task_clear_track(void);
static void btif_media_task_handler(void *arg);
BOOLEAN btc_media_task_clear_track(void);
static void btc_media_task_handler(void *arg);
static void btif_media_task_avk_data_ready(UNUSED_ATTR void *context);
static void btif_media_thread_init(UNUSED_ATTR void *context);
static void btif_media_thread_cleanup(UNUSED_ATTR void *context);
extern BOOLEAN btif_hf_is_call_idle();
static void btc_media_task_avk_data_ready(UNUSED_ATTR void *context);
static void btc_media_thread_init(UNUSED_ATTR void *context);
static void btc_media_thread_cleanup(UNUSED_ATTR void *context);
extern BOOLEAN btc_is_call_idle();
static tBTIF_MEDIA_CB btif_media_cb;
static tBTC_MEDIA_CB btc_media_cb;
static int media_task_running = MEDIA_TASK_STATE_OFF;
static fixed_queue_t *btif_media_cmd_msg_queue = NULL;
static xTaskHandle xBtifMediaTaskHandle = NULL;
static QueueHandle_t xBtifMediaQueue = NULL;
static fixed_queue_t *btc_media_cmd_msg_queue = NULL;
static xTaskHandle xBtcMediaTaskHandle = NULL;
static QueueHandle_t xBtcMediaQueue = NULL;
static esp_a2d_data_cb_t bt_av_sink_data_callback = NULL;
@ -293,7 +288,7 @@ esp_err_t esp_a2d_register_data_callback(esp_a2d_data_cb_t cb)
}
// TODO: need protection against race
#define BTIF_A2D_DATA_CB_TO_APP(data, len) do { \
#define BTC_A2D_DATA_CB_TO_APP(data, len) do { \
if (bt_av_sink_data_callback) { \
bt_av_sink_data_callback(data, len); \
} \
@ -302,7 +297,7 @@ esp_err_t esp_a2d_register_data_callback(esp_a2d_data_cb_t cb)
/*****************************************************************************
** temporary hacked functions. TODO: port these functions or remove them?
*****************************************************************************/
BOOLEAN btif_hf_is_call_idle(void)
BOOLEAN btc_is_call_idle(void)
{
return FALSE;
}
@ -314,20 +309,20 @@ BOOLEAN btif_hf_is_call_idle(void)
UNUSED_ATTR static const char *dump_media_event(UINT16 event)
{
switch (event) {
CASE_RETURN_STR(BTIF_MEDIA_START_AA_TX)
CASE_RETURN_STR(BTIF_MEDIA_STOP_AA_TX)
CASE_RETURN_STR(BTIF_MEDIA_AA_RX_RDY)
CASE_RETURN_STR(BTIF_MEDIA_UIPC_RX_RDY)
CASE_RETURN_STR(BTIF_MEDIA_SBC_ENC_INIT)
CASE_RETURN_STR(BTIF_MEDIA_SBC_ENC_UPDATE)
CASE_RETURN_STR(BTIF_MEDIA_SBC_DEC_INIT)
CASE_RETURN_STR(BTIF_MEDIA_VIDEO_DEC_INIT)
CASE_RETURN_STR(BTIF_MEDIA_FLUSH_AA_TX)
CASE_RETURN_STR(BTIF_MEDIA_FLUSH_AA_RX)
CASE_RETURN_STR(BTIF_MEDIA_AUDIO_FEEDING_INIT)
CASE_RETURN_STR(BTIF_MEDIA_AUDIO_RECEIVING_INIT)
CASE_RETURN_STR(BTIF_MEDIA_AUDIO_SINK_CFG_UPDATE)
CASE_RETURN_STR(BTIF_MEDIA_AUDIO_SINK_CLEAR_TRACK)
CASE_RETURN_STR(BTC_MEDIA_START_AA_TX)
CASE_RETURN_STR(BTC_MEDIA_STOP_AA_TX)
CASE_RETURN_STR(BTC_MEDIA_AA_RX_RDY)
CASE_RETURN_STR(BTC_MEDIA_UIPC_RX_RDY)
CASE_RETURN_STR(BTC_MEDIA_SBC_ENC_INIT)
CASE_RETURN_STR(BTC_MEDIA_SBC_ENC_UPDATE)
CASE_RETURN_STR(BTC_MEDIA_SBC_DEC_INIT)
CASE_RETURN_STR(BTC_MEDIA_VIDEO_DEC_INIT)
CASE_RETURN_STR(BTC_MEDIA_FLUSH_AA_TX)
CASE_RETURN_STR(BTC_MEDIA_FLUSH_AA_RX)
CASE_RETURN_STR(BTC_MEDIA_AUDIO_FEEDING_INIT)
CASE_RETURN_STR(BTC_MEDIA_AUDIO_RECEIVING_INIT)
CASE_RETURN_STR(BTC_MEDIA_AUDIO_SINK_CFG_UPDATE)
CASE_RETURN_STR(BTC_MEDIA_AUDIO_SINK_CLEAR_TRACK)
default:
return "UNKNOWN MEDIA EVENT";
@ -335,10 +330,10 @@ UNUSED_ATTR static const char *dump_media_event(UINT16 event)
}
/*****************************************************************************
** BTIF ADAPTATION
** BTC ADAPTATION
*****************************************************************************/
static void btif_media_task_post(uint32_t sig)
static void btc_media_task_post(uint32_t sig)
{
BtTaskEvt_t *evt = (BtTaskEvt_t *)osi_malloc(sizeof(BtTaskEvt_t));
if (evt == NULL) {
@ -348,29 +343,29 @@ static void btif_media_task_post(uint32_t sig)
evt->sig = sig;
evt->par = 0;
if (xQueueSend(xBtifMediaQueue, &evt, 10 / portTICK_RATE_MS) != pdTRUE) {
APPL_TRACE_ERROR("xBtifMediaQueue failed\n");
if (xQueueSend(xBtcMediaQueue, &evt, 10 / portTICK_RATE_MS) != pdTRUE) {
APPL_TRACE_ERROR("xBtcMediaQueue failed\n");
}
}
static void btif_media_task_handler(void *arg)
static void btc_media_task_handler(void *arg)
{
BtTaskEvt_t *e;
for (;;) {
if (pdTRUE == xQueueReceive(xBtifMediaQueue, &e, (portTickType)portMAX_DELAY)) {
if (pdTRUE == xQueueReceive(xBtcMediaQueue, &e, (portTickType)portMAX_DELAY)) {
// LOG_ERROR("med evt %d\n", e->sig);
switch (e->sig) {
case SIG_MEDIA_TASK_AVK_DATA_READY:
btif_media_task_avk_data_ready(NULL);
btc_media_task_avk_data_ready(NULL);
break;
case SIG_MEDIA_TASK_CMD_READY:
fixed_queue_process(btif_media_cmd_msg_queue);
fixed_queue_process(btc_media_cmd_msg_queue);
break;
case SIG_MEDIA_TASK_INIT:
btif_media_thread_init(NULL);
btc_media_thread_init(NULL);
break;
case SIG_MEDIA_TASK_CLEAN_UP:
btif_media_thread_cleanup(NULL);
btc_media_thread_cleanup(NULL);
break;
default:
APPL_TRACE_ERROR("media task unhandled evt: 0x%x\n", e->sig);
@ -380,7 +375,7 @@ static void btif_media_task_handler(void *arg)
}
}
bool btif_a2dp_start_media_task(void)
bool btc_a2dp_start_media_task(void)
{
if (media_task_running != MEDIA_TASK_STATE_OFF) {
APPL_TRACE_ERROR("warning : media task already running");
@ -389,21 +384,21 @@ bool btif_a2dp_start_media_task(void)
APPL_TRACE_EVENT("## A2DP START MEDIA THREAD ##");
btif_media_cmd_msg_queue = fixed_queue_new(SIZE_MAX);
if (btif_media_cmd_msg_queue == NULL) {
btc_media_cmd_msg_queue = fixed_queue_new(SIZE_MAX);
if (btc_media_cmd_msg_queue == NULL) {
goto error_exit;
}
xBtifMediaQueue = xQueueCreate(60, sizeof(void *));
if (xBtifMediaQueue == 0) {
xBtcMediaQueue = xQueueCreate(60, sizeof(void *));
if (xBtcMediaQueue == 0) {
goto error_exit;
}
xTaskCreatePinnedToCore(btif_media_task_handler, "BtifMediaT\n", 2048, NULL, configMAX_PRIORITIES - 1, &xBtifMediaTaskHandle, 0);
if (xBtifMediaTaskHandle == NULL) {
xTaskCreatePinnedToCore(btc_media_task_handler, "BtcMediaT\n", 2048, NULL, configMAX_PRIORITIES - 1, &xBtcMediaTaskHandle, 0);
if (xBtcMediaTaskHandle == NULL) {
goto error_exit;
}
fixed_queue_register_dequeue(btif_media_cmd_msg_queue, btif_media_thread_handle_cmd);
btif_media_task_post(SIG_MEDIA_TASK_INIT);
fixed_queue_register_dequeue(btc_media_cmd_msg_queue, btc_media_thread_handle_cmd);
btc_media_task_post(SIG_MEDIA_TASK_INIT);
APPL_TRACE_EVENT("## A2DP MEDIA THREAD STARTED ##\n");
@ -412,39 +407,39 @@ bool btif_a2dp_start_media_task(void)
error_exit:;
APPL_TRACE_ERROR("%s unable to start up media thread\n", __func__);
if (xBtifMediaTaskHandle != NULL) {
vTaskDelete(xBtifMediaTaskHandle);
xBtifMediaTaskHandle = NULL;
if (xBtcMediaTaskHandle != NULL) {
vTaskDelete(xBtcMediaTaskHandle);
xBtcMediaTaskHandle = NULL;
}
if (xBtifMediaQueue != 0) {
vQueueDelete(xBtifMediaQueue);
xBtifMediaQueue = 0;
if (xBtcMediaQueue != 0) {
vQueueDelete(xBtcMediaQueue);
xBtcMediaQueue = 0;
}
fixed_queue_free(btif_media_cmd_msg_queue, NULL);
btif_media_cmd_msg_queue = NULL;
fixed_queue_free(btc_media_cmd_msg_queue, NULL);
btc_media_cmd_msg_queue = NULL;
return false;
}
void btif_a2dp_stop_media_task(void)
void btc_a2dp_stop_media_task(void)
{
APPL_TRACE_EVENT("## A2DP STOP MEDIA THREAD ##\n");
// Exit thread
btif_media_task_post(SIG_MEDIA_TASK_CLEAN_UP);
btc_media_task_post(SIG_MEDIA_TASK_CLEAN_UP);
// TODO: wait until CLEAN up is done, then do task delete
vTaskDelete(xBtifMediaTaskHandle);
xBtifMediaTaskHandle = NULL;
vQueueDelete(xBtifMediaQueue);
xBtifMediaQueue = NULL;
vTaskDelete(xBtcMediaTaskHandle);
xBtcMediaTaskHandle = NULL;
vQueueDelete(xBtcMediaQueue);
xBtcMediaQueue = NULL;
fixed_queue_free(btif_media_cmd_msg_queue, NULL);
btif_media_cmd_msg_queue = NULL;
fixed_queue_free(btc_media_cmd_msg_queue, NULL);
btc_media_cmd_msg_queue = NULL;
}
/*****************************************************************************
**
** Function btif_a2dp_on_init
** Function btc_a2dp_on_init
**
** Description
**
@ -452,7 +447,7 @@ void btif_a2dp_stop_media_task(void)
**
*******************************************************************************/
void btif_a2dp_on_init(void)
void btc_a2dp_on_init(void)
{
//tput_mon(1, 0, 1);
}
@ -460,7 +455,7 @@ void btif_a2dp_on_init(void)
/*****************************************************************************
**
** Function btif_a2dp_setup_codec
** Function btc_a2dp_setup_codec
**
** Description
**
@ -468,10 +463,10 @@ void btif_a2dp_on_init(void)
**
*******************************************************************************/
void btif_a2dp_setup_codec(void)
void btc_a2dp_setup_codec(void)
{
tBTIF_AV_MEDIA_FEEDINGS media_feeding;
tBTIF_STATUS status;
tBTC_STATUS status;
APPL_TRACE_EVENT("## A2DP SETUP CODEC ##\n");
@ -491,7 +486,7 @@ void btif_a2dp_setup_codec(void)
/*****************************************************************************
**
** Function btif_a2dp_on_idle
** Function btc_a2dp_on_idle
**
** Description
**
@ -499,16 +494,16 @@ void btif_a2dp_setup_codec(void)
**
*******************************************************************************/
void btif_a2dp_on_idle(void)
void btc_a2dp_on_idle(void)
{
APPL_TRACE_EVENT("## ON A2DP IDLE ##\n");
bta_av_co_init();
#if (BTA_AV_SINK_INCLUDED == TRUE)
if (btif_media_cb.peer_sep == AVDT_TSEP_SRC) {
btif_media_cb.rx_flush = TRUE;
btif_media_task_aa_rx_flush_req();
btif_media_task_clear_track();
if (btc_media_cb.peer_sep == AVDT_TSEP_SRC) {
btc_media_cb.rx_flush = TRUE;
btc_media_task_aa_rx_flush_req();
btc_media_task_clear_track();
APPL_TRACE_DEBUG("Stopped BT track");
}
#endif
@ -516,14 +511,14 @@ void btif_a2dp_on_idle(void)
/*******************************************************************************
**
** Function btif_media_task_clear_track
** Function btc_media_task_clear_track
**
** Description
**
** Returns TRUE is success
**
*******************************************************************************/
BOOLEAN btif_media_task_clear_track(void)
BOOLEAN btc_media_task_clear_track(void)
{
BT_HDR *p_buf;
@ -531,16 +526,16 @@ BOOLEAN btif_media_task_clear_track(void)
return FALSE;
}
p_buf->event = BTIF_MEDIA_AUDIO_SINK_CLEAR_TRACK;
p_buf->event = BTC_MEDIA_AUDIO_SINK_CLEAR_TRACK;
fixed_queue_enqueue(btif_media_cmd_msg_queue, p_buf);
btif_media_task_post(SIG_MEDIA_TASK_CMD_READY);
fixed_queue_enqueue(btc_media_cmd_msg_queue, p_buf);
btc_media_task_post(SIG_MEDIA_TASK_CMD_READY);
return TRUE;
}
/*****************************************************************************
**
** Function btif_reset_decoder
** Function btc_reset_decoder
**
** Description
**
@ -548,29 +543,29 @@ BOOLEAN btif_media_task_clear_track(void)
**
*******************************************************************************/
void btif_reset_decoder(UINT8 *p_av)
void btc_reset_decoder(UINT8 *p_av)
{
APPL_TRACE_EVENT("btif_reset_decoder");
APPL_TRACE_DEBUG("btif_reset_decoder p_codec_info[%x:%x:%x:%x:%x:%x]\n",
APPL_TRACE_EVENT("btc_reset_decoder");
APPL_TRACE_DEBUG("btc_reset_decoder p_codec_info[%x:%x:%x:%x:%x:%x]\n",
p_av[1], p_av[2], p_av[3],
p_av[4], p_av[5], p_av[6]);
tBTIF_MEDIA_SINK_CFG_UPDATE *p_buf;
if (NULL == (p_buf = GKI_getbuf(sizeof(tBTIF_MEDIA_SINK_CFG_UPDATE)))) {
APPL_TRACE_ERROR("btif_reset_decoder No Buffer ");
tBTC_MEDIA_SINK_CFG_UPDATE *p_buf;
if (NULL == (p_buf = GKI_getbuf(sizeof(tBTC_MEDIA_SINK_CFG_UPDATE)))) {
APPL_TRACE_ERROR("btc_reset_decoder No Buffer ");
return;
}
memcpy(p_buf->codec_info, p_av, AVDT_CODEC_SIZE);
p_buf->hdr.event = BTIF_MEDIA_AUDIO_SINK_CFG_UPDATE;
p_buf->hdr.event = BTC_MEDIA_AUDIO_SINK_CFG_UPDATE;
fixed_queue_enqueue(btif_media_cmd_msg_queue, p_buf);
btif_media_task_post(SIG_MEDIA_TASK_CMD_READY);
fixed_queue_enqueue(btc_media_cmd_msg_queue, p_buf);
btc_media_task_post(SIG_MEDIA_TASK_CMD_READY);
}
/*****************************************************************************
**
** Function btif_a2dp_on_stopped
** Function btc_a2dp_on_stopped
**
** Description
**
@ -578,13 +573,13 @@ void btif_reset_decoder(UINT8 *p_av)
**
*******************************************************************************/
void btif_a2dp_on_stopped(tBTA_AV_SUSPEND *p_av)
void btc_a2dp_on_stopped(tBTA_AV_SUSPEND *p_av)
{
APPL_TRACE_EVENT("## ON A2DP STOPPED ##\n");
if (btif_media_cb.peer_sep == AVDT_TSEP_SRC) { /* Handling for A2DP SINK cases*/
btif_media_cb.rx_flush = TRUE;
btif_media_task_aa_rx_flush_req();
btif_media_cb.data_channel_open = FALSE;
if (btc_media_cb.peer_sep == AVDT_TSEP_SRC) { /* Handling for A2DP SINK cases*/
btc_media_cb.rx_flush = TRUE;
btc_media_task_aa_rx_flush_req();
btc_media_cb.data_channel_open = FALSE;
return;
}
}
@ -592,7 +587,7 @@ void btif_a2dp_on_stopped(tBTA_AV_SUSPEND *p_av)
/*****************************************************************************
**
** Function btif_a2dp_on_suspended
** Function btc_a2dp_on_suspended
**
** Description
**
@ -600,61 +595,61 @@ void btif_a2dp_on_stopped(tBTA_AV_SUSPEND *p_av)
**
*******************************************************************************/
void btif_a2dp_on_suspended(tBTA_AV_SUSPEND *p_av)
void btc_a2dp_on_suspended(tBTA_AV_SUSPEND *p_av)
{
APPL_TRACE_EVENT("## ON A2DP SUSPENDED ##\n");
if (btif_media_cb.peer_sep == AVDT_TSEP_SRC) {
btif_media_cb.rx_flush = TRUE;
btif_media_task_aa_rx_flush_req();
if (btc_media_cb.peer_sep == AVDT_TSEP_SRC) {
btc_media_cb.rx_flush = TRUE;
btc_media_task_aa_rx_flush_req();
return;
}
}
/* when true media task discards any rx frames */
void btif_a2dp_set_rx_flush(BOOLEAN enable)
void btc_a2dp_set_rx_flush(BOOLEAN enable)
{
APPL_TRACE_EVENT("## DROP RX %d ##\n", enable);
btif_media_cb.rx_flush = enable;
btc_media_cb.rx_flush = enable;
}
#if (BTA_AV_SINK_INCLUDED == TRUE)
static void btif_media_task_avk_data_ready(UNUSED_ATTR void *context)
static void btc_media_task_avk_data_ready(UNUSED_ATTR void *context)
{
UINT8 count;
tBT_SBC_HDR *p_msg;
int num_sbc_frames;
int num_frames_to_process;
count = btif_media_cb.RxSbcQ._count;
count = btc_media_cb.RxSbcQ._count;
if (0 == count) {
APPL_TRACE_DEBUG(" QUE EMPTY ");
} else {
if (btif_media_cb.rx_flush == TRUE) {
btif_media_flush_q(&(btif_media_cb.RxSbcQ));
if (btc_media_cb.rx_flush == TRUE) {
btc_media_flush_q(&(btc_media_cb.RxSbcQ));
return;
}
num_frames_to_process = btif_media_cb.frames_to_process;
num_frames_to_process = btc_media_cb.frames_to_process;
APPL_TRACE_DEBUG(" Process Frames + ");
do {
p_msg = (tBT_SBC_HDR *)GKI_getfirst(&(btif_media_cb.RxSbcQ));
p_msg = (tBT_SBC_HDR *)GKI_getfirst(&(btc_media_cb.RxSbcQ));
if (p_msg == NULL) {
return;
}
num_sbc_frames = p_msg->num_frames_to_be_processed; /* num of frames in Que Packets */
APPL_TRACE_DEBUG(" Frames left in topmost packet %d\n", num_sbc_frames);
APPL_TRACE_DEBUG(" Remaining frames to process in tick %d\n", num_frames_to_process);
APPL_TRACE_DEBUG(" Num of Packets in Que %d\n", btif_media_cb.RxSbcQ._count);
APPL_TRACE_DEBUG(" Num of Packets in Que %d\n", btc_media_cb.RxSbcQ._count);
if ( num_sbc_frames > num_frames_to_process) { /* Que Packet has more frames*/
p_msg->num_frames_to_be_processed = num_frames_to_process;
btif_media_task_handle_inc_media(p_msg);
btc_media_task_handle_inc_media(p_msg);
p_msg->num_frames_to_be_processed = num_sbc_frames - num_frames_to_process;
num_frames_to_process = 0;
break;
} else { /* Que packet has less frames */
btif_media_task_handle_inc_media(p_msg);
p_msg = (tBT_SBC_HDR *)GKI_dequeue(&(btif_media_cb.RxSbcQ));
btc_media_task_handle_inc_media(p_msg);
p_msg = (tBT_SBC_HDR *)GKI_dequeue(&(btc_media_cb.RxSbcQ));
if ( p_msg == NULL ) {
APPL_TRACE_ERROR("Insufficient data in que ");
break;
@ -668,66 +663,66 @@ static void btif_media_task_avk_data_ready(UNUSED_ATTR void *context)
}
}
#else
static void btif_media_task_avk_data_ready(UNUSED_ATTR void *context) {}
static void btc_media_task_avk_data_ready(UNUSED_ATTR void *context) {}
#endif
static void btif_media_thread_init(UNUSED_ATTR void *context)
static void btc_media_thread_init(UNUSED_ATTR void *context)
{
memset(&btif_media_cb, 0, sizeof(btif_media_cb));
memset(&btc_media_cb, 0, sizeof(btc_media_cb));
LOG_INFO("media thread init\n");
btif_media_cb.av_sm_hdl = btc_av_get_sm_handle();
btc_media_cb.av_sm_hdl = btc_av_get_sm_handle();
raise_priority_a2dp(TASK_HIGH_MEDIA);
media_task_running = MEDIA_TASK_STATE_ON;
}
static void btif_media_thread_cleanup(UNUSED_ATTR void *context)
static void btc_media_thread_cleanup(UNUSED_ATTR void *context)
{
/* make sure no channels are restarted while shutting down */
media_task_running = MEDIA_TASK_STATE_SHUTTING_DOWN;
btif_media_cb.data_channel_open = FALSE;
btc_media_cb.data_channel_open = FALSE;
/* Clear media task flag */
media_task_running = MEDIA_TASK_STATE_OFF;
}
/*******************************************************************************
**
** Function btif_media_flush_q
** Function btc_media_flush_q
**
** Description
**
** Returns void
**
*******************************************************************************/
static void btif_media_flush_q(BUFFER_Q *p_q)
static void btc_media_flush_q(BUFFER_Q *p_q)
{
while (!GKI_queue_is_empty(p_q)) {
GKI_freebuf(GKI_dequeue(p_q));
}
}
static void btif_media_thread_handle_cmd(fixed_queue_t *queue)
static void btc_media_thread_handle_cmd(fixed_queue_t *queue)
{
BT_HDR *p_msg;
while (!fixed_queue_is_empty(queue)) {
p_msg = (BT_HDR *)fixed_queue_dequeue(queue);
LOG_VERBOSE("btif_media_thread_handle_cmd : %d %s\n", p_msg->event,
LOG_VERBOSE("btc_media_thread_handle_cmd : %d %s\n", p_msg->event,
dump_media_event(p_msg->event));
switch (p_msg->event) {
#if (BTA_AV_INCLUDED == TRUE)
case BTIF_MEDIA_AUDIO_SINK_CFG_UPDATE:
case BTC_MEDIA_AUDIO_SINK_CFG_UPDATE:
#if (BTA_AV_SINK_INCLUDED == TRUE)
btif_media_task_aa_handle_decoder_reset(p_msg);
btc_media_task_aa_handle_decoder_reset(p_msg);
#endif
break;
case BTIF_MEDIA_AUDIO_SINK_CLEAR_TRACK:
case BTC_MEDIA_AUDIO_SINK_CLEAR_TRACK:
#if (BTA_AV_SINK_INCLUDED == TRUE)
btif_media_task_aa_handle_clear_track();
btc_media_task_aa_handle_clear_track();
#endif
break;
case BTIF_MEDIA_FLUSH_AA_RX:
btif_media_task_aa_rx_flush();
case BTC_MEDIA_FLUSH_AA_RX:
btc_media_task_aa_rx_flush();
break;
#endif
default:
@ -742,14 +737,14 @@ static void btif_media_thread_handle_cmd(fixed_queue_t *queue)
#if (BTA_AV_SINK_INCLUDED == TRUE)
/*******************************************************************************
**
** Function btif_media_task_handle_inc_media
** Function btc_media_task_handle_inc_media
**
** Description
**
** Returns void
**
*******************************************************************************/
static void btif_media_task_handle_inc_media(tBT_SBC_HDR *p_msg)
static void btc_media_task_handle_inc_media(tBT_SBC_HDR *p_msg)
{
UINT8 *sbc_start_frame = ((UINT8 *)(p_msg + 1) + p_msg->offset + 1);
int count;
@ -760,13 +755,13 @@ static void btif_media_task_handle_inc_media(tBT_SBC_HDR *p_msg)
UINT32 sbc_frame_len = p_msg->len - 1;
availPcmBytes = 2 * sizeof(pcmData);
if ((btif_media_cb.peer_sep == AVDT_TSEP_SNK) || (btif_media_cb.rx_flush)) {
if ((btc_media_cb.peer_sep == AVDT_TSEP_SNK) || (btc_media_cb.rx_flush)) {
APPL_TRACE_DEBUG(" State Changed happened in this tick ");
return;
}
// ignore data if no one is listening
if (!btif_media_cb.data_channel_open) {
if (!btc_media_cb.data_channel_open) {
return;
}
@ -790,7 +785,7 @@ static void btif_media_task_handle_inc_media(tBT_SBC_HDR *p_msg)
// LOG_ERROR("pre-send: %d\n", availPcmBytes);
// UIPC_Send(UIPC_CH_ID_AV_AUDIO, 0, (UINT8 *)pcmData, (2 * sizeof(pcmData) - availPcmBytes));
BTIF_A2D_DATA_CB_TO_APP((const uint8_t *)pcmData, (2 * sizeof(pcmData) - availPcmBytes));
BTC_A2D_DATA_CB_TO_APP((const uint8_t *)pcmData, (2 * sizeof(pcmData) - availPcmBytes));
}
#endif
@ -799,18 +794,18 @@ static void btif_media_task_handle_inc_media(tBT_SBC_HDR *p_msg)
/*******************************************************************************
**
** Function btif_media_task_aa_rx_flush_req
** Function btc_media_task_aa_rx_flush_req
**
** Description
**
** Returns TRUE is success
**
*******************************************************************************/
BOOLEAN btif_media_task_aa_rx_flush_req(void)
BOOLEAN btc_media_task_aa_rx_flush_req(void)
{
BT_HDR *p_buf;
if (GKI_queue_is_empty(&(btif_media_cb.RxSbcQ)) == TRUE) { /* Que is already empty */
if (GKI_queue_is_empty(&(btc_media_cb.RxSbcQ)) == TRUE) { /* Que is already empty */
return TRUE;
}
@ -818,31 +813,31 @@ BOOLEAN btif_media_task_aa_rx_flush_req(void)
return FALSE;
}
p_buf->event = BTIF_MEDIA_FLUSH_AA_RX;
p_buf->event = BTC_MEDIA_FLUSH_AA_RX;
fixed_queue_enqueue(btif_media_cmd_msg_queue, p_buf);
btif_media_task_post(SIG_MEDIA_TASK_CMD_READY);
fixed_queue_enqueue(btc_media_cmd_msg_queue, p_buf);
btc_media_task_post(SIG_MEDIA_TASK_CMD_READY);
return TRUE;
}
/*******************************************************************************
**
** Function btif_media_task_aa_rx_flush
** Function btc_media_task_aa_rx_flush
**
** Description
**
** Returns void
**
*******************************************************************************/
static void btif_media_task_aa_rx_flush(void)
static void btc_media_task_aa_rx_flush(void)
{
/* Flush all enqueued GKI SBC buffers (encoded) */
APPL_TRACE_DEBUG("btif_media_task_aa_rx_flush");
APPL_TRACE_DEBUG("btc_media_task_aa_rx_flush");
btif_media_flush_q(&(btif_media_cb.RxSbcQ));
btc_media_flush_q(&(btc_media_cb.RxSbcQ));
}
int btif_a2dp_get_track_frequency(UINT8 frequency)
int btc_a2dp_get_track_frequency(UINT8 frequency)
{
int freq = 48000;
switch (frequency) {
@ -862,7 +857,7 @@ int btif_a2dp_get_track_frequency(UINT8 frequency)
return freq;
}
int btif_a2dp_get_track_channel_count(UINT8 channeltype)
int btc_a2dp_get_track_channel_count(UINT8 channeltype)
{
int count = 1;
switch (channeltype) {
@ -878,30 +873,30 @@ int btif_a2dp_get_track_channel_count(UINT8 channeltype)
return count;
}
void btif_a2dp_set_peer_sep(UINT8 sep)
void btc_a2dp_set_peer_sep(UINT8 sep)
{
btif_media_cb.peer_sep = sep;
btc_media_cb.peer_sep = sep;
}
#if (BTA_AV_SINK_INCLUDED == TRUE)
static void btif_media_task_aa_handle_clear_track (void)
static void btc_media_task_aa_handle_clear_track (void)
{
APPL_TRACE_DEBUG("btif_media_task_aa_handle_clear_track");
APPL_TRACE_DEBUG("btc_media_task_aa_handle_clear_track");
}
/*******************************************************************************
**
** Function btif_media_task_aa_handle_decoder_reset
** Function btc_media_task_aa_handle_decoder_reset
**
** Description
**
** Returns void
**
*******************************************************************************/
static void btif_media_task_aa_handle_decoder_reset(BT_HDR *p_msg)
static void btc_media_task_aa_handle_decoder_reset(BT_HDR *p_msg)
{
tBTIF_MEDIA_SINK_CFG_UPDATE *p_buf = (tBTIF_MEDIA_SINK_CFG_UPDATE *) p_msg;
tBTC_MEDIA_SINK_CFG_UPDATE *p_buf = (tBTC_MEDIA_SINK_CFG_UPDATE *) p_msg;
tA2D_STATUS a2d_status;
tA2D_SBC_CIE sbc_cie;
OI_STATUS status;
@ -909,7 +904,7 @@ static void btif_media_task_aa_handle_decoder_reset(BT_HDR *p_msg)
UINT32 num_blocks = 16;
UINT32 num_subbands = 8;
APPL_TRACE_EVENT("btif_media_task_aa_handle_decoder_reset p_codec_info[%x:%x:%x:%x:%x:%x]\n",
APPL_TRACE_EVENT("btc_media_task_aa_handle_decoder_reset p_codec_info[%x:%x:%x:%x:%x:%x]\n",
p_buf->codec_info[1], p_buf->codec_info[2], p_buf->codec_info[3],
p_buf->codec_info[4], p_buf->codec_info[5], p_buf->codec_info[6]);
@ -919,17 +914,17 @@ static void btif_media_task_aa_handle_decoder_reset(BT_HDR *p_msg)
return;
}
btif_media_cb.sample_rate = btif_a2dp_get_track_frequency(sbc_cie.samp_freq);
btif_media_cb.channel_count = btif_a2dp_get_track_channel_count(sbc_cie.ch_mode);
btc_media_cb.sample_rate = btc_a2dp_get_track_frequency(sbc_cie.samp_freq);
btc_media_cb.channel_count = btc_a2dp_get_track_channel_count(sbc_cie.ch_mode);
btif_media_cb.rx_flush = FALSE;
btc_media_cb.rx_flush = FALSE;
APPL_TRACE_EVENT("Reset to sink role");
status = OI_CODEC_SBC_DecoderReset(&context, contextData, sizeof(contextData), 2, 2, FALSE);
if (!OI_SUCCESS(status)) {
APPL_TRACE_ERROR("OI_CODEC_SBC_DecoderReset failed with error code %d\n", status);
}
btif_media_cb.data_channel_open = TRUE;
btc_media_cb.data_channel_open = TRUE;
switch (sbc_cie.samp_freq) {
case A2D_SBC_IE_SAMP_FREQ_16:
@ -1021,59 +1016,59 @@ static void btif_media_task_aa_handle_decoder_reset(BT_HDR *p_msg)
APPL_TRACE_EVENT("\tBit pool Min:%d Max:%d\n", sbc_cie.min_bitpool, sbc_cie.max_bitpool);
btif_media_cb.frames_to_process = ((freq_multiple) / (num_blocks * num_subbands)) + 1;
APPL_TRACE_EVENT(" Frames to be processed in 20 ms %d\n", btif_media_cb.frames_to_process);
btc_media_cb.frames_to_process = ((freq_multiple) / (num_blocks * num_subbands)) + 1;
APPL_TRACE_EVENT(" Frames to be processed in 20 ms %d\n", btc_media_cb.frames_to_process);
}
#endif
/*******************************************************************************
**
** Function btif_media_sink_enque_buf
** Function btc_media_sink_enque_buf
**
** Description This function is called by the av_co to fill A2DP Sink Queue
**
**
** Returns size of the queue
*******************************************************************************/
UINT8 btif_media_sink_enque_buf(BT_HDR *p_pkt)
UINT8 btc_media_sink_enque_buf(BT_HDR *p_pkt)
{
tBT_SBC_HDR *p_msg;
if (btif_media_cb.rx_flush == TRUE) { /* Flush enabled, do not enque*/
return GKI_queue_length(&btif_media_cb.RxSbcQ);
if (btc_media_cb.rx_flush == TRUE) { /* Flush enabled, do not enque*/
return GKI_queue_length(&btc_media_cb.RxSbcQ);
}
if (GKI_queue_length(&btif_media_cb.RxSbcQ) == MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ) {
GKI_freebuf(GKI_dequeue(&(btif_media_cb.RxSbcQ)));
if (GKI_queue_length(&btc_media_cb.RxSbcQ) == MAX_OUTPUT_A2DP_FRAME_QUEUE_SZ) {
GKI_freebuf(GKI_dequeue(&(btc_media_cb.RxSbcQ)));
}
BTIF_TRACE_VERBOSE("btif_media_sink_enque_buf + ");
LOG_VERBOSE("btc_media_sink_enque_buf + ");
/* allocate and Queue this buffer */
if ((p_msg = (tBT_SBC_HDR *) GKI_getbuf(sizeof(tBT_SBC_HDR) +
p_pkt->offset + p_pkt->len)) != NULL) {
memcpy(p_msg, p_pkt, (sizeof(BT_HDR) + p_pkt->offset + p_pkt->len));
p_msg->num_frames_to_be_processed = (*((UINT8 *)(p_msg + 1) + p_msg->offset)) & 0x0f;
BTIF_TRACE_VERBOSE("btif_media_sink_enque_buf %d + \n", p_msg->num_frames_to_be_processed);
GKI_enqueue(&(btif_media_cb.RxSbcQ), p_msg);
btif_media_task_post(SIG_MEDIA_TASK_AVK_DATA_READY);
LOG_VERBOSE("btc_media_sink_enque_buf %d + \n", p_msg->num_frames_to_be_processed);
GKI_enqueue(&(btc_media_cb.RxSbcQ), p_msg);
btc_media_task_post(SIG_MEDIA_TASK_AVK_DATA_READY);
} else {
/* let caller deal with a failed allocation */
BTIF_TRACE_VERBOSE("btif_media_sink_enque_buf No Buffer left - ");
LOG_VERBOSE("btc_media_sink_enque_buf No Buffer left - ");
}
return GKI_queue_length(&btif_media_cb.RxSbcQ);
return GKI_queue_length(&btc_media_cb.RxSbcQ);
}
/*******************************************************************************
**
** Function btif_media_aa_readbuf
** Function btc_media_aa_readbuf
**
** Description This function is called by the av_co to get the next buffer to send
**
**
** Returns void
*******************************************************************************/
BT_HDR *btif_media_aa_readbuf(void)
BT_HDR *btc_media_aa_readbuf(void)
{
return NULL;
}

View File

@ -25,7 +25,7 @@
#include "avrc_defs.h"
#include "gki.h"
#include "btif_common.h"
#include "btc_common.h"
#include "btif_util.h"
#include "btc_av.h"
#include "btc_avrc.h"
@ -207,7 +207,7 @@ extern BOOLEAN btc_hf_call_terminated_recently();
******************************************************************************/
void send_key (int fd, uint16_t key, int pressed)
{
BTIF_TRACE_DEBUG("%s fd:%d key:%u pressed:%d, func not implemented", __FUNCTION__,
LOG_DEBUG("%s fd:%d key:%u pressed:%d, func not implemented", __FUNCTION__,
fd, key, pressed);
return;
@ -243,7 +243,7 @@ static void handle_rc_features()
LOG_DEBUG("%s: rc_features=0x%x", __FUNCTION__, rc_features);
// todo: uncomment the following line when added the AVRC target role
// HAL_CBACK(bt_rc_callbacks, remote_features_cb, &rc_addr, rc_features)
// BTC_HAL_CBACK(bt_rc_callbacks, remote_features_cb, &rc_addr, rc_features)
#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
LOG_DEBUG("Checking for feature flags in btc_rc_handler with label %d",
@ -464,7 +464,7 @@ static void handle_rc_passthrough_cmd ( tBTA_AV_REMOTE_CMD *p_remote_cmd)
#ifdef BTC_HF_INCLUDED
&& (btc_hf_call_terminated_recently() == TRUE)
#endif
#if 0 // temporary hack since no btif_storage module is not ported for now
#if 0 // temporary hack since no btc_storage module is not ported for now
&& (check_cod( (const bt_bdaddr_t*)&(btc_rc_vb.rc_addr), COD_AV_HEADSETS) != TRUE)
#endif
)
@ -475,7 +475,7 @@ static void handle_rc_passthrough_cmd ( tBTA_AV_REMOTE_CMD *p_remote_cmd)
}
if (p_remote_cmd->rc_id == BTA_AV_RC_FAST_FOR || p_remote_cmd->rc_id == BTA_AV_RC_REWIND) {
HAL_CBACK(bt_rc_callbacks, passthrough_cmd_cb, p_remote_cmd->rc_id, pressed);
BTC_HAL_CBACK(bt_rc_callbacks, passthrough_cmd_cb, p_remote_cmd->rc_id, pressed);
return;
}
@ -966,7 +966,7 @@ static void btc_rc_upstreams_evt(UINT16 event, tAVRC_COMMAND *pavrc_cmd, UINT8 c
case AVRC_PDU_GET_PLAY_STATUS:
{
FILL_PDU_QUEUE(IDX_GET_PLAY_STATUS_RSP, ctype, label, TRUE)
HAL_CBACK(bt_rc_callbacks, get_play_status_cb);
BTC_HAL_CBACK(bt_rc_callbacks, get_play_status_cb);
}
break;
case AVRC_PDU_LIST_PLAYER_APP_ATTR:
@ -1033,7 +1033,7 @@ static void btc_rc_upstreams_evt(UINT16 event, tAVRC_COMMAND *pavrc_cmd, UINT8 c
}
}
FILL_PDU_QUEUE(IDX_GET_ELEMENT_ATTR_RSP, ctype, label, TRUE);
HAL_CBACK(bt_rc_callbacks, get_element_attr_cb, num_attr, element_attrs);
BTC_HAL_CBACK(bt_rc_callbacks, get_element_attr_cb, num_attr, element_attrs);
}
break;
case AVRC_PDU_REGISTER_NOTIFICATION:
@ -1048,7 +1048,7 @@ static void btc_rc_upstreams_evt(UINT16 event, tAVRC_COMMAND *pavrc_cmd, UINT8 c
btc_rc_vb.rc_notif[BTRC_EVT_PLAY_POS_CHANGED - 1].bNotify = FALSE;
return;
}
HAL_CBACK(bt_rc_callbacks, register_notification_cb, pavrc_cmd->reg_notif.event_id,
BTC_HAL_CBACK(bt_rc_callbacks, register_notification_cb, pavrc_cmd->reg_notif.event_id,
pavrc_cmd->reg_notif.param);
}
break;
@ -1099,7 +1099,7 @@ static void btc_rc_upstreams_rsp_evt(UINT16 event, tAVRC_RESPONSE *pavrc_resp, U
{
if(AVRC_RSP_CHANGED==ctype)
btc_rc_vb.rc_volume=pavrc_resp->reg_notif.param.volume;
HAL_CBACK(bt_rc_callbacks, volume_change_cb, pavrc_resp->reg_notif.param.volume,ctype)
BTC_HAL_CBACK(bt_rc_callbacks, volume_change_cb, pavrc_resp->reg_notif.param.volume,ctype)
}
break;
@ -1109,7 +1109,7 @@ static void btc_rc_upstreams_rsp_evt(UINT16 event, tAVRC_RESPONSE *pavrc_resp, U
pavrc_resp->volume.volume,ctype);
if(AVRC_RSP_ACCEPT==ctype)
btc_rc_vb.rc_volume=pavrc_resp->volume.volume;
HAL_CBACK(bt_rc_callbacks,volume_change_cb,pavrc_resp->volume.volume,ctype)
BTC_HAL_CBACK(bt_rc_callbacks,volume_change_cb,pavrc_resp->volume.volume,ctype)
}
break;

View File

@ -27,7 +27,8 @@
#include "esp_a2dp_api.h"
#include "btc_task.h"
#include "btif_common.h"
// #include "btif_common.h"
#include "btc_common.h"
#include "btc_sm.h"
#include "bta_av_api.h"

View File

@ -1,68 +1,60 @@
/******************************************************************************
*
* Copyright (C) 2009-2012 Broadcom Corporation
*
* 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.
*
******************************************************************************/
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// 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.
/*******************************************************************************
*
* Filename: btif_media.h
* Filename: btc_media.h
*
* Description: This is the audio module for the BTIF system.
*
*******************************************************************************/
#ifndef BTIF_MEDIA_H
#define BTIF_MEDIA_H
#ifndef __BTC_MEDIA_H__
#define __BTC_MEDIA_H__
#include <stdbool.h>
#include "bta_api.h"
#include "gki.h"
#include "btif_av_api.h"
// #include "audio_a2dp_hw.h"
/*******************************************************************************
** Constants
*******************************************************************************/
/* Generic part */
#define BTIF_SUCCESS 0
#define BTC_SUCCESS (0)
/**
* AV (Audio Video source) Errors
*/
#define BTIF_ERROR_SRV_AV_NOT_ENABLED 700 /* AV is not enabled */
#define BTIF_ERROR_SRV_AV_FEEDING_NOT_SUPPORTED 701 /* Requested Feeding not supported */
#define BTIF_ERROR_SRV_AV_BUSY 702 /* Another operation ongoing */
#define BTIF_ERROR_SRV_AV_NOT_OPENED 703 /* No AV link opened */
#define BTIF_ERROR_SRV_AV_NOT_STARTED 704 /* AV is not started */
#define BTIF_ERROR_SRV_AV_CP_NOT_SUPPORTED 705 /* Content protection is not supported by all headsets */
#define BTC_ERROR_SRV_AV_NOT_ENABLED 700 /* AV is not enabled */
#define BTC_ERROR_SRV_AV_FEEDING_NOT_SUPPORTED 701 /* Requested Feeding not supported */
#define BTC_ERROR_SRV_AV_BUSY 702 /* Another operation ongoing */
#define BTC_ERROR_SRV_AV_NOT_OPENED 703 /* No AV link opened */
#define BTC_ERROR_SRV_AV_NOT_STARTED 704 /* AV is not started */
#define BTC_ERROR_SRV_AV_CP_NOT_SUPPORTED 705 /* Content protection is not supported by all headsets */
/* Transcoding definition for TxTranscoding and RxTranscoding */
#define BTIF_MEDIA_TRSCD_OFF 0
#define BTIF_MEDIA_TRSCD_PCM_2_SBC 1 /* Tx */
#define BTC_MEDIA_TRSCD_OFF 0
#define BTC_MEDIA_TRSCD_PCM_2_SBC 1 /* Tx */
/*******************************************************************************
** Data types
*******************************************************************************/
typedef int tBTIF_STATUS;
typedef int tBTC_STATUS;
/* tBTIF_MEDIA_INIT_AUDIO msg structure */
/* tBTC_MEDIA_INIT_AUDIO msg structure */
typedef struct {
BT_HDR hdr;
UINT16 SamplingFreq; /* 16k, 32k, 44.1k or 48k*/
@ -71,28 +63,28 @@ typedef struct {
UINT8 NumOfBlocks; /* 4, 8, 12 or 16*/
UINT8 AllocationMethod; /* loudness or SNR*/
UINT16 MtuSize; /* peer mtu size */
} tBTIF_MEDIA_INIT_AUDIO;
} tBTC_MEDIA_INIT_AUDIO;
#if (BTA_AV_INCLUDED == TRUE)
/* tBTIF_MEDIA_UPDATE_AUDIO msg structure */
/* tBTC_MEDIA_UPDATE_AUDIO msg structure */
typedef struct {
BT_HDR hdr;
UINT16 MinMtuSize; /* Minimum peer mtu size */
UINT8 MaxBitPool; /* Maximum peer bitpool */
UINT8 MinBitPool; /* Minimum peer bitpool */
} tBTIF_MEDIA_UPDATE_AUDIO;
} tBTC_MEDIA_UPDATE_AUDIO;
/* tBTIF_MEDIA_INIT_AUDIO_FEEDING msg structure */
/* tBTC_MEDIA_INIT_AUDIO_FEEDING msg structure */
typedef struct {
BT_HDR hdr;
tBTIF_AV_FEEDING_MODE feeding_mode;
tBTIF_AV_MEDIA_FEEDINGS feeding;
} tBTIF_MEDIA_INIT_AUDIO_FEEDING;
} tBTC_MEDIA_INIT_AUDIO_FEEDING;
typedef struct {
BT_HDR hdr;
UINT8 codec_info[AVDT_CODEC_SIZE];
} tBTIF_MEDIA_SINK_CFG_UPDATE;
} tBTC_MEDIA_SINK_CFG_UPDATE;
#endif
/*******************************************************************************
@ -108,22 +100,22 @@ typedef struct {
** Returns void
**
*******************************************************************************/
extern void btif_media_task(void);
extern void btc_media_task(void);
/*******************************************************************************
**
** Function btif_media_task_enc_init_req
** Function btc_media_task_enc_init_req
**
** Description Request to initialize the media task encoder
**
** Returns TRUE is success
**
*******************************************************************************/
extern BOOLEAN btif_media_task_enc_init_req(tBTIF_MEDIA_INIT_AUDIO *p_msg);
extern BOOLEAN btc_media_task_enc_init_req(tBTC_MEDIA_INIT_AUDIO *p_msg);
/*******************************************************************************
**
** Function btif_media_task_enc_update_req
** Function btc_media_task_enc_update_req
**
** Description Request to update the media task encoder
**
@ -131,103 +123,103 @@ extern BOOLEAN btif_media_task_enc_init_req(tBTIF_MEDIA_INIT_AUDIO *p_msg);
**
*******************************************************************************/
#if (BTA_AV_INCLUDED == TRUE)
extern BOOLEAN btif_media_task_enc_update_req(tBTIF_MEDIA_UPDATE_AUDIO *p_msg);
extern BOOLEAN btc_media_task_enc_update_req(tBTC_MEDIA_UPDATE_AUDIO *p_msg);
#endif
/*******************************************************************************
**
** Function btif_media_task_start_aa_req
** Function btc_media_task_start_aa_req
**
** Description Request to start audio encoding task
**
** Returns TRUE is success
**
*******************************************************************************/
extern BOOLEAN btif_media_task_start_aa_req(void);
extern BOOLEAN btc_media_task_start_aa_req(void);
/*******************************************************************************
**
** Function btif_media_task_stop_aa_req
** Function btc_media_task_stop_aa_req
**
** Description Request to stop audio encoding task
**
** Returns TRUE is success
**
*******************************************************************************/
extern BOOLEAN btif_media_task_stop_aa_req(void);
extern BOOLEAN btc_media_task_stop_aa_req(void);
/*******************************************************************************
**
** Function btif_media_task_aa_rx_flush_req
** Function btc_media_task_aa_rx_flush_req
**
** Description Request to flush audio decoding pipe
**
** Returns TRUE is success
**
*******************************************************************************/
extern BOOLEAN btif_media_task_aa_rx_flush_req(void);
extern BOOLEAN btc_media_task_aa_rx_flush_req(void);
/*******************************************************************************
**
** Function btif_media_task_aa_tx_flush_req
** Function btc_media_task_aa_tx_flush_req
**
** Description Request to flush audio encoding pipe
**
** Returns TRUE is success
**
*******************************************************************************/
extern BOOLEAN btif_media_task_aa_tx_flush_req(void);
extern BOOLEAN btc_media_task_aa_tx_flush_req(void);
/*******************************************************************************
**
** Function btif_media_aa_readbuf
** Function btc_media_aa_readbuf
**
** Description Read an audio GKI buffer from the BTIF media TX queue
**
** Returns pointer on a GKI aa buffer ready to send
**
*******************************************************************************/
extern BT_HDR *btif_media_aa_readbuf(void);
extern BT_HDR *btc_media_aa_readbuf(void);
/*******************************************************************************
**
** Function btif_media_sink_enque_buf
** Function btc_media_sink_enque_buf
**
** Description This function is called by the av_co to fill A2DP Sink Queue
**
**
** Returns size of the queue
*******************************************************************************/
UINT8 btif_media_sink_enque_buf(BT_HDR *p_buf);
UINT8 btc_media_sink_enque_buf(BT_HDR *p_buf);
/*******************************************************************************
**
** Function btif_media_aa_writebuf
** Function btc_media_aa_writebuf
**
** Description Enqueue a Advance Audio media GKI buffer to be processed by btif media task.
**
** Returns TRUE is success
**
*******************************************************************************/
extern void btif_media_aa_writebuf(BT_HDR *pBuf, UINT32 timestamp, UINT16 seq_num);
extern void btc_media_aa_writebuf(BT_HDR *pBuf, UINT32 timestamp, UINT16 seq_num);
/*******************************************************************************
**
** Function btif_media_av_writebuf
** Function btc_media_av_writebuf
**
** Description Enqueue a video media GKI buffer to be processed by btif media task.
**
** Returns TRUE is success
**
*******************************************************************************/
extern BOOLEAN btif_media_av_writebuf(UINT8 *p_media, UINT32 media_len,
extern BOOLEAN btc_media_av_writebuf(UINT8 *p_media, UINT32 media_len,
UINT32 timestamp, UINT16 seq_num);
#if (BTA_AV_INCLUDED == TRUE)
/*******************************************************************************
**
** Function btif_media_task_audio_feeding_init_req
** Function btc_media_task_audio_feeding_init_req
**
** Description Request to initialize audio feeding
**
@ -235,7 +227,7 @@ extern BOOLEAN btif_media_av_writebuf(UINT8 *p_media, UINT32 media_len,
**
*******************************************************************************/
extern BOOLEAN btif_media_task_audio_feeding_init_req(tBTIF_MEDIA_INIT_AUDIO_FEEDING *p_msg);
extern BOOLEAN btc_media_task_audio_feeding_init_req(tBTC_MEDIA_INIT_AUDIO_FEEDING *p_msg);
#endif
/*******************************************************************************
@ -253,23 +245,23 @@ extern void dump_codec_info(unsigned char *p_codec);
* Local adaptation helper functions between btif and media task
*/
bool btif_a2dp_start_media_task(void);
void btif_a2dp_stop_media_task(void);
bool btc_a2dp_start_media_task(void);
void btc_a2dp_stop_media_task(void);
void btif_a2dp_on_init(void);
void btif_a2dp_setup_codec(void);
void btif_a2dp_on_idle(void);
BOOLEAN btif_a2dp_on_started(tBTA_AV_START *p_av, BOOLEAN pending_start);
void btif_a2dp_on_stop_req(void);
void btif_a2dp_on_stopped(tBTA_AV_SUSPEND *p_av);
void btif_a2dp_on_suspend(void);
void btif_a2dp_on_suspended(tBTA_AV_SUSPEND *p_av);
void btif_a2dp_set_rx_flush(BOOLEAN enable);
void btif_media_check_iop_exceptions(UINT8 *peer_bda);
void btif_reset_decoder(UINT8 *p_av);
void btc_a2dp_on_init(void);
void btc_a2dp_setup_codec(void);
void btc_a2dp_on_idle(void);
BOOLEAN btc_a2dp_on_started(tBTA_AV_START *p_av, BOOLEAN pending_start);
void btc_a2dp_on_stop_req(void);
void btc_a2dp_on_stopped(tBTA_AV_SUSPEND *p_av);
void btc_a2dp_on_suspend(void);
void btc_a2dp_on_suspended(tBTA_AV_SUSPEND *p_av);
void btc_a2dp_set_rx_flush(BOOLEAN enable);
void btc_media_check_iop_exceptions(UINT8 *peer_bda);
void btc_reset_decoder(UINT8 *p_av);
int btif_a2dp_get_track_frequency(UINT8 frequency);
int btif_a2dp_get_track_channel_count(UINT8 channeltype);
void btif_a2dp_set_peer_sep(UINT8 sep);
int btc_a2dp_get_track_frequency(UINT8 frequency);
int btc_a2dp_get_track_channel_count(UINT8 channeltype);
void btc_a2dp_set_peer_sep(UINT8 sep);
#endif

View File

@ -31,7 +31,7 @@
#include "bta_av_co.h"
#include "bta_av_ci.h"
#include "bta_av_sbc.h"
#include "btif_media.h"
#include "btc_media.h"
#include "btif_av_co.h"
#include "btif_util.h"
@ -956,7 +956,7 @@ void *bta_av_co_audio_src_data_path(tBTA_AV_CODEC codec_type, UINT32 *p_len,
FUNC_TRACE();
p_buf = btif_media_aa_readbuf();
p_buf = btc_media_aa_readbuf();
if (p_buf != NULL) {
switch (codec_type) {
case BTA_AV_CODEC_SBC:
@ -1376,7 +1376,7 @@ static BOOLEAN bta_av_co_audio_media_supports_config(UINT8 codec_type, const UIN
** Returns TRUE if all opened devices support this codec, FALSE otherwise
**
*******************************************************************************/
BOOLEAN bta_av_co_audio_codec_supported(tBTIF_STATUS *p_status)
BOOLEAN bta_av_co_audio_codec_supported(tBTC_STATUS *p_status)
{
UINT8 index;
UINT8 snk_index;
@ -1393,7 +1393,7 @@ BOOLEAN bta_av_co_audio_codec_supported(tBTIF_STATUS *p_status)
APPL_TRACE_DEBUG("bta_av_co_audio_codec_supported");
/* Check AV feeding is supported */
*p_status = BTIF_ERROR_SRV_AV_FEEDING_NOT_SUPPORTED;
*p_status = BTC_ERROR_SRV_AV_FEEDING_NOT_SUPPORTED;
for (index = 0; index < BTA_AV_CO_NUM_ELEMENTS(bta_av_co_cb.peers); index++) {
p_peer = &bta_av_co_cb.peers[index];
@ -1405,7 +1405,7 @@ BOOLEAN bta_av_co_audio_codec_supported(tBTIF_STATUS *p_status)
if (!bta_av_co_audio_sink_supports_cp(p_sink)) {
APPL_TRACE_DEBUG("bta_av_co_audio_codec_supported sink %d of peer %d doesn't support cp",
snk_index, index);
*p_status = BTIF_ERROR_SRV_AV_CP_NOT_SUPPORTED;
*p_status = BTC_ERROR_SRV_AV_CP_NOT_SUPPORTED;
return FALSE;
}
@ -1446,7 +1446,7 @@ BOOLEAN bta_av_co_audio_codec_supported(tBTIF_STATUS *p_status)
}
}
*p_status = BTIF_SUCCESS;
*p_status = BTC_SUCCESS;
return TRUE;
}
@ -1485,7 +1485,7 @@ void bta_av_co_audio_codec_reset(void)
** Returns TRUE if successful, FALSE otherwise
**
*******************************************************************************/
BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTIF_STATUS *p_status)
BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTC_STATUS *p_status)
{
tA2D_SBC_CIE sbc_config;
tBTIF_AV_CODEC_INFO new_cfg;
@ -1493,7 +1493,7 @@ BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTI
FUNC_TRACE();
/* Check AV feeding is supported */
*p_status = BTIF_ERROR_SRV_AV_FEEDING_NOT_SUPPORTED;
*p_status = BTC_ERROR_SRV_AV_FEEDING_NOT_SUPPORTED;
APPL_TRACE_DEBUG("bta_av_co_audio_set_codec cid=%d", p_feeding->format);
@ -1552,7 +1552,7 @@ BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTI
/* Check all devices support it */
*p_status = BTIF_SUCCESS;
*p_status = BTC_SUCCESS;
return bta_av_co_audio_codec_supported(p_status);
}

View File

@ -33,7 +33,7 @@
#include "bta_av_api.h"
// #include "uipc.h"
#include "btif_media.h"
#include "btc_media.h"
#include "a2d_api.h"
#include "a2d_sbc.h"

View File

@ -19,7 +19,7 @@
#ifndef BTIF_AV_CO_H
#define BTIF_AV_CO_H
#include "btif_media.h"
#include "btc_media.h"
/*******************************************************************************
** Constants & Macros
@ -96,7 +96,7 @@ void bta_av_co_audio_codec_reset(void);
** Returns TRUE if all opened devices support this codec, FALSE otherwise
**
*******************************************************************************/
BOOLEAN bta_av_co_audio_codec_supported(tBTIF_STATUS *p_status);
BOOLEAN bta_av_co_audio_codec_supported(tBTC_STATUS *p_status);
/*******************************************************************************
**
@ -109,7 +109,7 @@ BOOLEAN bta_av_co_audio_codec_supported(tBTIF_STATUS *p_status);
** Returns TRUE if successful, FALSE otherwise
**
*******************************************************************************/
BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTIF_STATUS *p_status);
BOOLEAN bta_av_co_audio_set_codec(const tBTIF_AV_MEDIA_FEEDINGS *p_feeding, tBTC_STATUS *p_status);
/*******************************************************************************
**