From 381283ad81c79c90c1184d5837480b144ef3c0f5 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 14 Apr 2023 19:25:51 +0200 Subject: [PATCH] alsa: handle old alsa version Out Ubuntu CI seems to have an older alsa version that doesn't have snd_pcm_channel_area_addr so include it here. --- spa/plugins/alsa/alsa-pcm.c | 6 +++--- spa/plugins/alsa/alsa-pcm.h | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c index fd941ceb3..e6badacd2 100644 --- a/spa/plugins/alsa/alsa-pcm.c +++ b/spa/plugins/alsa/alsa-pcm.c @@ -2179,7 +2179,7 @@ again: if (SPA_LIKELY(state->use_mmap)) { for (i = 0; i < b->buf->n_datas; i++) { - spa_memcpy(snd_pcm_channel_area_addr(&my_areas[i], off), + spa_memcpy(channel_area_addr(&my_areas[i], off), SPA_PTROFF(d[i].data, offs, void), n_bytes); } } else { @@ -2290,11 +2290,11 @@ push_frames(struct state *state, for (i = 0; i < b->buf->n_datas; i++) { spa_memcpy(d[i].data, - snd_pcm_channel_area_addr(&my_areas[i], offset), + channel_area_addr(&my_areas[i], offset), l0); if (SPA_UNLIKELY(l1 > 0)) spa_memcpy(SPA_PTROFF(d[i].data, l0, void), - snd_pcm_channel_area_addr(&my_areas[i], 0), + channel_area_addr(&my_areas[i], 0), l1); d[i].chunk->offset = 0; d[i].chunk->size = n_bytes; diff --git a/spa/plugins/alsa/alsa-pcm.h b/spa/plugins/alsa/alsa-pcm.h index be8972adb..e5e3afc19 100644 --- a/spa/plugins/alsa/alsa-pcm.h +++ b/spa/plugins/alsa/alsa-pcm.h @@ -353,6 +353,16 @@ static inline int ratelimit_test(struct ratelimit *r, uint64_t now) return missed; } +#if defined(SND_LIB_VER) +#if SND_LIB_VERSION >= SND_LIB_VER(1, 2, 6) +#define channel_area_addr snd_pcm_channel_area_addr +#else +static inline void *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; +} +#endif +#endif #ifdef __cplusplus } /* extern "C" */