]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: hw - fix again snd_pcm_hw_state() when the driver was disconnected
authorJaroslav Kysela <perex@perex.cz>
Thu, 27 May 2021 20:01:25 +0000 (22:01 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 27 May 2021 20:01:38 +0000 (22:01 +0200)
Fixes: 2c8e31f5 ("pcm: hw - fix snd_pcm_hw_state()")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/pcm/pcm_hw.c

index b38dcb5fc914c28a949bf01add05665e4652921b..610e0ef3f48131559f7fc9ef8101fa3ba5ae3a25 100644 (file)
@@ -600,9 +600,10 @@ static int snd_pcm_hw_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
 static snd_pcm_state_t snd_pcm_hw_state(snd_pcm_t *pcm)
 {
        snd_pcm_hw_t *hw = pcm->private_data;
-       /* no error checking, the mmap state should be correct
-        * after SNDRV_PCM_IOCTL_SYNC_PTR */
-       query_status_data(hw);
+       /* the -ENODEV may come from the snd_disconnect_ioctl() in kernel */
+       /* in this case, the mmaped state is no longer updated */
+       if (query_status_data(hw) == -ENODEV)
+               return SND_PCM_STATE_DISCONNECTED;
        return (snd_pcm_state_t) hw->mmap_status->state;
 }