mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
Remove variable n in tu_fifo_get_read_info()
This commit is contained in:
parent
de933c45bc
commit
14e2c004cd
@ -985,13 +985,19 @@ static uint16_t audiod_encode_type_I_pcm(uint8_t rhport, audiod_function_t* audi
|
|||||||
{
|
{
|
||||||
dst = &audio->lin_buf_in[cnt_ff*audio->n_channels_per_ff_tx*audio->n_bytes_per_sampe_tx];
|
dst = &audio->lin_buf_in[cnt_ff*audio->n_channels_per_ff_tx*audio->n_bytes_per_sampe_tx];
|
||||||
|
|
||||||
tu_fifo_get_read_info(&audio->tx_supp_ff[cnt_ff], &info, nBytesPerFFToSend);
|
tu_fifo_get_read_info(&audio->tx_supp_ff[cnt_ff], &info);
|
||||||
|
|
||||||
if (info.ptr_lin != 0)
|
// Limit up to desired length
|
||||||
|
info.len_lin = tu_min16(nBytesPerFFToSend, info.len_lin);
|
||||||
|
|
||||||
|
if (info.len_lin != 0)
|
||||||
{
|
{
|
||||||
src_end = info.ptr_lin + info.len_lin;
|
src_end = info.ptr_lin + info.len_lin;
|
||||||
dst = audiod_interleaved_copy_bytes_fast_encode(nBytesToCopy, info.ptr_lin, src_end, dst, n_ff_used);
|
dst = audiod_interleaved_copy_bytes_fast_encode(nBytesToCopy, info.ptr_lin, src_end, dst, n_ff_used);
|
||||||
|
|
||||||
|
// Limit up to desired length
|
||||||
|
info.len_wrap = tu_min16(nBytesPerFFToSend - info.len_lin, info.len_wrap);
|
||||||
|
|
||||||
// Handle wrapped part of FIFO
|
// Handle wrapped part of FIFO
|
||||||
if (info.len_wrap != 0)
|
if (info.len_wrap != 0)
|
||||||
{
|
{
|
||||||
|
@ -896,7 +896,7 @@ void tu_fifo_advance_read_pointer(tu_fifo_t *f, uint16_t n)
|
|||||||
Pointer to struct which holds the desired infos
|
Pointer to struct which holds the desired infos
|
||||||
*/
|
*/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
void tu_fifo_get_read_info(tu_fifo_t *f, tu_fifo_buffer_info_t *info, uint16_t n)
|
void tu_fifo_get_read_info(tu_fifo_t *f, tu_fifo_buffer_info_t *info)
|
||||||
{
|
{
|
||||||
// Operate on temporary values in case they change in between
|
// Operate on temporary values in case they change in between
|
||||||
uint16_t w = f->wr_idx, r = f->rd_idx;
|
uint16_t w = f->wr_idx, r = f->rd_idx;
|
||||||
@ -923,8 +923,6 @@ void tu_fifo_get_read_info(tu_fifo_t *f, tu_fifo_buffer_info_t *info, uint16_t n
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cnt < n) n = cnt;
|
|
||||||
|
|
||||||
// Get relative pointers
|
// Get relative pointers
|
||||||
w = get_relative_pointer(f, w);
|
w = get_relative_pointer(f, w);
|
||||||
r = get_relative_pointer(f, r);
|
r = get_relative_pointer(f, r);
|
||||||
@ -935,14 +933,14 @@ void tu_fifo_get_read_info(tu_fifo_t *f, tu_fifo_buffer_info_t *info, uint16_t n
|
|||||||
// Check if there is a wrap around necessary
|
// Check if there is a wrap around necessary
|
||||||
if (w > r) {
|
if (w > r) {
|
||||||
// Non wrapping case
|
// Non wrapping case
|
||||||
info->len_lin = tu_min16(n, w - r); // Limit to required length
|
info->len_lin = cnt;
|
||||||
info->len_wrap = 0;
|
info->len_wrap = 0;
|
||||||
info->ptr_wrap = NULL;
|
info->ptr_wrap = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
info->len_lin = tu_min16(n, f->depth - r); // Also the case if FIFO was full
|
info->len_lin = f->depth - r; // Also the case if FIFO was full
|
||||||
info->len_wrap = n-info->len_lin;
|
info->len_wrap = cnt - info->len_lin;
|
||||||
info->ptr_wrap = f->buffer;
|
info->ptr_wrap = f->buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ void tu_fifo_advance_read_pointer (tu_fifo_t *f, uint16_t n);
|
|||||||
// tu_fifo_advance_read_pointer()/tu_fifo_advance_write_pointer and conduct a second read/write operation
|
// tu_fifo_advance_read_pointer()/tu_fifo_advance_write_pointer and conduct a second read/write operation
|
||||||
// TODO - update comments
|
// TODO - update comments
|
||||||
|
|
||||||
void tu_fifo_get_read_info(tu_fifo_t *f, tu_fifo_buffer_info_t *info, uint16_t n);
|
void tu_fifo_get_read_info(tu_fifo_t *f, tu_fifo_buffer_info_t *info);
|
||||||
void tu_fifo_get_write_info(tu_fifo_t *f, tu_fifo_buffer_info_t *info, uint16_t n);
|
void tu_fifo_get_write_info(tu_fifo_t *f, tu_fifo_buffer_info_t *info, uint16_t n);
|
||||||
|
|
||||||
static inline uint16_t tu_fifo_depth(tu_fifo_t* f)
|
static inline uint16_t tu_fifo_depth(tu_fifo_t* f)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user