Skip to content

Commit

Permalink
copier: Use correct multiplier for latency to bytes calculation
Browse files Browse the repository at this point in the history
The latency value is in number of periods (1ms) while the buffer allocated
for the DAI copier is at least 2 periods.
This can shoot up the calculated  stream_start_offset resulting invalid
delay reporting.
Use the period size of the DAI copier to correct this error.

The kernel reported delay currently (on normal non DeepBuffer PCM):
at start: ~302 frames
after 20x pause/resume: ~6530 frames

With this patch:
at start: ~254 frames
after 20x pause/resume: ~3600 frames

The drift rate is about the same with DeepBuffer.

Signed-off-by: Peter Ujfalusi <[email protected]>
  • Loading branch information
ujfalusi authored and kv2019i committed Mar 26, 2024
1 parent aaf2f11 commit 41bdc0c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/audio/copier/copier.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ static int copier_comp_trigger(struct comp_dev *dev, int cmd)

buffer = list_first_item(&dai_copier->bsource_list, struct comp_buffer, sink_list);
pipe_reg.stream_start_offset = posn.dai_posn +
latency * audio_stream_get_size(&buffer->stream);
latency * audio_stream_period_bytes(&buffer->stream, dev->frames);
pipe_reg.stream_end_offset = 0;
mailbox_sw_regs_write(cd->pipeline_reg_offset, &pipe_reg, sizeof(pipe_reg));
} else if (cmd == COMP_TRIGGER_PAUSE) {
Expand All @@ -413,7 +413,8 @@ static int copier_comp_trigger(struct comp_dev *dev, int cmd)
}

buffer = list_first_item(&dai_copier->bsource_list, struct comp_buffer, sink_list);
pipe_reg.stream_start_offset += latency * audio_stream_get_size(&buffer->stream);
pipe_reg.stream_start_offset += latency *
audio_stream_period_bytes(&buffer->stream, dev->frames);
mailbox_sw_regs_write(cd->pipeline_reg_offset, &pipe_reg.stream_start_offset,
sizeof(pipe_reg.stream_start_offset));
}
Expand Down

0 comments on commit 41bdc0c

Please sign in to comment.