Skip to content

Commit 41bdc0c

Browse files
ujfalusikv2019i
authored andcommitted
copier: Use correct multiplier for latency to bytes calculation
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]>
1 parent aaf2f11 commit 41bdc0c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/audio/copier/copier.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ static int copier_comp_trigger(struct comp_dev *dev, int cmd)
390390

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

415415
buffer = list_first_item(&dai_copier->bsource_list, struct comp_buffer, sink_list);
416-
pipe_reg.stream_start_offset += latency * audio_stream_get_size(&buffer->stream);
416+
pipe_reg.stream_start_offset += latency *
417+
audio_stream_period_bytes(&buffer->stream, dev->frames);
417418
mailbox_sw_regs_write(cd->pipeline_reg_offset, &pipe_reg.stream_start_offset,
418419
sizeof(pipe_reg.stream_start_offset));
419420
}

0 commit comments

Comments
 (0)