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

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

 



Hi Amadeusz

Thank you for comment

> > 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>
> > ---
(snip)
> Perhaps you could use generics here, so you could have one caller for
> both cases?
> 
> Something like:
> #define snd_pcm_is_playback(x) _Generic((x),                   \
>         int :         (x == SNDRV_PCM_STREAM_PLAYBACK), \
>         struct snd_pcm_substream *substream * : (x->stream ==
> SNDRV_PCM_STREAM_PLAYBACK))(x)
> or just call the above functions in it?

Actually, I have tried _Generic() first, but changed to current style,
because many drivers are using own direction variable, and they are using
own variable types. But I think more again.

Thank you for your help !!

Best regards
---
Kuninori Morimoto



[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