aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Biehl Pasquali <pasqualirb@gmail.com>2018-09-09 21:40:01 -0300
committerRicardo Biehl Pasquali <pasqualirb@gmail.com>2019-01-08 13:06:18 -0200
commit7c40a9ecde0150049bf1b04a9fbf0fd437c16043 (patch)
treec2781ff77862745210be8f38d1b4ca97be2cfd6b
parent13bf6299d4f6907bcdc97729a17c6172d46637c9 (diff)
pcm: Move prepare action to xrun handling
Signed-off-by: Ricardo Biehl Pasquali <pasqualirb@gmail.com>
-rw-r--r--src/pcm.c5
1 files changed, 2 insertions, 3 deletions
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");