Skip to content

Commit 90b12a8

Browse files
crojewsk-intelbroonie
authored andcommitted
ALSA: Add snd_pcm_direction_name() helper
Allow for retrieving string naming a direction of a stream without the need of substream pointer. Signed-off-by: Cezary Rojewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent be1a63d commit 90b12a8

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

include/sound/pcm.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,20 @@ static inline void snd_pcm_limit_isa_dma_size(int dma, size_t *max)
13921392

13931393
const char *snd_pcm_format_name(snd_pcm_format_t format);
13941394

1395+
/**
1396+
* snd_pcm_direction_name - Get a string naming the direction of a stream
1397+
* @direction: Stream's direction, one of SNDRV_PCM_STREAM_XXX
1398+
*
1399+
* Returns a string naming the direction of the stream.
1400+
*/
1401+
static inline const char *snd_pcm_direction_name(int direction)
1402+
{
1403+
if (direction == SNDRV_PCM_STREAM_PLAYBACK)
1404+
return "Playback";
1405+
else
1406+
return "Capture";
1407+
}
1408+
13951409
/**
13961410
* snd_pcm_stream_str - Get a string naming the direction of a stream
13971411
* @substream: the pcm substream instance
@@ -1400,10 +1414,7 @@ const char *snd_pcm_format_name(snd_pcm_format_t format);
14001414
*/
14011415
static inline const char *snd_pcm_stream_str(struct snd_pcm_substream *substream)
14021416
{
1403-
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
1404-
return "Playback";
1405-
else
1406-
return "Capture";
1417+
return snd_pcm_direction_name(substream->stream);
14071418
}
14081419

14091420
/*

0 commit comments

Comments
 (0)