[PATCH 8/9] pcm: fix undefined bit shift in bad_pcm_state

Alex Henrie alexhenrie24 at gmail.com
Sat Dec 26 22:35:46 CET 2020


Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
---
 include/pcm.h       | 4 +++-
 src/pcm/pcm.c       | 2 ++
 src/pcm/pcm_local.h | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/pcm.h b/include/pcm.h
index e300b951..c6c5d8f8 100644
--- a/include/pcm.h
+++ b/include/pcm.h
@@ -307,7 +307,9 @@ typedef enum _snd_pcm_state {
 	SND_PCM_STATE_SUSPENDED,
 	/** Hardware is disconnected */
 	SND_PCM_STATE_DISCONNECTED,
-	SND_PCM_STATE_LAST = SND_PCM_STATE_DISCONNECTED,
+	/** State cannot be queried */
+	SND_PCM_STATE_UNKNOWN,
+	SND_PCM_STATE_LAST = SND_PCM_STATE_UNKNOWN,
 	/** Private - used internally in the library - do not use*/
 	SND_PCM_STATE_PRIVATE1 = 1024
 } snd_pcm_state_t;
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index 24030b31..5fafc2a0 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -680,6 +680,8 @@ static int pcm_state_to_error(snd_pcm_state_t state)
 		return -ESTRPIPE;
 	case SND_PCM_STATE_DISCONNECTED:
 		return -ENODEV;
+	case SND_PCM_STATE_UNKNOWN:
+		return -ENOSYS;
 	default:
 		return 0;
 	}
diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h
index fe77e50d..04f89623 100644
--- a/src/pcm/pcm_local.h
+++ b/src/pcm/pcm_local.h
@@ -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_UNKNOWN;
 	return pcm->fast_ops->state(pcm->fast_op_arg);
 }
 
-- 
2.29.2.368.ge46b91665e.dirty



More information about the Alsa-devel mailing list