Skip to content

Commit e661c48

Browse files
committed
ALSA: pcm: Handle XRUN at trigger START
When the driver returns -EPIPE for indicating an XRUN already at PCM trigger START, we should treat properly and set it to the XRUN state. Otherwise the state is missing and the application would try to issue trigger again without knowing that it's in an error state. This is just for a theoretical bug, and it won't happen in most cases. Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 5c8cc93 commit e661c48

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sound/core/pcm_native.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1424,9 +1424,15 @@ static int snd_pcm_pre_start(struct snd_pcm_substream *substream,
14241424
static int snd_pcm_do_start(struct snd_pcm_substream *substream,
14251425
snd_pcm_state_t state)
14261426
{
1427+
int err;
1428+
14271429
if (substream->runtime->trigger_master != substream)
14281430
return 0;
1429-
return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_START);
1431+
err = substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_START);
1432+
/* XRUN happened during the start */
1433+
if (err == -EPIPE)
1434+
__snd_pcm_set_state(substream->runtime, SNDRV_PCM_STATE_XRUN);
1435+
return err;
14301436
}
14311437

14321438
static void snd_pcm_undo_start(struct snd_pcm_substream *substream,

0 commit comments

Comments
 (0)