diff options
author | Takashi Iwai <tiwai@suse.de> | 2018-04-11 17:56:52 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2018-04-17 07:37:13 +0200 |
commit | 763e5067aac91ce569a8b1212e6c31968bc7d325 (patch) | |
tree | 0cad6a8be1127348f7a5fecf2bbe16b6ee38aa58 /sound/core/pcm_local.h | |
parent | 057666b69b1d51feb389a17ec73722b001aaf3d0 (diff) | |
download | talos-op-linux-763e5067aac91ce569a8b1212e6c31968bc7d325.tar.gz talos-op-linux-763e5067aac91ce569a8b1212e6c31968bc7d325.zip |
ALSA: pcm: Clean up with snd_pcm_avail() and snd_pcm_hw_avail() helpers
Introduce two new direction-neutral helpers to calculate the avail and
hw_avail values, and clean up the code with them.
The two separated forward and rewind functions are gathered to the
unified functions.
No functional change but only code reductions.
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/pcm_local.h')
-rw-r--r-- | sound/core/pcm_local.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sound/core/pcm_local.h b/sound/core/pcm_local.h index 16f254732b2a..7a499d02df6c 100644 --- a/sound/core/pcm_local.h +++ b/sound/core/pcm_local.h @@ -36,6 +36,24 @@ int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream); void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_uframes_t new_hw_ptr); +static inline snd_pcm_uframes_t +snd_pcm_avail(struct snd_pcm_substream *substream) +{ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + return snd_pcm_playback_avail(substream->runtime); + else + return snd_pcm_capture_avail(substream->runtime); +} + +static inline snd_pcm_uframes_t +snd_pcm_hw_avail(struct snd_pcm_substream *substream) +{ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + return snd_pcm_playback_hw_avail(substream->runtime); + else + return snd_pcm_capture_hw_avail(substream->runtime); +} + #ifdef CONFIG_SND_PCM_TIMER void snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream); void snd_pcm_timer_init(struct snd_pcm_substream *substream); |