#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"
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); \
} \
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, ¶m);
+ BTC_A2D_CB_TO_APP(ESP_A2D_CONNECTION_STATE_EVT, ¶m);
}
static void btc_report_audio_state(esp_a2d_audio_state_t state, bt_bdaddr_t *bd_addr)
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, ¶m);
+ BTC_A2D_CB_TO_APP(ESP_A2D_AUDIO_STATE_EVT, ¶m);
}
/*****************************************************************************
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:
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 );
esp_a2d_cb_param_t param;
memcpy(param.audio_cfg.remote_bda, &btc_av_cb.peer_bda, sizeof(esp_bd_addr_t));
memcpy(¶m.audio_cfg.mcc, p_data, sizeof(esp_a2d_mcc_t));
- BTIF_A2D_CB_TO_APP(ESP_A2D_AUDIO_CFG_EVT, ¶m);
+ BTC_A2D_CB_TO_APP(ESP_A2D_AUDIO_CFG_EVT, ¶m);
}
} break;
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:
}
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 */
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 */
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;
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);
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) {
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));
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 */
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;
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);
**
** Function btc_av_init
**
-** Description Initializes btif AV if not already done
+** Description Initializes btc AV if not already done
**
** Returns bt_status_t
**
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;
}
btc_dm_enable_service(BTA_A2DP_SINK_SERVICE_ID);
#endif
- btif_a2dp_on_init();
+ btc_a2dp_on_init();
}
return BT_STATUS_SUCCESS;
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;
}
{
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 */
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;
**
** 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
******************************************************************************/
-/******************************************************************************
- *
- * 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
**
#include "l2c_api.h"
#include "btif_av_co.h"
-#include "btif_media.h"
+#include "btc_media.h"
#include "alarm.h"
#include "bt_trace.h"
#endif
#include "stdio.h"
-#include "btif_media.h"
#include "allocator.h"
#include "bt_utils.h"
#include "esp_a2dp_api.h"
#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 {
};
/* 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
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)
UINT8 channel_count;
#endif
-} tBTIF_MEDIA_CB;
+} tBTC_MEDIA_CB;
typedef struct {
long long rx;
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;
}
// 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); \
} \
/*****************************************************************************
** 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;
}
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";
}
/*****************************************************************************
- ** 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) {
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);
}
}
-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");
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");
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
**
**
*******************************************************************************/
-void btif_a2dp_on_init(void)
+void btc_a2dp_on_init(void)
{
//tput_mon(1, 0, 1);
}
/*****************************************************************************
**
-** Function btif_a2dp_setup_codec
+** Function btc_a2dp_setup_codec
**
** Description
**
**
*******************************************************************************/
-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");
/*****************************************************************************
**
-** Function btif_a2dp_on_idle
+** Function btc_a2dp_on_idle
**
** Description
**
**
*******************************************************************************/
-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
/*******************************************************************************
**
- ** 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;
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
**
**
*******************************************************************************/
-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
**
**
*******************************************************************************/
-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;
}
}
/*****************************************************************************
**
-** Function btif_a2dp_on_suspended
+** Function btc_a2dp_on_suspended
**
** Description
**
**
*******************************************************************************/
-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;
}
}
#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:
#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;
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;
}
// 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
/*******************************************************************************
**
- ** 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;
}
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) {
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) {
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;
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]);
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:
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;
}
-/******************************************************************************
- *
- * 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*/
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
/*******************************************************************************
** 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
**
**
*******************************************************************************/
#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
**
**
*******************************************************************************/
-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
/*******************************************************************************
* Local adaptation helper functions between btif and media task
*/
-bool btif_a2dp_start_media_task(void);
-void btif_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);
-
-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);
+bool btc_a2dp_start_media_task(void);
+void btc_a2dp_stop_media_task(void);
+
+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 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