]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: Move snd_pcm_channel_area_addr() and _step() to public header
authorTakashi Iwai <tiwai@suse.de>
Mon, 21 Jun 2021 12:21:26 +0000 (14:21 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 21 Jun 2021 12:22:36 +0000 (14:22 +0200)
Used in the rate plugins commonly.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/pcm.h
src/pcm/pcm_local.h

index e300b951c076c112cf862cf777f6b01c84242583..b5a514fa6cbee11a4b0bed4eb55e8e6dc9558504 100644 (file)
@@ -1173,6 +1173,29 @@ int snd_pcm_areas_copy_wrap(const snd_pcm_channel_area_t *dst_channels,
                            snd_pcm_uframes_t frames,
                            const snd_pcm_format_t format);
 
+/**
+ * \brief get the address of the given PCM channel area
+ * \param area PCM channel area
+ * \param offset Offset in frames
+ *
+ * Returns the pointer corresponding to the given offset on the channel area.
+ */
+static inline void *snd_pcm_channel_area_addr(const snd_pcm_channel_area_t *area, snd_pcm_uframes_t offset)
+{
+       return (char *)area->addr + (area->first + area->step * offset) / 8;
+}
+
+/**
+ * \brief get the step size of the given PCM channel area in bytes
+ * \param area PCM channel area
+ *
+ * Returns the step size in bytes from the given channel area.
+ */
+static inline unsigned int snd_pcm_channel_area_step(const snd_pcm_channel_area_t *area)
+{
+       return area->step / 8;
+}
+
 /** \} */
 
 /**
index a63f4be0a06a9c503badf7f8048d4183cee6e75f..6f03365ccd09964ce0885c1658b26ff03b9c7e85 100644 (file)
@@ -632,19 +632,6 @@ static inline snd_pcm_sframes_t snd_pcm_mmap_delay(snd_pcm_t *pcm)
                return snd_pcm_mmap_capture_delay(pcm);
 }
 
-static inline void *snd_pcm_channel_area_addr(const snd_pcm_channel_area_t *area, snd_pcm_uframes_t offset)
-{
-       unsigned int bitofs = area->first + area->step * offset;
-       assert(bitofs % 8 == 0);
-       return (char *) area->addr + bitofs / 8;
-}
-
-static inline unsigned int snd_pcm_channel_area_step(const snd_pcm_channel_area_t *area)
-{
-       assert(area->step % 8 == 0);
-       return area->step / 8;
-}
-
 static inline snd_pcm_sframes_t _snd_pcm_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size)
 {
        /* lock handled in the callback */