summaryrefslogtreecommitdiff
path: root/src/class
diff options
context:
space:
mode:
Diffstat (limited to 'src/class')
-rw-r--r--src/class/audio/audio_device.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/class/audio/audio_device.c b/src/class/audio/audio_device.c
index f19f8f6fe..fc5402834 100644
--- a/src/class/audio/audio_device.c
+++ b/src/class/audio/audio_device.c
@@ -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];
- 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;
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
if (info.len_wrap != 0)
{