summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@perex.cz>2021-05-27 22:01:25 +0200
committerJaroslav Kysela <perex@perex.cz>2021-05-27 22:01:38 +0200
commitc7a939ee31a8a25253d9620ecea6620d48a028eb (patch)
tree566611ac17b1366a066222b3e2193c14c330fd0f
parentc8f608d67463b814f2c077c3cdae5663f3574f12 (diff)
downloadalsa-lib-c7a939ee31a8a25253d9620ecea6620d48a028eb.tar.gz
pcm: hw - fix again snd_pcm_hw_state() when the driver was disconnected
Fixes: 2c8e31f5 ("pcm: hw - fix snd_pcm_hw_state()") Signed-off-by: Jaroslav Kysela <perex@perex.cz>
-rw-r--r--src/pcm/pcm_hw.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index b38dcb5f..610e0ef3 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -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;
}