diff options
author | Volker RĂ¼melin <vr_qemu@t-online.de> | 2022-03-01 20:12:57 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2022-03-04 11:05:13 +0100 |
commit | 18404ff111e43d218b36b69ae002cae58acef352 (patch) | |
tree | c9bdc100da5ea814ef10c2d5c6b0d7c43cd463a9 /audio/audio_int.h | |
parent | 3a4d06f26f2606dd5029b05b4aff97f198455249 (diff) |
audio: replace open-coded buffer arithmetic
Replace open-coded buffer arithmetic with the new function
audio_ring_posb(). That's the position in backward direction
of a given point at a given distance.
Signed-off-by: Volker RĂ¼melin <vr_qemu@t-online.de>
Reviewed-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Message-Id: <20220301191311.26695-1-vr_qemu@t-online.de>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'audio/audio_int.h')
-rw-r--r-- | audio/audio_int.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/audio/audio_int.h b/audio/audio_int.h index 428a091d05..71be162271 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -266,6 +266,19 @@ static inline size_t audio_ring_dist(size_t dst, size_t src, size_t len) return (dst >= src) ? (dst - src) : (len - src + dst); } +/** + * audio_ring_posb() - returns new position in ringbuffer in backward + * direction at given distance + * + * @pos: current position in ringbuffer + * @dist: distance in ringbuffer to walk in reverse direction + * @len: size of ringbuffer + */ +static inline size_t audio_ring_posb(size_t pos, size_t dist, size_t len) +{ + return pos >= dist ? pos - dist : len - dist + pos; +} + #define dolog(fmt, ...) AUD_log(AUDIO_CAP, fmt, ## __VA_ARGS__) #ifdef DEBUG |