]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: fix __snd_pcm_state() return value
authorJaroslav Kysela <perex@perex.cz>
Sun, 27 Dec 2020 12:29:33 +0000 (13:29 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sun, 27 Dec 2020 12:31:57 +0000 (13:31 +0100)
The __snd_pcm_state() must return a valid state, not an error value
when the plugin callback is not defined. Use the first state
SND_PCM_STATE_OPEN - the other functions will return the error
code depending on this state.

Link: https://lore.kernel.org/alsa-devel/20201226213547.175071-10-alexhenrie24@gmail.com/
Reported-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/pcm/pcm_local.h

index fe77e50def281ce81d08e77b92b31037c1c31d6e..bec5a40855dc3e1204e52837ae9e77e0060fc85a 100644 (file)
@@ -444,7 +444,7 @@ static inline int __snd_pcm_start(snd_pcm_t *pcm)
 static inline snd_pcm_state_t __snd_pcm_state(snd_pcm_t *pcm)
 {
        if (!pcm->fast_ops->state)
-               return -ENOSYS;
+               return SND_PCM_STATE_OPEN;
        return pcm->fast_ops->state(pcm->fast_op_arg);
 }