Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions src/audio/host-zephyr.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,22 +484,18 @@ static uint32_t host_get_copy_bytes_normal(struct comp_dev *dev)
buffer_c = buffer_acquire(buffer);

/* calculate minimum size to copy */
if (dev->direction == SOF_IPC_STREAM_PLAYBACK) {
/* limit bytes per copy to one period for the whole pipeline
* in order to avoid high load spike
*/
if (dev->direction == SOF_IPC_STREAM_PLAYBACK)
free_bytes = audio_stream_get_free_bytes(&buffer_c->stream);
copy_bytes = MIN(hd->period_bytes, MIN(avail_bytes, free_bytes));
if (!copy_bytes)
comp_info(dev, "no bytes to copy, %d free in buffer, %d available in DMA",
free_bytes, avail_bytes);
} else {
else
avail_bytes = audio_stream_get_avail_bytes(&buffer_c->stream);
copy_bytes = MIN(avail_bytes, free_bytes);
if (!copy_bytes)
comp_info(dev, "no bytes to copy, %d avail in buffer, %d free in DMA",
avail_bytes, free_bytes);
}

/* limit bytes per copy to one period for the whole pipeline

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how this can work... you are combining playback and capture direction avail and free bytes with MIN? so depending on direction isn't the other value like random? So it can be like always 0 or whatever the "balance" between free and avail happens to be... or I just don't understand how free_bytes and avail_bytes works.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juimonen, the real change is: change capture copy_bytes from:
copy_bytes = MIN(avail_bytes, free_bytes);
to:
copy_bytes = MIN(hd->period_bytes, MIN(avail_bytes, free_bytes));

Since both playback and capture have same limitation for copy_bytes, then I moved out for save code space.
Please check again.

* in order to avoid high load spike
*/
copy_bytes = MIN(hd->period_bytes, MIN(avail_bytes, free_bytes));
if (!copy_bytes)
comp_info(dev, "no bytes to copy, available bytes: %d, free_bytes: %d",
avail_bytes, free_bytes);

buffer_release(buffer_c);

Expand Down