Skip to content

Commit 938fc33

Browse files
committed
ASoC: SOF: ipc4-pcm: do not report invalid delay values
If the stream hits an xrun condition, the delay calculation results in invalid, very large values. The application has no way to interpret these values as it doesn't know the internal boundary limits used in delay calculation. Add a sanity to check the delay value before it is reported back. If it's clearly invalid, return a zero delay and emit a rate limited warning to kernel log. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent f666a0a commit 938fc33

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sound/soc/sof/ipc4-pcm.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ struct sof_ipc4_pcm_stream_priv {
5959
*/
6060
#define DELAY_BOUNDARY U32_MAX
6161

62+
#define DELAY_MAX (DELAY_BOUNDARY >> 1)
63+
6264
static inline struct sof_ipc4_timestamp_info *
6365
sof_ipc4_sps_to_time_info(struct snd_sof_pcm_stream *sps)
6466
{
@@ -1260,6 +1262,12 @@ static int sof_ipc4_pcm_pointer(struct snd_soc_component *component,
12601262
else
12611263
time_info->delay = head_cnt - tail_cnt;
12621264

1265+
if (time_info->delay > DELAY_MAX) {
1266+
dev_dbg_ratelimited(sdev->dev,
1267+
"inaccurate delay, host %llu dai_cnt %llu", host_cnt, dai_cnt);
1268+
time_info->delay = 0;
1269+
}
1270+
12631271
/*
12641272
* Convert the host byte counter to PCM pointer which wraps in buffer
12651273
* and it is in frames

0 commit comments

Comments
 (0)