diff options
Diffstat (limited to 'btif/src')
-rw-r--r-- | btif/src/btif_av.c | 10 | ||||
-rw-r--r-- | btif/src/btif_hf.c | 16 | ||||
-rw-r--r-- | btif/src/btif_media_task.c | 61 | ||||
-rw-r--r-- | btif/src/btif_rc.c | 17 | ||||
-rw-r--r-- | btif/src/btif_sock_thread.c | 3 |
5 files changed, 84 insertions, 23 deletions
diff --git a/btif/src/btif_av.c b/btif/src/btif_av.c index f5f9b795c..2448c7be4 100644 --- a/btif/src/btif_av.c +++ b/btif/src/btif_av.c @@ -279,7 +279,7 @@ static void btif_report_audio_state(btav_audio_state_t state, bt_bdaddr_t *bd_ad static BOOLEAN btif_av_state_idle_handler(btif_sm_event_t event, void *p_data) { - BTIF_TRACE_DEBUG("%s event:%s flags %x", __FUNCTION__, + BTIF_TRACE_IMP("%s event:%s flags %x", __FUNCTION__, dump_av_sm_event_name(event), btif_av_cb.flags); switch (event) @@ -389,7 +389,7 @@ static BOOLEAN btif_av_state_idle_handler(btif_sm_event_t event, void *p_data) static BOOLEAN btif_av_state_opening_handler(btif_sm_event_t event, void *p_data) { - BTIF_TRACE_DEBUG("%s event:%s flags %x", __FUNCTION__, + BTIF_TRACE_IMP("%s event:%s flags %x", __FUNCTION__, dump_av_sm_event_name(event), btif_av_cb.flags); switch (event) @@ -551,7 +551,7 @@ static BOOLEAN btif_av_state_opening_handler(btif_sm_event_t event, void *p_data static BOOLEAN btif_av_state_closing_handler(btif_sm_event_t event, void *p_data) { - BTIF_TRACE_DEBUG("%s event:%s flags %x", __FUNCTION__, + BTIF_TRACE_IMP("%s event:%s flags %x", __FUNCTION__, dump_av_sm_event_name(event), btif_av_cb.flags); switch (event) @@ -624,7 +624,7 @@ static BOOLEAN btif_av_state_opened_handler(btif_sm_event_t event, void *p_data) tBTA_AV *p_av = (tBTA_AV*)p_data; tBTIF_STATUS status = BTIF_SUCCESS; - BTIF_TRACE_DEBUG("%s event:%s flags %x", __FUNCTION__, + BTIF_TRACE_IMP("%s event:%s flags %x", __FUNCTION__, dump_av_sm_event_name(event), btif_av_cb.flags); if ( (event == BTA_AV_REMOTE_CMD_EVT) && (btif_av_cb.flags & BTIF_AV_FLAG_REMOTE_SUSPEND) && @@ -813,7 +813,7 @@ static BOOLEAN btif_av_state_started_handler(btif_sm_event_t event, void *p_data { tBTA_AV *p_av = (tBTA_AV*)p_data; - BTIF_TRACE_DEBUG("%s event:%s flags %x", __FUNCTION__, + BTIF_TRACE_IMP("%s event:%s flags %x", __FUNCTION__, dump_av_sm_event_name(event), btif_av_cb.flags); switch (event) diff --git a/btif/src/btif_hf.c b/btif/src/btif_hf.c index b4a565f11..0421f801c 100644 --- a/btif/src/btif_hf.c +++ b/btif/src/btif_hf.c @@ -119,7 +119,7 @@ static UINT32 btif_features = BTIF_HF_FEATURES; }\ else\ {\ - BTIF_TRACE_EVENT("BTHF: %s", __FUNCTION__);\ + BTIF_TRACE_IMP("BTHF: %s", __FUNCTION__);\ } #define CHECK_BTHF_SLC_CONNECTED() if (bt_hf_callbacks == NULL)\ @@ -382,7 +382,7 @@ static void btif_hf_upstreams_evt(UINT16 event, char* p_param) bdstr_t bdstr; int idx = p_data->hdr.handle - 1; - BTIF_TRACE_DEBUG("%s: event=%s", __FUNCTION__, dump_hf_event(event)); + BTIF_TRACE_IMP("%s: event=%s", __FUNCTION__, dump_hf_event(event)); if ((idx < 0) || (idx >= BTIF_HF_NUM_CB)) { @@ -1263,7 +1263,7 @@ static bt_status_t phone_state_change(int num_active, int num_held, bthf_call_st if (btif_hf_check_if_slc_connected() != BT_STATUS_SUCCESS) return BT_STATUS_NOT_READY; - BTIF_TRACE_DEBUG("phone_state_change: num_active=%d [prev: %d] num_held=%d[prev: %d]" + BTIF_TRACE_IMP("phone_state_change: num_active=%d [prev: %d] num_held=%d[prev: %d]" " call_setup=%s [prev: %s]", num_active, btif_hf_cb[idx].num_active, num_held, btif_hf_cb[idx].num_held, dump_hf_call_state(call_setup_state), dump_hf_call_state(btif_hf_cb[idx].call_setup_state)); @@ -1325,7 +1325,7 @@ static bt_status_t phone_state_change(int num_active, int num_held, bthf_call_st /* Ringing call changed? */ if (call_setup_state != btif_hf_cb[idx].call_setup_state) { - BTIF_TRACE_DEBUG("%s: Call setup states changed. old: %s new: %s", + BTIF_TRACE_IMP("%s: Call setup states changed. old: %s new: %s", __FUNCTION__, dump_hf_call_state(btif_hf_cb[idx].call_setup_state), dump_hf_call_state(call_setup_state)); memset(&ag_res, 0, sizeof(tBTA_AG_RES_DATA)); @@ -1399,7 +1399,7 @@ static bt_status_t phone_state_change(int num_active, int num_held, bthf_call_st status = BT_STATUS_PARM_INVALID; break; } - BTIF_TRACE_DEBUG("%s: Call setup state changed. res=%d, audio_handle=%d", __FUNCTION__, res, ag_res.audio_handle); + BTIF_TRACE_IMP("%s: Call setup state changed. res=%d, audio_handle=%d", __FUNCTION__, res, ag_res.audio_handle); if (res) BTA_AgResult(BTA_AG_HANDLE_ALL, res, &ag_res); @@ -1423,7 +1423,7 @@ static bt_status_t phone_state_change(int num_active, int num_held, bthf_call_st if (!activeCallUpdated && ((num_active + num_held) != (btif_hf_cb[idx].num_active + btif_hf_cb[idx].num_held)) ) { - BTIF_TRACE_DEBUG("%s: Active call states changed. old: %d new: %d", __FUNCTION__, btif_hf_cb[idx].num_active, num_active); + BTIF_TRACE_IMP("%s: Active call states changed. old: %d new: %d", __FUNCTION__, btif_hf_cb[idx].num_active, num_active); send_indicator_update(BTA_AG_IND_CALL, ((num_active + num_held) > 0) ? 1 : 0); } @@ -1431,7 +1431,7 @@ static bt_status_t phone_state_change(int num_active, int num_held, bthf_call_st if (num_held != btif_hf_cb[idx].num_held || ((num_active == 0) && ((num_held + btif_hf_cb[idx].num_held) > 1))) { - BTIF_TRACE_DEBUG("%s: Held call states changed. old: %d new: %d", + BTIF_TRACE_IMP("%s: Held call states changed. old: %d new: %d", __FUNCTION__, btif_hf_cb[idx].num_held, num_held); send_indicator_update(BTA_AG_IND_CALLHELD, ((num_held == 0) ? 0 : ((num_active == 0) ? 2 : 1))); } @@ -1442,7 +1442,7 @@ static bt_status_t phone_state_change(int num_active, int num_held, bthf_call_st (num_active == btif_hf_cb[idx].num_active) && (num_held == btif_hf_cb[idx].num_held) ) { - BTIF_TRACE_DEBUG("%s: Calls swapped", __FUNCTION__); + BTIF_TRACE_IMP("%s: Calls swapped", __FUNCTION__); send_indicator_update(BTA_AG_IND_CALLHELD, 1); } diff --git a/btif/src/btif_media_task.c b/btif/src/btif_media_task.c index 6851c9cbb..34fd19aa4 100644 --- a/btif/src/btif_media_task.c +++ b/btif/src/btif_media_task.c @@ -25,6 +25,10 @@ ** audio & video processing ** ******************************************************************************/ +//#define BT_AUDIO_SYSTRACE_LOG +#ifdef BT_AUDIO_SYSTRACE_LOG +#define ATRACE_TAG ATRACE_TAG_ALWAYS +#endif #define LOG_TAG "bt_btif_media" @@ -85,6 +89,11 @@ OI_UINT32 contextData[CODEC_DATA_WORDS(2, SBC_CODEC_FAST_FILTER_BUFFERS)]; OI_INT16 pcmData[15*SBC_MAX_SAMPLES_PER_FRAME*SBC_MAX_CHANNELS]; #endif +#ifdef BT_AUDIO_SYSTRACE_LOG +#include <cutils/trace.h> +#define PERF_SYSTRACE 1 +#endif + /***************************************************************************** ** Constants *****************************************************************************/ @@ -328,10 +337,23 @@ static UINT64 time_now_us() static void log_tstamps_us(char *comment) { + #define USEC_PER_MSEC 1000L static UINT64 prev_us = 0; const UINT64 now_us = time_now_us(); - APPL_TRACE_DEBUG("[%s] ts %08llu, diff : %08llu, queue sz %d", comment, now_us, now_us - prev_us, + static UINT64 diff_us = 0; + + diff_us = now_us - prev_us; + if ((diff_us / USEC_PER_MSEC) > (BTIF_MEDIA_TIME_TICK + 10)) + { + APPL_TRACE_ERROR("[%s] ts %08llu, diff : %08llu, queue sz %d", comment, now_us, diff_us, GKI_queue_length(&btif_media_cb.TxAaQ)); + } + else + { + APPL_TRACE_DEBUG("[%s] ts %08llu, diff : %08llu, queue sz %d", comment, now_us, diff_us, + GKI_queue_length(&btif_media_cb.TxAaQ)); + } + prev_us = now_us; } @@ -1357,7 +1379,9 @@ static void btif_media_task_handle_inc_media(tBT_SBC_HDR*p_msg) p_msg->len = sbc_frame_len + 1; } + UIPC_Send(UIPC_CH_ID_AV_AUDIO, 0, (UINT8 *)pcmData, (2*sizeof(pcmData) - availPcmBytes)); + } #endif @@ -2366,6 +2390,9 @@ BOOLEAN btif_media_aa_read_feeding(tUIPC_CH_ID channel_id) INT32 fract_max; INT32 fract_threshold; UINT32 nb_byte_read; + #ifdef BT_AUDIO_SYSTRACE_LOG + char trace_buf[512]; + #endif /* Get the SBC sampling rate */ switch (btif_media_cb.encoder.s16SamplingFreq) @@ -2455,6 +2482,19 @@ BOOLEAN btif_media_aa_read_feeding(tUIPC_CH_ID channel_id) { APPL_TRACE_WARNING("### UNDERRUN :: ONLY READ %d BYTES OUT OF %d ###", nb_byte_read, read_size); + #ifdef BT_AUDIO_SYSTRACE_LOG + snprintf(trace_buf, 32, "A2DP UNDERRUN read %ld ", nb_byte_read); + + if (PERF_SYSTRACE) + { + ATRACE_BEGIN(trace_buf); + } + + if (PERF_SYSTRACE) + { + ATRACE_END(); + } + #endif if (nb_byte_read == 0) return FALSE; @@ -2660,6 +2700,9 @@ static void btif_media_send_aa_frame(void) { UINT8 nb_frame_2_send; + #ifdef BT_AUDIO_SYSTRACE_LOG + char trace_buf[1024]; + #endif /* get the number of frame to send */ nb_frame_2_send = btif_get_num_aa_frame(); @@ -2671,6 +2714,22 @@ static void btif_media_send_aa_frame(void) /* send it */ LOG_VERBOSE("btif_media_send_aa_frame : send %d frames", nb_frame_2_send); + #ifdef BT_AUDIO_SYSTRACE_LOG + snprintf(trace_buf, 32, "btif_media_send_aa_frame:"); + if (PERF_SYSTRACE) + { + ATRACE_BEGIN(trace_buf); + } + #endif + + /* send it */ + + #ifdef BT_AUDIO_SYSTRACE_LOG + if (PERF_SYSTRACE) + { + ATRACE_END(); + } + #endif bta_av_ci_src_data_ready(BTA_AV_CHNL_AUDIO); } diff --git a/btif/src/btif_rc.c b/btif/src/btif_rc.c index 3000d819f..93be30f5a 100644 --- a/btif/src/btif_rc.c +++ b/btif/src/btif_rc.c @@ -255,7 +255,7 @@ void send_key (int fd, uint16_t key, int pressed) return; } - BTIF_TRACE_DEBUG("AVRCP: Send key %d (%d) fd=%d", key, pressed, fd); + BTIF_TRACE_IMP("AVRCP: Send key %d (%d) fd=%d", key, pressed, fd); send_event(fd, EV_KEY, key, pressed); send_event(fd, EV_SYN, SYN_REPORT, 0); } @@ -356,7 +356,7 @@ void handle_rc_features() bt_bdaddr_t avdtp_addr; bdstr_t addr1, addr2; - bdcpy(rc_addr.address, btif_rc_cb.rc_addr); + bdcpy(rc_addr.address, btif_rc_cb.rc_addr); avdtp_addr = btif_av_get_addr(); BTIF_TRACE_DEBUG("AVDTP Address : %s AVCTP address: %s", @@ -440,7 +440,7 @@ void handle_rc_features() ***************************************************************************/ void handle_rc_connect (tBTA_AV_RC_OPEN *p_rc_open) { - BTIF_TRACE_DEBUG("%s: rc_handle: %d", __FUNCTION__, p_rc_open->rc_handle); + BTIF_TRACE_IMP("%s: rc_handle: %d", __FUNCTION__, p_rc_open->rc_handle); bt_status_t result = BT_STATUS_SUCCESS; #if (AVRC_CTLR_INCLUDED == TRUE) bt_bdaddr_t rc_addr; @@ -514,14 +514,13 @@ void handle_rc_disconnect (tBTA_AV_RC_CLOSE *p_rc_close) bt_bdaddr_t rc_addr; tBTA_AV_FEAT features; #endif - BTIF_TRACE_DEBUG("%s: rc_handle: %d", __FUNCTION__, p_rc_close->rc_handle); + BTIF_TRACE_IMP("%s: rc_handle: %d", __FUNCTION__, p_rc_close->rc_handle); if ((p_rc_close->rc_handle != btif_rc_cb.rc_handle) && (bdcmp(btif_rc_cb.rc_addr, p_rc_close->peer_addr))) { BTIF_TRACE_ERROR("Got disconnect of unknown device"); return; } - btif_rc_cb.rc_handle = 0; btif_rc_cb.rc_connected = FALSE; memset(btif_rc_cb.rc_addr, 0, sizeof(BD_ADDR)); @@ -811,7 +810,7 @@ void handle_rc_metamsg_cmd (tBTA_AV_META_MSG *pmeta_msg) ***************************************************************************/ void btif_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data) { - BTIF_TRACE_DEBUG ("%s event:%s", __FUNCTION__, dump_rc_event(event)); + BTIF_TRACE_IMP ("%s event:%s", __FUNCTION__, dump_rc_event(event)); switch (event) { case BTA_AV_RC_OPEN_EVT: @@ -1128,7 +1127,7 @@ static UINT8 opcode_from_pdu(UINT8 pdu) *******************************************************************************/ static void btif_rc_upstreams_evt(UINT16 event, tAVRC_COMMAND *pavrc_cmd, UINT8 ctype, UINT8 label) { - BTIF_TRACE_EVENT("%s pdu: %s handle: 0x%x ctype:%x label:%x", __FUNCTION__, + BTIF_TRACE_IMP("%s pdu: %s handle: 0x%x ctype:%x label:%x", __FUNCTION__, dump_rc_pdu(pavrc_cmd->pdu), btif_rc_cb.rc_handle, ctype, label); switch (event) @@ -1259,7 +1258,7 @@ static void btif_rc_upstreams_evt(UINT16 event, tAVRC_COMMAND *pavrc_cmd, UINT8 *******************************************************************************/ static void btif_rc_upstreams_rsp_evt(UINT16 event, tAVRC_RESPONSE *pavrc_resp, UINT8 ctype, UINT8 label) { - BTIF_TRACE_EVENT("%s pdu: %s handle: 0x%x ctype:%x label:%x", __FUNCTION__, + BTIF_TRACE_IMP("%s pdu: %s handle: 0x%x ctype:%x label:%x", __FUNCTION__, dump_rc_pdu(pavrc_resp->pdu), btif_rc_cb.rc_handle, ctype, label); #if (AVRC_ADV_CTRL_INCLUDED == TRUE) @@ -1434,7 +1433,7 @@ static bt_status_t register_notification_rsp(btrc_event_id_t event_id, { tAVRC_RESPONSE avrc_rsp; CHECK_RC_CONNECTED - BTIF_TRACE_EVENT("## %s ## event_id:%s", __FUNCTION__, dump_rc_notification_event_id(event_id)); + BTIF_TRACE_IMP("## %s ## event_id:%s", __FUNCTION__, dump_rc_notification_event_id(event_id)); if (btif_rc_cb.rc_notif[event_id-1].bNotify == FALSE) { BTIF_TRACE_ERROR("Avrcp Event id not registered: event_id = %x", event_id); diff --git a/btif/src/btif_sock_thread.c b/btif/src/btif_sock_thread.c index 459aebac2..5a0ba45b7 100644 --- a/btif/src/btif_sock_thread.c +++ b/btif/src/btif_sock_thread.c @@ -37,6 +37,7 @@ #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> +#include <sys/prctl.h> #include <time.h> #include <fcntl.h> #include <unistd.h> @@ -605,6 +606,8 @@ static void *sock_poll_thread(void *arg) struct pollfd pfds[MAX_POLL]; memset(pfds, 0, sizeof(pfds)); int h = (intptr_t)arg; + + prctl(PR_SET_NAME, (unsigned long)"btif_sock_poll", 0, 0, 0); for(;;) { prepare_poll_fds(h, pfds); |