From 7c40a9ecde0150049bf1b04a9fbf0fd437c16043 Mon Sep 17 00:00:00 2001 From: Ricardo Biehl Pasquali Date: Sun, 9 Sep 2018 21:40:01 -0300 Subject: pcm: Move prepare action to xrun handling Signed-off-by: Ricardo Biehl Pasquali --- src/pcm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/pcm.c b/src/pcm.c index f854a94..43e8279 100644 --- a/src/pcm.c +++ b/src/pcm.c @@ -704,9 +704,6 @@ int pcm_writei(struct pcm *pcm, const void *data, unsigned int frame_count) x.result = 0; for (;;) { if (!pcm->running) { - int prepare_error = pcm_prepare(pcm); - if (prepare_error) - return prepare_error; if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_WRITEI_FRAMES, &x)) return oops(pcm, errno, "cannot write initial data"); pcm->running = 1; @@ -722,6 +719,8 @@ int pcm_writei(struct pcm *pcm, const void *data, unsigned int frame_count) pcm->underruns++; if (pcm->flags & PCM_NORESTART) return -EPIPE; + if (pcm_prepare(pcm)) + return -EPIPE; continue; } return oops(pcm, errno, "cannot write stream data"); -- cgit v1.2.3