]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: ioplug: update prepare and draining state correctly
authorTimo Wischer <twischer@de.adit-jv.com>
Fri, 16 Mar 2018 10:20:46 +0000 (11:20 +0100)
committerTakashi Iwai <tiwai@suse.de>
Fri, 16 Mar 2018 10:29:20 +0000 (11:29 +0100)
PREPARED should only be set when it is done and it was successfully.

DRAINING should be signalled when starting to drain. There is no need to
check if draining was successfully because it will change to drop (SETUP)
in any case.

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/pcm/pcm_ioplug.c

index af223a13f47397f007c2a6b46b8578b66656c13e..8c0ed4836365afb53c0cbce796a5d39c2d05a3d7 100644 (file)
@@ -146,13 +146,16 @@ static int snd_pcm_ioplug_prepare(snd_pcm_t *pcm)
        ioplug_priv_t *io = pcm->private_data;
        int err = 0;
 
-       io->data->state = SND_PCM_STATE_PREPARED;
        snd_pcm_ioplug_reset(pcm);
        if (io->data->callback->prepare) {
                snd_pcm_unlock(pcm); /* to avoid deadlock */
                err = io->data->callback->prepare(io->data);
                snd_pcm_lock(pcm);
        }
+       if (err < 0)
+               return err;
+
+       io->data->state = SND_PCM_STATE_PREPARED;
        return err;
 }
 
@@ -493,6 +496,8 @@ static int snd_pcm_ioplug_drain(snd_pcm_t *pcm)
 
        if (io->data->state == SND_PCM_STATE_OPEN)
                return -EBADFD;
+
+       io->data->state = SND_PCM_STATE_DRAINING;
        if (io->data->callback->drain)
                io->data->callback->drain(io->data);
        snd_pcm_lock(pcm);