All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Hills <mark@xwax.org>
To: alsa-devel@alsa-project.org
Subject: [RFC PATCH 9/9] pcm: Annotate the _avail functions
Date: Fri, 12 Jun 2020 10:55:30 +0100	[thread overview]
Message-ID: <20200612095530.3970-9-mark@xwax.org> (raw)
In-Reply-To: <2006121020220.23374@stax.localdomain>

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.
---
 src/pcm/pcm_local.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/src/pcm/pcm_local.h b/src/pcm/pcm_local.h
index cf018fc0..aae58ed3 100644
--- a/src/pcm/pcm_local.h
+++ b/src/pcm/pcm_local.h
@@ -480,6 +480,13 @@ static inline int snd_pcm_check_error(snd_pcm_t *pcm, int 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,
 							 const snd_pcm_uframes_t hw_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);
 }
 
+/*
+ * \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,
 							const snd_pcm_uframes_t hw_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);
 }
 
+/*
+ * \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)
 {
 	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)
 {
 	return pcm->buffer_size - snd_pcm_mmap_capture_avail(pcm);
-- 
2.17.5


  parent reply	other threads:[~2020-06-12 10:00 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-12  9:54 alsa-lib: Bug fixes to namehint, dsnoop and minor changes Mark Hills
2020-06-12  9:55 ` [RFC PATCH 1/9] control: Fix typos in the namehint example Mark Hills
2020-06-12  9:55 ` [RFC PATCH 2/9] control: Fix a bug that prevented namehint behaviour Mark Hills
2020-06-12  9:55 ` [RFC PATCH 3/9] conf: Read a host-specific asoundrc Mark Hills
2020-06-12  9:55 ` [RFC PATCH 4/9] dsnoop: The delay presented to snd_pcm_status_delay() was incorrect Mark Hills
2020-06-12  9:55 ` [RFC PATCH 5/9] pcm: Annotate the _delay functions based on findings from the previous bug Mark Hills
2020-06-12  9:55 ` [RFC PATCH 6/9] dsnoop: The stop threshold was not implemented correctly Mark Hills
2020-06-12  9:55 ` [RFC PATCH 7/9] dsnoop: Another bug where the empty, not full, part of the ringbuffer was observed Mark Hills
2020-06-12  9:55 ` [RFC PATCH 8/9] dsnoop: Make use of the (previously unused) function Mark Hills
2020-06-12  9:55 ` Mark Hills [this message]
2020-06-22 13:11 ` alsa-lib: Bug fixes to namehint, dsnoop and minor changes Mark Hills
2020-06-22 13:15   ` [PATCH 1/9] control: Fix typos in the namehint example Mark Hills
2020-06-23 10:57     ` Takashi Iwai
2020-06-22 13:15   ` [PATCH 2/9] control: Fix a bug that prevented namehint behaviour Mark Hills
2020-06-23 10:57     ` Takashi Iwai
2020-06-22 13:15   ` [PATCH 3/9] conf: Read a host-specific asoundrc Mark Hills
2020-06-23 10:54     ` Takashi Iwai
2020-06-23 11:18       ` Mark Hills
2020-06-23 11:28         ` Takashi Iwai
2020-06-23 11:42           ` Mark Hills
2020-06-23 11:45             ` Takashi Iwai
2020-06-22 13:15   ` [PATCH 4/9] dsnoop: The delay presented to snd_pcm_status_delay() was incorrect Mark Hills
2020-06-23 10:57     ` Takashi Iwai
2020-06-22 13:15   ` [PATCH 5/9] pcm: Annotate the _delay functions based on findings from the previous bug Mark Hills
2020-06-23 10:58     ` Takashi Iwai
2020-06-22 13:15   ` [PATCH 6/9] dsnoop: The stop threshold was not implemented correctly Mark Hills
2020-06-23 10:59     ` Takashi Iwai
2020-06-22 13:15   ` [PATCH 7/9] dsnoop: Another bug where the empty, not full, part of the ringbuffer was observed Mark Hills
2020-06-23 11:00     ` Takashi Iwai
2020-06-22 13:15   ` [PATCH 8/9] dsnoop: Make use of the (previously unused) function Mark Hills
2020-06-23 11:00     ` Takashi Iwai
2020-06-22 13:15   ` [PATCH 9/9] pcm: Annotate the _avail functions Mark Hills
2020-06-23 11:01     ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200612095530.3970-9-mark@xwax.org \
    --to=mark@xwax.org \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.