summaryrefslogtreecommitdiff
path: root/sound/core/pcm_native.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2022-12-05 14:21:23 +0100
committerTakashi Iwai <tiwai@suse.de>2022-12-05 14:22:48 +0100
commite661c4886965e6f48d9378d8608f1d7dd7401a41 (patch)
tree4e59172e8b6d8ab4dca7aedc7fa9581b7febb267 /sound/core/pcm_native.c
parent5c8cc93b06d1ff860327a273abf3ac006290d242 (diff)
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/b4e71631-4a94-613-27b2-fb595792630@carlh.net Link: https://lore.kernel.org/r/20221205132124.11585-3-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/pcm_native.c')
-rw-r--r--sound/core/pcm_native.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index e3deec62b9a1..9c122e757efe 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -1424,9 +1424,15 @@ static int snd_pcm_pre_start(struct snd_pcm_substream *substream,
static int snd_pcm_do_start(struct snd_pcm_substream *substream,
snd_pcm_state_t state)
{
+ int err;
+
if (substream->runtime->trigger_master != substream)
return 0;
- return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_START);
+ err = substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_START);
+ /* XRUN happened during the start */
+ if (err == -EPIPE)
+ __snd_pcm_set_state(substream->runtime, SNDRV_PCM_STATE_XRUN);
+ return err;
}
static void snd_pcm_undo_start(struct snd_pcm_substream *substream,