pcm: Annotate the _avail functions

I took time to understand these functions in the context of the
rest of the code, which would have been a lot quicker with a comment
like this.

Signed-off-by: Mark Hills <mark@xwax.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Mark Hills 2020-06-22 14:15:15 +01:00 committed by Takashi Iwai
parent 46c65dd490
commit 676e2f0811

View file

@ -480,6 +480,13 @@ static inline int snd_pcm_check_error(snd_pcm_t *pcm, int err)
return err; return err;
} }
/**
* \retval number of frames available to the application for playback
*
* This is how far ahead the hardware position in the ring buffer is,
* compared to the application position. ie. for playback it's the
* number of frames in the empty part of the ring buffer.
*/
static inline snd_pcm_uframes_t __snd_pcm_playback_avail(snd_pcm_t *pcm, static inline snd_pcm_uframes_t __snd_pcm_playback_avail(snd_pcm_t *pcm,
const snd_pcm_uframes_t hw_ptr, const snd_pcm_uframes_t hw_ptr,
const snd_pcm_uframes_t appl_ptr) const snd_pcm_uframes_t appl_ptr)
@ -498,6 +505,13 @@ static inline snd_pcm_uframes_t snd_pcm_mmap_playback_avail(snd_pcm_t *pcm)
return __snd_pcm_playback_avail(pcm, *pcm->hw.ptr, *pcm->appl.ptr); return __snd_pcm_playback_avail(pcm, *pcm->hw.ptr, *pcm->appl.ptr);
} }
/*
* \retval number of frames available to the application for capture
*
* This is how far ahead the hardware position in the ring buffer is
* compared to the application position. ie. for capture, it's the
* number of frames in the filled part of the ring buffer.
*/
static inline snd_pcm_uframes_t __snd_pcm_capture_avail(snd_pcm_t *pcm, static inline snd_pcm_uframes_t __snd_pcm_capture_avail(snd_pcm_t *pcm,
const snd_pcm_uframes_t hw_ptr, const snd_pcm_uframes_t hw_ptr,
const snd_pcm_uframes_t appl_ptr) const snd_pcm_uframes_t appl_ptr)
@ -529,11 +543,21 @@ static inline snd_pcm_uframes_t snd_pcm_mmap_avail(snd_pcm_t *pcm)
return __snd_pcm_avail(pcm, *pcm->hw.ptr, *pcm->appl.ptr); return __snd_pcm_avail(pcm, *pcm->hw.ptr, *pcm->appl.ptr);
} }
/*
* \retval number of frames available to the hardware for playback
*
* ie. the filled part of the ring buffer
*/
static inline snd_pcm_sframes_t snd_pcm_mmap_playback_hw_avail(snd_pcm_t *pcm) static inline snd_pcm_sframes_t snd_pcm_mmap_playback_hw_avail(snd_pcm_t *pcm)
{ {
return pcm->buffer_size - snd_pcm_mmap_playback_avail(pcm); return pcm->buffer_size - snd_pcm_mmap_playback_avail(pcm);
} }
/*
* \retval number of frames available to the hardware for capture
*
* ie. the empty part of the ring buffer.
*/
static inline snd_pcm_sframes_t snd_pcm_mmap_capture_hw_avail(snd_pcm_t *pcm) static inline snd_pcm_sframes_t snd_pcm_mmap_capture_hw_avail(snd_pcm_t *pcm)
{ {
return pcm->buffer_size - snd_pcm_mmap_capture_avail(pcm); return pcm->buffer_size - snd_pcm_mmap_capture_avail(pcm);