[RFC 01/xx] ALSA: add snd_stream_is_playback/capture() macro

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Many drivers are using below code to know the direction.

	if (direction == SNDRV_PCM_STREAM_PLAYBACK)

Add snd_stream_is_playback/capture() macro to handle it.
It also adds snd_substream_is_playback/capture() to handle
snd_pcm_substream.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>
---
 include/sound/pcm.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 3edd7a7346daa..024dc2b337154 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -501,6 +501,25 @@ struct snd_pcm_substream {
 
 #define SUBSTREAM_BUSY(substream) ((substream)->ref_count > 0)
 
+static inline int snd_stream_is_playback(int stream)
+{
+	return stream == SNDRV_PCM_STREAM_PLAYBACK;
+}
+
+static inline int snd_stream_is_capture(int stream)
+{
+	return stream == SNDRV_PCM_STREAM_CAPTURE;
+}
+
+static inline int snd_substream_is_playback(const struct snd_pcm_substream *substream)
+{
+	return snd_stream_is_playback(substream->stream);
+}
+
+static inline int snd_substream_is_capture(const struct snd_pcm_substream *substream)
+{
+	return snd_stream_is_capture(substream->stream);
+}
 
 struct snd_pcm_str {
 	int stream;				/* stream (direction) */
-- 
2.43.0




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux