/** Transmit frame */ static int transmit_buf(TRANSAC transac, char *p_buf, int len) { utils_enqueue(&tx_q, (void *) transac); bthc_signal_event(HC_EVENT_TX); return BT_HC_STATUS_SUCCESS; }
void bthc_tx(HC_BT_HDR *buf) { pthread_mutex_lock(&hc_cb.worker_thread_lock); if (hc_cb.worker_thread) { if (buf) utils_enqueue(&tx_q, buf); thread_post(hc_cb.worker_thread, event_tx, NULL); } pthread_mutex_unlock(&hc_cb.worker_thread_lock); }
/******************************************************************************* ** ** Function userial_read_thread ** ** Description ** ** Returns void * ** *******************************************************************************/ static void *userial_read_thread(void *arg) { int rx_length = 0; HC_BT_HDR *p_buf = NULL; uint8_t *p; USERIALDBG("Entering userial_read_thread()"); prctl(PR_SET_NAME, (unsigned long)"userial_read", 0, 0, 0); rx_flow_on = TRUE; userial_running = 1; raise_priority_a2dp(TASK_HIGH_USERIAL_READ); while (userial_running) { if (bt_hc_cbacks) { p_buf = (HC_BT_HDR *) bt_hc_cbacks->alloc( \ BTHC_USERIAL_READ_MEM_SIZE); } else p_buf = NULL; if (p_buf != NULL) { p_buf->offset = 0; p_buf->layer_specific = 0; p = (uint8_t *) (p_buf + 1); rx_length = select_read(userial_cb.fd, p, READ_LIMIT); } else { rx_length = 0; utils_delay(100); ALOGW("userial_read_thread() failed to gain buffers"); continue; } if (rx_length > 0) { p_buf->len = (uint16_t)rx_length; utils_enqueue(&(userial_cb.rx_q), p_buf); bthc_signal_event(HC_EVENT_RX); } else /* either 0 or < 0 */ { ALOGW("select_read return size <=0:%d, exiting userial_read_thread",\ rx_length); /* if we get here, we should have a buffer */ bt_hc_cbacks->dealloc((TRANSAC) p_buf, (char *) (p_buf + 1)); /* negative value means exit thread */ break; } } /* for */ userial_running = 0; USERIALDBG("Leaving userial_read_thread()"); pthread_exit(NULL); return NULL; // Compiler friendly }