📄 aud_bt_a2dp.c
字号:
{
cmd_queue->cmds[1] = cmd0; /* reconfig, start, none */
}
else if (cmd0 == AUD_BT_A2DP_CMD_RECONFIG_STREAM)
{
cmd_queue->cmds[1] = cmd1; /* reconfig, start, none */
}
else if (cmd0 == AUD_BT_A2DP_CMD_CLOSE_STREAM)
{
cmd_queue->cmds[0] = cmd0; /* close, none, none */
}
break;
/* start, none, none */
case AUD_BT_A2DP_CMD_QUEUE_START_STREAM:
if (cmd0 == AUD_BT_A2DP_CMD_ABORT)
{
cmd_queue->cmds[0] = cmd0; /* abort, none, none */
}
else if (cmd0 == AUD_BT_A2DP_CMD_RECONFIG_STREAM)
{
cmd_queue->cmds[0] = cmd0; /* reconfig, start, none */
cmd_queue->cmds[1] = cmd1;
}
else if (cmd0 == AUD_BT_A2DP_CMD_PAUSE_STREAM)
{
cmd_queue->cmds[0] = AUD_BT_A2DP_CMD_NONE; /* none, none, none */
}
else if (cmd0 == AUD_BT_A2DP_CMD_CLOSE_STREAM)
{
cmd_queue->cmds[0] = cmd0; /* close, none, none */
}
break;
/* pause, none, none */
case AUD_BT_A2DP_CMD_QUEUE_PAUSE_STREAM:
if (cmd0 == AUD_BT_A2DP_CMD_ABORT)
{
cmd_queue->cmds[0] = cmd0; /* abort, none, none */
}
else if (cmd0 == AUD_BT_A2DP_CMD_START_STREAM)
{
cmd_queue->cmds[0] = cmd0; /* start, none, none */
}
else if (cmd0 == AUD_BT_A2DP_CMD_RECONFIG_STREAM)
{
cmd_queue->cmds[1] = cmd0; /* pause, reconfig, start */
cmd_queue->cmds[2] = cmd1;
}
else if (cmd0 == AUD_BT_A2DP_CMD_CLOSE_STREAM)
{
cmd_queue->cmds[0] = cmd0; /* close, none, none */
}
break;
/* reconfig, start, none */
case AUD_BT_A2DP_CMD_QUEUE_RECONFIG_START_STREAM:
if (cmd0 == AUD_BT_A2DP_CMD_ABORT)
{
cmd_queue->cmds[0] = cmd0; /* abort, none, none */
cmd_queue->cmds[1] = AUD_BT_A2DP_CMD_NONE;
}
else if (cmd0 == AUD_BT_A2DP_CMD_PAUSE_STREAM)
{
cmd_queue->cmds[1] = AUD_BT_A2DP_CMD_NONE; /* reconfig, none, none */
}
else if (cmd0 == AUD_BT_A2DP_CMD_CLOSE_STREAM)
{
cmd_queue->cmds[0] = cmd0; /* close, none, none */
cmd_queue->cmds[1] = AUD_BT_A2DP_CMD_NONE;
}
break;
/* pause, reconfig, none */
case AUD_BT_A2DP_CMD_QUEUE_PAUSE_RECONFIG_STREAM:
if (cmd0 == AUD_BT_A2DP_CMD_ABORT)
{
cmd_queue->cmds[0] = cmd0; /* abort, none, none */
cmd_queue->cmds[1] = AUD_BT_A2DP_CMD_NONE;
}
else if (cmd0 == AUD_BT_A2DP_CMD_START_STREAM)
{
cmd_queue->cmds[2] = cmd0; /* pause, reconfig, start */
}
else if (cmd0 == AUD_BT_A2DP_CMD_RECONFIG_STREAM)
{
cmd_queue->cmds[2] = cmd1; /* pause, reconfig, start */
}
else if (cmd0 == AUD_BT_A2DP_CMD_CLOSE_STREAM)
{
cmd_queue->cmds[0] = cmd0; /* close, none, none */
cmd_queue->cmds[1] = AUD_BT_A2DP_CMD_NONE;
}
break;
/* pause, reconfig, start */
case AUD_BT_A2DP_CMD_QUEUE_PAUSE_RECONFIG_START_STREAM:
if (cmd0 == AUD_BT_A2DP_CMD_ABORT)
{
cmd_queue->cmds[0] = cmd0; /* abort, none, none */
cmd_queue->cmds[1] = AUD_BT_A2DP_CMD_NONE;
cmd_queue->cmds[2] = AUD_BT_A2DP_CMD_NONE;
}
else if (cmd0 == AUD_BT_A2DP_CMD_PAUSE_STREAM)
{
cmd_queue->cmds[2] = AUD_BT_A2DP_CMD_NONE; /* pause, reconfig, none */
}
else if (cmd0 == AUD_BT_A2DP_CMD_CLOSE_STREAM)
{
cmd_queue->cmds[0] = cmd0; /* close, none, none */
cmd_queue->cmds[1] = AUD_BT_A2DP_CMD_NONE;
cmd_queue->cmds[2] = AUD_BT_A2DP_CMD_NONE;
}
break;
default:
ASSERT(0);
}
/* scan cmds in queue to update count */
for (count = 0; count < 3; count++)
{
if (cmd_queue->cmds[count] == AUD_BT_A2DP_CMD_NONE)
{
break;
}
}
cmd_queue->count = count;
AUD_BT_A2DP_FUNC_TRACE3(AUD_BT_A2DP_CMD_QUEUE_ADD, cmd_queue->cmds[0], cmd_queue->cmds[1], cmd_queue->cmds[2])
}
/*****************************************************************************
* FUNCTION
* aud_bt_a2dp_open_codec
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void aud_bt_a2dp_open_codec(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
ASSERT(aud_bt_a2dp_ctx.codec == NULL);
switch (aud_bt_a2dp_ctx.audio_config.codec_type)
{
case BT_A2DP_SBC:
aud_bt_a2dp_ctx.codec = SBC_Open(
aud_context_p->current_format,
aud_bt_a2dp_sbc_callback,
&aud_bt_a2dp_ctx.audio_config.codec_cap.sbc,
aud_bt_a2dp_ctx.buf,
SBC_ENCODE_MEM_SIZE);
break;
default:
ASSERT(0);
}
}
/*****************************************************************************
* FUNCTION
* aud_bt_a2dp_close_codec
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void aud_bt_a2dp_close_codec(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
AUD_BT_A2DP_FUNC_ENTRY(AUD_BT_A2DP_CLOSE_CODEC);
if (aud_bt_a2dp_ctx.codec != NULL)
{
switch (aud_bt_a2dp_ctx.audio_config.codec_type)
{
case BT_A2DP_SBC:
SBC_Close();
break;
default:
ASSERT(0);
}
aud_bt_a2dp_ctx.codec = NULL;
}
}
/*****************************************************************************
* FUNCTION
* aud_bt_a2dp_reset_state
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void aud_bt_a2dp_reset_state(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
AUD_BT_A2DP_FUNC_ENTRY(AUD_BT_A2DP_RESET_STATE);
aud_bt_a2dp_ctx.src_mod_id = MOD_MMI;
AUD_BT_A2DP_ENTER_STATE(AUD_BT_A2DP_STATE_IDLE);
aud_bt_a2dp_ctx.wait = AUD_BT_A2DP_WAIT_NONE;
aud_bt_a2dp_ctx.service_status = AUD_BT_A2DP_SERVICE_STATUS_IDLE;
aud_bt_a2dp_ctx.result = MED_RES_OK;
aud_bt_a2dp_ctx.remote_seid = 0;
aud_bt_a2dp_ctx.local_seid = 0x01; /* valid between 0x01 ~ 0x3E */
aud_bt_a2dp_ctx.audio_cap_num = 0;
aud_bt_a2dp_ctx.forced_streaming_handling = KAL_FALSE;
memset(&aud_bt_a2dp_ctx.audio_config, 0, sizeof(bt_a2dp_audio_cap_struct));
memset(&aud_bt_a2dp_ctx.remote_audio_config, 0, sizeof(bt_a2dp_audio_cap_struct));
aud_bt_a2dp_cmd_queue_clear(&aud_bt_a2dp_ctx.cmd_queue);
aud_bt_a2dp_media_reset_output(KAL_FALSE);
aud_bt_a2dp_ctx.turn_on = KAL_FALSE;
aud_bt_a2dp_ctx.start_failed = KAL_FALSE;
}
/*****************************************************************************
* FUNCTION
* aud_bt_a2dp_init
* DESCRIPTION
*
* PARAMETERS
* void
* RETURNS
* void
*****************************************************************************/
void aud_bt_a2dp_init(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
aud_bt_a2dp_ctx.output_on = KAL_FALSE;
aud_bt_a2dp_ctx.media_output_on = KAL_FALSE;
aud_bt_a2dp_reset_state();
aud_bt_a2dp_ctx.codec = NULL;
}
/*****************************************************************************
* FUNCTION
* aud_bt_a2dp_close_result
* DESCRIPTION
*
* PARAMETERS
* service_status [IN]
* mod_id [IN]
* result [IN]
* RETURNS
* void
*****************************************************************************/
void aud_bt_a2dp_close_result(kal_uint8 service_status, kal_uint16 mod_id, kal_uint16 result)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
switch (service_status)
{
case AUD_BT_A2DP_SERVICE_STATUS_IDLE:
ASSERT(0);
break;
case AUD_BT_A2DP_SERVICE_STATUS_OPENING:
aud_send_bt_audio_open_cnf(mod_id, BT_A2DP, result);
break;
case AUD_BT_A2DP_SERVICE_STATUS_RUNNING:
aud_send_bt_audio_close_ind(mod_id, BT_A2DP, result);
break;
case AUD_BT_A2DP_SERVICE_STATUS_CLOSING:
aud_send_bt_audio_close_cnf(mod_id, BT_A2DP, MED_RES_OK);
break;
case AUD_BT_A2DP_SERVICE_STATUS_OPENING_CLOSING:
aud_send_bt_audio_open_cnf(mod_id, BT_A2DP, result);
aud_send_bt_audio_close_cnf(mod_id, BT_A2DP, MED_RES_OK);
break;
default:
ASSERT(0);
}
}
/*****************************************************************************
* FUNCTION
* aud_bt_a2dp_open_result
* DESCRIPTION
*
* PARAMETERS
* result [IN]
* RETURNS
* void
*****************************************************************************/
void aud_bt_a2dp_open_result(kal_uint16 result)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
kal_uint16 mod_id = aud_bt_a2dp_ctx.src_mod_id;
kal_bool abort = (aud_bt_a2dp_ctx.cmd_queue.cmds[0] == AUD_BT_A2DP_CMD_ABORT);
kal_bool close = (aud_bt_a2dp_ctx.service_status >= AUD_BT_A2DP_SERVICE_STATUS_CLOSING);
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
AUD_BT_A2DP_FUNC_TRACE1(AUD_BT_A2DP_OPEN_RESULT, result);
if (result != MED_RES_OK)
{
aud_bt_a2dp_reset_state();
}
else
{
aud_bt_a2dp_ctx.service_status = AUD_BT_A2DP_SERVICE_STATUS_RUNNING;
}
aud_send_bt_audio_open_cnf(mod_id, BT_A2DP, result);
if (abort)
{
aud_bt_a2dp_reset_state();
if (close)
{
aud_send_bt_audio_close_cnf(mod_id, BT_A2DP, MED_RES_OK);
}
}
}
/*****************************************************************************
* FUNCTION
* aud_bt_a2dp_open_req_hdlr
* DESCRIPTION
*
* PARAMETERS
* ilm_ptr [?]
* RETURNS
* void
*****************************************************************************/
void aud_bt_a2dp_open_req_hdlr(ilm_struct *ilm_ptr)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
media_bt_audio_open_req_struct *msg_p = (media_bt_audio_open_req_struct*) ilm_ptr->local_para_ptr;
kal_uint16 result;
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
AUD_BT_A2DP_FUNC_ENTRY(AUD_BT_A2DP_OPEN_REQ_HDLR);
/* for PTS testing */
if( msg_p->mode == BT_A2DP_PTS_PASSIVE_MODE )
aud_bt_a2dp_ctx.mode = msg_p->mode;
if (aud_bt_a2dp_ctx.s
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -