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.
This commit is contained in:
Wim Taymans 2023-04-14 19:25:51 +02:00
parent a8770d501c
commit 381283ad81
2 changed files with 13 additions and 3 deletions

View file

@ -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;

View file

@ -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" */