Lines Matching +full:start +full:- +full:from +full:- +full:right
9 * SPDX-License-Identifier: Apache-2.0
65 /* USB consumer callback, called every 1ms, consumes data from ring-buffer */
74 /* no-op as we have no streams that receive data */ in usb_data_request_cb()
84 /* This may fail without causing issues since usb_audio_data is 0-initialized */ in usb_data_request_cb()
136 /* Send frames to USB - If we only have a single channel we mix it to stereo */ in bap_usb_send_frames_to_usb()
225 return -EINVAL; in bap_usb_add_frame_to_usb()
231 return -EINVAL; in bap_usb_add_frame_to_usb()
237 LOG_DBG("Cannot mix and match mono with left or right"); in bap_usb_add_frame_to_usb()
239 return -EINVAL; in bap_usb_add_frame_to_usb()
242 /* Check if the frame can be combined with a previous frame from another channel, of if in bap_usb_add_frame_to_usb()
246 * same, there are additional checks to see if we have received more left than right frames, in bap_usb_add_frame_to_usb()
252 return -ENOEXEC; in bap_usb_add_frame_to_usb()
254 /* We are getting new data - Send existing data to ring buffer */ in bap_usb_add_frame_to_usb()
260 /* We are receiving left again before a right, send to USB */ in bap_usb_add_frame_to_usb()
263 /* We are receiving right again before a left, send to USB */ in bap_usb_add_frame_to_usb()
279 return -ENOMEM; in bap_usb_add_frame_to_usb()
285 LOG_WRN("Could not add more right frames"); in bap_usb_add_frame_to_usb()
287 return -ENOMEM; in bap_usb_add_frame_to_usb()
296 return -ENOMEM; in bap_usb_add_frame_to_usb()
304 return -EINVAL; in bap_usb_add_frame_to_usb()
329 return (USB_SAMPLE_CNT * sh_stream->lc3_frame_duration_us) / USEC_PER_MSEC; in bap_usb_get_read_cnt()
339 if (sh_stream->is_tx) { in stream_cb()
341 (sh_stream->lc3_chan_allocation & BT_AUDIO_LOCATION_FRONT_LEFT) != 0; in stream_cb()
343 (sh_stream->lc3_chan_allocation & BT_AUDIO_LOCATION_FRONT_RIGHT) != 0; in stream_cb()
345 const bool is_mono = sh_stream->lc3_chan_allocation == BT_AUDIO_LOCATION_MONO_AUDIO; in stream_cb()
352 read_idx = MIN(sh_stream->tx.left_read_idx, sh_stream->tx.right_read_idx); in stream_cb()
354 read_idx = sh_stream->tx.left_read_idx; in stream_cb()
356 read_idx = sh_stream->tx.right_read_idx; in stream_cb()
367 sh_stream->tx.left_read_idx = write_index; in stream_cb()
368 sh_stream->tx.right_read_idx = write_index; in stream_cb()
390 pcm = (int16_t *)buf->data; in usb_data_received_cb()
392 /* Split the data into left and right as LC3 uses LLLLRRRR instead of LRLRLRLR as USB in usb_data_received_cb()
394 * Since the left and right buffer sizes are a factor of USB_SAMPLE_CNT, then we can always in usb_data_received_cb()
406 /* Overflow so that we start overwriting oldest */ in usb_data_received_cb()
424 const bool has_left = (sh_stream->lc3_chan_allocation & BT_AUDIO_LOCATION_FRONT_LEFT) != 0; in bap_usb_can_get_full_sdu()
426 (sh_stream->lc3_chan_allocation & BT_AUDIO_LOCATION_FRONT_RIGHT) != 0; in bap_usb_can_get_full_sdu()
428 const bool is_mono = sh_stream->lc3_chan_allocation == BT_AUDIO_LOCATION_MONO_AUDIO; in bap_usb_can_get_full_sdu()
430 const uint32_t retrieve_cnt = read_cnt * sh_stream->lc3_frame_blocks_per_sdu; in bap_usb_can_get_full_sdu()
437 read_idx = MIN(sh_stream->tx.left_read_idx, sh_stream->tx.right_read_idx); in bap_usb_can_get_full_sdu()
439 read_idx = sh_stream->tx.left_read_idx; in bap_usb_can_get_full_sdu()
441 read_idx = sh_stream->tx.right_read_idx; in bap_usb_can_get_full_sdu()
447 buffer_cnt = write_index - read_idx; in bap_usb_can_get_full_sdu()
450 buffer_cnt = write_index + (USB_IN_RING_BUF_SIZE - read_idx); in bap_usb_can_get_full_sdu()
471 * Reads @p size octets from src, handling wrapping and returns the new idx
493 const size_t first_read_cnt = USB_IN_RING_BUF_SIZE - idx; in usb_ring_buf_get()
494 const size_t second_read_cnt = cnt - first_read_cnt; in usb_ring_buf_get()
514 sh_stream->tx.left_read_idx = usb_ring_buf_get( in bap_usb_get_frame()
515 buffer, usb_in_left_ring_buffer, sh_stream->tx.left_read_idx, read_cnt); in bap_usb_get_frame()
517 sh_stream->tx.right_read_idx = usb_ring_buf_get( in bap_usb_get_frame()
518 buffer, usb_in_right_ring_buffer, sh_stream->tx.right_read_idx, read_cnt); in bap_usb_get_frame()
539 return -EIO; in bap_usb_init()
556 err -= NRFX_ERROR_BASE_NUM; in bap_usb_init()