Loading system/btif/src/btif_a2dp_control.cc +37 −30 Original line number Diff line number Diff line Loading @@ -48,15 +48,16 @@ static void btif_a2dp_ctrl_cb(tUIPC_CH_ID ch_id, tUIPC_EVENT event); /* We can have max one command pending */ static tA2DP_CTRL_CMD a2dp_cmd_pending = A2DP_CTRL_CMD_NONE; std::unique_ptr<tUIPC_STATE> a2dp_uipc; void btif_a2dp_control_init(void) { UIPC_Init(NULL, UIPC_USER_A2DP); UIPC_Open(UIPC_CH_ID_AV_CTRL, btif_a2dp_ctrl_cb); a2dp_uipc = UIPC_Init(); UIPC_Open(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, btif_a2dp_ctrl_cb); } void btif_a2dp_control_cleanup(void) { /* This calls blocks until UIPC is fully closed */ UIPC_Close(UIPC_CH_ID_ALL, UIPC_USER_A2DP); UIPC_Close(*a2dp_uipc, UIPC_CH_ID_ALL); } static void btif_a2dp_recv_ctrl_data(void) { Loading @@ -64,13 +65,13 @@ static void btif_a2dp_recv_ctrl_data(void) { int n; uint8_t read_cmd = 0; /* The read command size is one octet */ n = UIPC_Read(UIPC_CH_ID_AV_CTRL, NULL, &read_cmd, 1); n = UIPC_Read(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, NULL, &read_cmd, 1); cmd = static_cast<tA2DP_CTRL_CMD>(read_cmd); /* detach on ctrl channel means audioflinger process was terminated */ if (n == 0) { APPL_TRACE_WARNING("%s: CTRL CH DETACHED", __func__); UIPC_Close(UIPC_CH_ID_AV_CTRL, UIPC_USER_A2DP); UIPC_Close(*a2dp_uipc, UIPC_CH_ID_AV_CTRL); return; } Loading Loading @@ -117,7 +118,7 @@ static void btif_a2dp_recv_ctrl_data(void) { if (btif_av_stream_ready()) { /* Setup audio data channel listener */ UIPC_Open(UIPC_CH_ID_AV_AUDIO, btif_a2dp_data_cb); UIPC_Open(*a2dp_uipc, UIPC_CH_ID_AV_AUDIO, btif_a2dp_data_cb); /* * Post start event and wait for audio path to open. Loading @@ -135,7 +136,7 @@ static void btif_a2dp_recv_ctrl_data(void) { * Already started, setup audio data channel listener and ACK * back immediately. */ UIPC_Open(UIPC_CH_ID_AV_AUDIO, btif_a2dp_data_cb); UIPC_Open(*a2dp_uipc, UIPC_CH_ID_AV_AUDIO, btif_a2dp_data_cb); btif_a2dp_command_ack(A2DP_CTRL_ACK_SUCCESS); break; } Loading Loading @@ -174,9 +175,10 @@ static void btif_a2dp_recv_ctrl_data(void) { tA2DP_CHANNEL_COUNT channel_count = btif_a2dp_sink_get_channel_count(); btif_a2dp_command_ack(A2DP_CTRL_ACK_SUCCESS); UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<uint8_t*>(&sample_rate), UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<uint8_t*>(&sample_rate), sizeof(tA2DP_SAMPLE_RATE)); UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, &channel_count, UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, &channel_count, sizeof(tA2DP_CHANNEL_COUNT)); break; } Loading @@ -199,24 +201,26 @@ static void btif_a2dp_recv_ctrl_data(void) { btif_a2dp_command_ack(A2DP_CTRL_ACK_SUCCESS); // Send the current codec config UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<const uint8_t*>(&codec_config.sample_rate), sizeof(btav_a2dp_codec_sample_rate_t)); UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<const uint8_t*>(&codec_config.bits_per_sample), sizeof(btav_a2dp_codec_bits_per_sample_t)); UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<const uint8_t*>(&codec_config.channel_mode), sizeof(btav_a2dp_codec_channel_mode_t)); // Send the current codec capability UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<const uint8_t*>(&codec_capability.sample_rate), sizeof(btav_a2dp_codec_sample_rate_t)); UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<const uint8_t*>( &codec_capability.bits_per_sample), UIPC_Send( *a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<const uint8_t*>(&codec_capability.bits_per_sample), sizeof(btav_a2dp_codec_bits_per_sample_t)); UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<const uint8_t*>( &codec_capability.channel_mode), UIPC_Send( *a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<const uint8_t*>(&codec_capability.channel_mode), sizeof(btav_a2dp_codec_channel_mode_t)); break; } Loading @@ -229,7 +233,7 @@ static void btif_a2dp_recv_ctrl_data(void) { btif_a2dp_command_ack(A2DP_CTRL_ACK_SUCCESS); // Send the current codec config if (UIPC_Read(UIPC_CH_ID_AV_CTRL, 0, if (UIPC_Read(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<uint8_t*>(&codec_config.sample_rate), sizeof(btav_a2dp_codec_sample_rate_t)) != sizeof(btav_a2dp_codec_sample_rate_t)) { Loading @@ -237,7 +241,7 @@ static void btif_a2dp_recv_ctrl_data(void) { __func__); break; } if (UIPC_Read(UIPC_CH_ID_AV_CTRL, 0, if (UIPC_Read(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<uint8_t*>(&codec_config.bits_per_sample), sizeof(btav_a2dp_codec_bits_per_sample_t)) != sizeof(btav_a2dp_codec_bits_per_sample_t)) { Loading @@ -245,7 +249,7 @@ static void btif_a2dp_recv_ctrl_data(void) { __func__); break; } if (UIPC_Read(UIPC_CH_ID_AV_CTRL, 0, if (UIPC_Read(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<uint8_t*>(&codec_config.channel_mode), sizeof(btav_a2dp_codec_channel_mode_t)) != sizeof(btav_a2dp_codec_channel_mode_t)) { Loading @@ -270,17 +274,19 @@ static void btif_a2dp_recv_ctrl_data(void) { case A2DP_CTRL_GET_PRESENTATION_POSITION: { btif_a2dp_command_ack(A2DP_CTRL_ACK_SUCCESS); UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, (uint8_t*)&(delay_report_stats.total_bytes_read), sizeof(uint64_t)); UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, (uint8_t*)&(delay_report_stats.audio_delay), sizeof(uint16_t)); uint32_t seconds = delay_report_stats.timestamp.tv_sec; UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, (uint8_t*)&seconds, sizeof(seconds)); UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, (uint8_t*)&seconds, sizeof(seconds)); uint32_t nsec = delay_report_stats.timestamp.tv_nsec; UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, (uint8_t*)&nsec, sizeof(nsec)); UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, (uint8_t*)&nsec, sizeof(nsec)); break; } default: Loading @@ -304,7 +310,7 @@ static void btif_a2dp_ctrl_cb(UNUSED_ATTR tUIPC_CH_ID ch_id, case UIPC_CLOSE_EVT: /* restart ctrl server unless we are shutting down */ if (btif_a2dp_source_media_task_is_running()) UIPC_Open(UIPC_CH_ID_AV_CTRL, btif_a2dp_ctrl_cb); UIPC_Open(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, btif_a2dp_ctrl_cb); break; case UIPC_RX_DATA_READY_EVT: Loading @@ -329,8 +335,9 @@ static void btif_a2dp_data_cb(UNUSED_ATTR tUIPC_CH_ID ch_id, * Read directly from media task from here on (keep callback for * connection events. */ UIPC_Ioctl(UIPC_CH_ID_AV_AUDIO, UIPC_REG_REMOVE_ACTIVE_READSET, NULL); UIPC_Ioctl(UIPC_CH_ID_AV_AUDIO, UIPC_SET_READ_POLL_TMO, UIPC_Ioctl(*a2dp_uipc, UIPC_CH_ID_AV_AUDIO, UIPC_REG_REMOVE_ACTIVE_READSET, NULL); UIPC_Ioctl(*a2dp_uipc, UIPC_CH_ID_AV_AUDIO, UIPC_SET_READ_POLL_TMO, reinterpret_cast<void*>(A2DP_DATA_READ_POLL_MS)); if (btif_av_get_peer_sep() == AVDT_TSEP_SNK) { Loading Loading @@ -378,7 +385,7 @@ void btif_a2dp_command_ack(tA2DP_CTRL_ACK status) { a2dp_cmd_pending = A2DP_CTRL_CMD_NONE; /* Acknowledge start request */ UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, &ack, sizeof(ack)); UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, &ack, sizeof(ack)); } void btif_a2dp_control_log_bytes_read(uint32_t bytes_read) { Loading system/btif/src/btif_a2dp_source.cc +7 −4 Original line number Diff line number Diff line Loading @@ -52,6 +52,8 @@ using system_bt_osi::BluetoothMetricsLogger; using system_bt_osi::A2dpSessionMetrics; extern std::unique_ptr<tUIPC_STATE> a2dp_uipc; /** * The typical runlevel of the tx queue size is ~1 buffer * but due to link flow control or thread preemption in lower Loading Loading @@ -694,13 +696,13 @@ static void btif_a2dp_source_audio_tx_stop_event(void) { // Keep track of audio data still left in the pipe btif_a2dp_control_log_bytes_read( UIPC_Read(UIPC_CH_ID_AV_AUDIO, &event, p_buf, sizeof(p_buf))); UIPC_Read(*a2dp_uipc, UIPC_CH_ID_AV_AUDIO, &event, p_buf, sizeof(p_buf))); /* Stop the timer first */ alarm_free(btif_a2dp_source_cb.media_alarm); btif_a2dp_source_cb.media_alarm = nullptr; UIPC_Close(UIPC_CH_ID_AV_AUDIO, UIPC_USER_A2DP); UIPC_Close(*a2dp_uipc, UIPC_CH_ID_AV_AUDIO); /* * Try to send acknowldegment once the media stream is Loading Loading @@ -759,7 +761,8 @@ static void btif_a2dp_source_audio_handle_timer(void) { static uint32_t btif_a2dp_source_read_callback(uint8_t* p_buf, uint32_t len) { uint16_t event; uint32_t bytes_read = UIPC_Read(UIPC_CH_ID_AV_AUDIO, &event, p_buf, len); uint32_t bytes_read = UIPC_Read(*a2dp_uipc, UIPC_CH_ID_AV_AUDIO, &event, p_buf, len); if (bytes_read < len) { LOG_WARN(LOG_TAG, "%s: UNDERFLOW: ONLY READ %d BYTES OUT OF %d", __func__, Loading Loading @@ -869,7 +872,7 @@ static void btif_a2dp_source_audio_tx_flush_event(void) { time_get_os_boottime_us(); fixed_queue_flush(btif_a2dp_source_cb.tx_audio_queue, osi_free); UIPC_Ioctl(UIPC_CH_ID_AV_AUDIO, UIPC_REQ_RX_FLUSH, nullptr); UIPC_Ioctl(*a2dp_uipc, UIPC_CH_ID_AV_AUDIO, UIPC_REQ_RX_FLUSH, nullptr); } static bool btif_a2dp_source_audio_tx_flush_req(void) { Loading system/udrv/include/uipc.h +30 −16 Original line number Diff line number Diff line Loading @@ -37,13 +37,6 @@ typedef enum { UIPC_TX_DATA_READY_EVT = 0x0010 } tUIPC_EVENT; /* UIPC users */ typedef enum { UIPC_USER_A2DP = 0, UIPC_USER_HEARING_AID = 1, UIPC_USER_NUM = 2 } tUIPC_USER; /* * UIPC IOCTL Requests */ Loading @@ -62,12 +55,33 @@ typedef void(tUIPC_RCV_CBACK)( const char* dump_uipc_event(tUIPC_EVENT event); typedef struct { int srvfd; int fd; int read_poll_tmo_ms; int task_evt_flags; /* event flags pending to be processed in read task */ tUIPC_RCV_CBACK* cback; } tUIPC_CHAN; struct tUIPC_STATE { pthread_t tid; /* main thread id */ int running; std::recursive_mutex mutex; fd_set active_set; fd_set read_set; int max_fd; int signal_fds[2]; tUIPC_CHAN ch[UIPC_CH_NUM]; }; /** * Initialize UIPC module * * @param user User ID who uses UIPC */ void UIPC_Init(void*, int user); std::unique_ptr<tUIPC_STATE> UIPC_Init(); /** * Open a UIPC channel Loading @@ -76,15 +90,14 @@ void UIPC_Init(void*, int user); * @param p_cback Callback handler * @return true on success, otherwise false */ bool UIPC_Open(tUIPC_CH_ID ch_id, tUIPC_RCV_CBACK* p_cback); bool UIPC_Open(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id, tUIPC_RCV_CBACK* p_cback); /** * Closes a channel in UIPC or the entire UIPC module * * @param ch_id Channel ID; if ch_id is UIPC_CH_ID_ALL, then cleanup UIPC * @param user User ID who uses UIPC */ void UIPC_Close(tUIPC_CH_ID ch_id, int user); void UIPC_Close(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id); /** * Send a message over UIPC Loading @@ -95,8 +108,8 @@ void UIPC_Close(tUIPC_CH_ID ch_id, int user); * @param msglen Message length * @return true on success, otherwise false */ bool UIPC_Send(tUIPC_CH_ID ch_id, uint16_t msg_evt, const uint8_t* p_buf, uint16_t msglen); bool UIPC_Send(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id, uint16_t msg_evt, const uint8_t* p_buf, uint16_t msglen); /** * Read a message from UIPC Loading @@ -107,8 +120,8 @@ bool UIPC_Send(tUIPC_CH_ID ch_id, uint16_t msg_evt, const uint8_t* p_buf, * @param len Bytes to read * @return true on success, otherwise false */ uint32_t UIPC_Read(tUIPC_CH_ID ch_id, uint16_t* p_msg_evt, uint8_t* p_buf, uint32_t len); uint32_t UIPC_Read(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id, uint16_t* p_msg_evt, uint8_t* p_buf, uint32_t len); /** * Control the UIPC parameter Loading @@ -118,6 +131,7 @@ uint32_t UIPC_Read(tUIPC_CH_ID ch_id, uint16_t* p_msg_evt, uint8_t* p_buf, * @param param Optional parameters * @return true on success, otherwise false */ bool UIPC_Ioctl(tUIPC_CH_ID ch_id, uint32_t request, void* param); bool UIPC_Ioctl(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id, uint32_t request, void* param); #endif /* UIPC_H */ system/udrv/ulinux/uipc.cc +144 −191 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
system/btif/src/btif_a2dp_control.cc +37 −30 Original line number Diff line number Diff line Loading @@ -48,15 +48,16 @@ static void btif_a2dp_ctrl_cb(tUIPC_CH_ID ch_id, tUIPC_EVENT event); /* We can have max one command pending */ static tA2DP_CTRL_CMD a2dp_cmd_pending = A2DP_CTRL_CMD_NONE; std::unique_ptr<tUIPC_STATE> a2dp_uipc; void btif_a2dp_control_init(void) { UIPC_Init(NULL, UIPC_USER_A2DP); UIPC_Open(UIPC_CH_ID_AV_CTRL, btif_a2dp_ctrl_cb); a2dp_uipc = UIPC_Init(); UIPC_Open(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, btif_a2dp_ctrl_cb); } void btif_a2dp_control_cleanup(void) { /* This calls blocks until UIPC is fully closed */ UIPC_Close(UIPC_CH_ID_ALL, UIPC_USER_A2DP); UIPC_Close(*a2dp_uipc, UIPC_CH_ID_ALL); } static void btif_a2dp_recv_ctrl_data(void) { Loading @@ -64,13 +65,13 @@ static void btif_a2dp_recv_ctrl_data(void) { int n; uint8_t read_cmd = 0; /* The read command size is one octet */ n = UIPC_Read(UIPC_CH_ID_AV_CTRL, NULL, &read_cmd, 1); n = UIPC_Read(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, NULL, &read_cmd, 1); cmd = static_cast<tA2DP_CTRL_CMD>(read_cmd); /* detach on ctrl channel means audioflinger process was terminated */ if (n == 0) { APPL_TRACE_WARNING("%s: CTRL CH DETACHED", __func__); UIPC_Close(UIPC_CH_ID_AV_CTRL, UIPC_USER_A2DP); UIPC_Close(*a2dp_uipc, UIPC_CH_ID_AV_CTRL); return; } Loading Loading @@ -117,7 +118,7 @@ static void btif_a2dp_recv_ctrl_data(void) { if (btif_av_stream_ready()) { /* Setup audio data channel listener */ UIPC_Open(UIPC_CH_ID_AV_AUDIO, btif_a2dp_data_cb); UIPC_Open(*a2dp_uipc, UIPC_CH_ID_AV_AUDIO, btif_a2dp_data_cb); /* * Post start event and wait for audio path to open. Loading @@ -135,7 +136,7 @@ static void btif_a2dp_recv_ctrl_data(void) { * Already started, setup audio data channel listener and ACK * back immediately. */ UIPC_Open(UIPC_CH_ID_AV_AUDIO, btif_a2dp_data_cb); UIPC_Open(*a2dp_uipc, UIPC_CH_ID_AV_AUDIO, btif_a2dp_data_cb); btif_a2dp_command_ack(A2DP_CTRL_ACK_SUCCESS); break; } Loading Loading @@ -174,9 +175,10 @@ static void btif_a2dp_recv_ctrl_data(void) { tA2DP_CHANNEL_COUNT channel_count = btif_a2dp_sink_get_channel_count(); btif_a2dp_command_ack(A2DP_CTRL_ACK_SUCCESS); UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<uint8_t*>(&sample_rate), UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<uint8_t*>(&sample_rate), sizeof(tA2DP_SAMPLE_RATE)); UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, &channel_count, UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, &channel_count, sizeof(tA2DP_CHANNEL_COUNT)); break; } Loading @@ -199,24 +201,26 @@ static void btif_a2dp_recv_ctrl_data(void) { btif_a2dp_command_ack(A2DP_CTRL_ACK_SUCCESS); // Send the current codec config UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<const uint8_t*>(&codec_config.sample_rate), sizeof(btav_a2dp_codec_sample_rate_t)); UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<const uint8_t*>(&codec_config.bits_per_sample), sizeof(btav_a2dp_codec_bits_per_sample_t)); UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<const uint8_t*>(&codec_config.channel_mode), sizeof(btav_a2dp_codec_channel_mode_t)); // Send the current codec capability UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<const uint8_t*>(&codec_capability.sample_rate), sizeof(btav_a2dp_codec_sample_rate_t)); UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<const uint8_t*>( &codec_capability.bits_per_sample), UIPC_Send( *a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<const uint8_t*>(&codec_capability.bits_per_sample), sizeof(btav_a2dp_codec_bits_per_sample_t)); UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<const uint8_t*>( &codec_capability.channel_mode), UIPC_Send( *a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<const uint8_t*>(&codec_capability.channel_mode), sizeof(btav_a2dp_codec_channel_mode_t)); break; } Loading @@ -229,7 +233,7 @@ static void btif_a2dp_recv_ctrl_data(void) { btif_a2dp_command_ack(A2DP_CTRL_ACK_SUCCESS); // Send the current codec config if (UIPC_Read(UIPC_CH_ID_AV_CTRL, 0, if (UIPC_Read(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<uint8_t*>(&codec_config.sample_rate), sizeof(btav_a2dp_codec_sample_rate_t)) != sizeof(btav_a2dp_codec_sample_rate_t)) { Loading @@ -237,7 +241,7 @@ static void btif_a2dp_recv_ctrl_data(void) { __func__); break; } if (UIPC_Read(UIPC_CH_ID_AV_CTRL, 0, if (UIPC_Read(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<uint8_t*>(&codec_config.bits_per_sample), sizeof(btav_a2dp_codec_bits_per_sample_t)) != sizeof(btav_a2dp_codec_bits_per_sample_t)) { Loading @@ -245,7 +249,7 @@ static void btif_a2dp_recv_ctrl_data(void) { __func__); break; } if (UIPC_Read(UIPC_CH_ID_AV_CTRL, 0, if (UIPC_Read(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, reinterpret_cast<uint8_t*>(&codec_config.channel_mode), sizeof(btav_a2dp_codec_channel_mode_t)) != sizeof(btav_a2dp_codec_channel_mode_t)) { Loading @@ -270,17 +274,19 @@ static void btif_a2dp_recv_ctrl_data(void) { case A2DP_CTRL_GET_PRESENTATION_POSITION: { btif_a2dp_command_ack(A2DP_CTRL_ACK_SUCCESS); UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, (uint8_t*)&(delay_report_stats.total_bytes_read), sizeof(uint64_t)); UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, (uint8_t*)&(delay_report_stats.audio_delay), sizeof(uint16_t)); uint32_t seconds = delay_report_stats.timestamp.tv_sec; UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, (uint8_t*)&seconds, sizeof(seconds)); UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, (uint8_t*)&seconds, sizeof(seconds)); uint32_t nsec = delay_report_stats.timestamp.tv_nsec; UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, (uint8_t*)&nsec, sizeof(nsec)); UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, (uint8_t*)&nsec, sizeof(nsec)); break; } default: Loading @@ -304,7 +310,7 @@ static void btif_a2dp_ctrl_cb(UNUSED_ATTR tUIPC_CH_ID ch_id, case UIPC_CLOSE_EVT: /* restart ctrl server unless we are shutting down */ if (btif_a2dp_source_media_task_is_running()) UIPC_Open(UIPC_CH_ID_AV_CTRL, btif_a2dp_ctrl_cb); UIPC_Open(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, btif_a2dp_ctrl_cb); break; case UIPC_RX_DATA_READY_EVT: Loading @@ -329,8 +335,9 @@ static void btif_a2dp_data_cb(UNUSED_ATTR tUIPC_CH_ID ch_id, * Read directly from media task from here on (keep callback for * connection events. */ UIPC_Ioctl(UIPC_CH_ID_AV_AUDIO, UIPC_REG_REMOVE_ACTIVE_READSET, NULL); UIPC_Ioctl(UIPC_CH_ID_AV_AUDIO, UIPC_SET_READ_POLL_TMO, UIPC_Ioctl(*a2dp_uipc, UIPC_CH_ID_AV_AUDIO, UIPC_REG_REMOVE_ACTIVE_READSET, NULL); UIPC_Ioctl(*a2dp_uipc, UIPC_CH_ID_AV_AUDIO, UIPC_SET_READ_POLL_TMO, reinterpret_cast<void*>(A2DP_DATA_READ_POLL_MS)); if (btif_av_get_peer_sep() == AVDT_TSEP_SNK) { Loading Loading @@ -378,7 +385,7 @@ void btif_a2dp_command_ack(tA2DP_CTRL_ACK status) { a2dp_cmd_pending = A2DP_CTRL_CMD_NONE; /* Acknowledge start request */ UIPC_Send(UIPC_CH_ID_AV_CTRL, 0, &ack, sizeof(ack)); UIPC_Send(*a2dp_uipc, UIPC_CH_ID_AV_CTRL, 0, &ack, sizeof(ack)); } void btif_a2dp_control_log_bytes_read(uint32_t bytes_read) { Loading
system/btif/src/btif_a2dp_source.cc +7 −4 Original line number Diff line number Diff line Loading @@ -52,6 +52,8 @@ using system_bt_osi::BluetoothMetricsLogger; using system_bt_osi::A2dpSessionMetrics; extern std::unique_ptr<tUIPC_STATE> a2dp_uipc; /** * The typical runlevel of the tx queue size is ~1 buffer * but due to link flow control or thread preemption in lower Loading Loading @@ -694,13 +696,13 @@ static void btif_a2dp_source_audio_tx_stop_event(void) { // Keep track of audio data still left in the pipe btif_a2dp_control_log_bytes_read( UIPC_Read(UIPC_CH_ID_AV_AUDIO, &event, p_buf, sizeof(p_buf))); UIPC_Read(*a2dp_uipc, UIPC_CH_ID_AV_AUDIO, &event, p_buf, sizeof(p_buf))); /* Stop the timer first */ alarm_free(btif_a2dp_source_cb.media_alarm); btif_a2dp_source_cb.media_alarm = nullptr; UIPC_Close(UIPC_CH_ID_AV_AUDIO, UIPC_USER_A2DP); UIPC_Close(*a2dp_uipc, UIPC_CH_ID_AV_AUDIO); /* * Try to send acknowldegment once the media stream is Loading Loading @@ -759,7 +761,8 @@ static void btif_a2dp_source_audio_handle_timer(void) { static uint32_t btif_a2dp_source_read_callback(uint8_t* p_buf, uint32_t len) { uint16_t event; uint32_t bytes_read = UIPC_Read(UIPC_CH_ID_AV_AUDIO, &event, p_buf, len); uint32_t bytes_read = UIPC_Read(*a2dp_uipc, UIPC_CH_ID_AV_AUDIO, &event, p_buf, len); if (bytes_read < len) { LOG_WARN(LOG_TAG, "%s: UNDERFLOW: ONLY READ %d BYTES OUT OF %d", __func__, Loading Loading @@ -869,7 +872,7 @@ static void btif_a2dp_source_audio_tx_flush_event(void) { time_get_os_boottime_us(); fixed_queue_flush(btif_a2dp_source_cb.tx_audio_queue, osi_free); UIPC_Ioctl(UIPC_CH_ID_AV_AUDIO, UIPC_REQ_RX_FLUSH, nullptr); UIPC_Ioctl(*a2dp_uipc, UIPC_CH_ID_AV_AUDIO, UIPC_REQ_RX_FLUSH, nullptr); } static bool btif_a2dp_source_audio_tx_flush_req(void) { Loading
system/udrv/include/uipc.h +30 −16 Original line number Diff line number Diff line Loading @@ -37,13 +37,6 @@ typedef enum { UIPC_TX_DATA_READY_EVT = 0x0010 } tUIPC_EVENT; /* UIPC users */ typedef enum { UIPC_USER_A2DP = 0, UIPC_USER_HEARING_AID = 1, UIPC_USER_NUM = 2 } tUIPC_USER; /* * UIPC IOCTL Requests */ Loading @@ -62,12 +55,33 @@ typedef void(tUIPC_RCV_CBACK)( const char* dump_uipc_event(tUIPC_EVENT event); typedef struct { int srvfd; int fd; int read_poll_tmo_ms; int task_evt_flags; /* event flags pending to be processed in read task */ tUIPC_RCV_CBACK* cback; } tUIPC_CHAN; struct tUIPC_STATE { pthread_t tid; /* main thread id */ int running; std::recursive_mutex mutex; fd_set active_set; fd_set read_set; int max_fd; int signal_fds[2]; tUIPC_CHAN ch[UIPC_CH_NUM]; }; /** * Initialize UIPC module * * @param user User ID who uses UIPC */ void UIPC_Init(void*, int user); std::unique_ptr<tUIPC_STATE> UIPC_Init(); /** * Open a UIPC channel Loading @@ -76,15 +90,14 @@ void UIPC_Init(void*, int user); * @param p_cback Callback handler * @return true on success, otherwise false */ bool UIPC_Open(tUIPC_CH_ID ch_id, tUIPC_RCV_CBACK* p_cback); bool UIPC_Open(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id, tUIPC_RCV_CBACK* p_cback); /** * Closes a channel in UIPC or the entire UIPC module * * @param ch_id Channel ID; if ch_id is UIPC_CH_ID_ALL, then cleanup UIPC * @param user User ID who uses UIPC */ void UIPC_Close(tUIPC_CH_ID ch_id, int user); void UIPC_Close(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id); /** * Send a message over UIPC Loading @@ -95,8 +108,8 @@ void UIPC_Close(tUIPC_CH_ID ch_id, int user); * @param msglen Message length * @return true on success, otherwise false */ bool UIPC_Send(tUIPC_CH_ID ch_id, uint16_t msg_evt, const uint8_t* p_buf, uint16_t msglen); bool UIPC_Send(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id, uint16_t msg_evt, const uint8_t* p_buf, uint16_t msglen); /** * Read a message from UIPC Loading @@ -107,8 +120,8 @@ bool UIPC_Send(tUIPC_CH_ID ch_id, uint16_t msg_evt, const uint8_t* p_buf, * @param len Bytes to read * @return true on success, otherwise false */ uint32_t UIPC_Read(tUIPC_CH_ID ch_id, uint16_t* p_msg_evt, uint8_t* p_buf, uint32_t len); uint32_t UIPC_Read(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id, uint16_t* p_msg_evt, uint8_t* p_buf, uint32_t len); /** * Control the UIPC parameter Loading @@ -118,6 +131,7 @@ uint32_t UIPC_Read(tUIPC_CH_ID ch_id, uint16_t* p_msg_evt, uint8_t* p_buf, * @param param Optional parameters * @return true on success, otherwise false */ bool UIPC_Ioctl(tUIPC_CH_ID ch_id, uint32_t request, void* param); bool UIPC_Ioctl(tUIPC_STATE& uipc, tUIPC_CH_ID ch_id, uint32_t request, void* param); #endif /* UIPC_H */
system/udrv/ulinux/uipc.cc +144 −191 File changed.Preview size limit exceeded, changes collapsed. Show changes