mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
spa: add macro to simplify array iterations some more
uint32_t i; for (i = 0; i < SPA_N_ELEMENTS(some_array); i++) .. stuff with some_array[i].foo ... becomes: SPA_FOR_EACH_ELEMENT_VAR(some_array, p) .. stuff with p->foo ..
This commit is contained in:
parent
365ebcda9b
commit
d22feab92a
21 changed files with 113 additions and 150 deletions
|
|
@ -638,12 +638,10 @@ static const struct format_info format_info[] = {
|
|||
|
||||
static snd_pcm_format_t spa_format_to_alsa(uint32_t format, bool *planar)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < SPA_N_ELEMENTS(format_info); i++) {
|
||||
*planar = format_info[i].spa_pformat == format;
|
||||
if (format_info[i].spa_format == format || *planar)
|
||||
return format_info[i].format;
|
||||
SPA_FOR_EACH_ELEMENT_VAR(format_info, i) {
|
||||
*planar = i->spa_pformat == format;
|
||||
if (i->spa_format == format || *planar)
|
||||
return i->format;
|
||||
}
|
||||
return SND_PCM_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
|
@ -969,7 +967,7 @@ static int enum_pcm_formats(struct state *state, uint32_t index, uint32_t *next,
|
|||
struct spa_pod **result, struct spa_pod_builder *b)
|
||||
{
|
||||
int res, err;
|
||||
size_t i, j;
|
||||
size_t j;
|
||||
snd_pcm_t *hndl;
|
||||
snd_pcm_hw_params_t *params;
|
||||
struct spa_pod_frame f[2];
|
||||
|
|
@ -1020,8 +1018,10 @@ static int enum_pcm_formats(struct state *state, uint32_t index, uint32_t *next,
|
|||
spa_pod_builder_push_choice(b, &f[1], SPA_CHOICE_None, 0);
|
||||
choice = (struct spa_pod_choice*)spa_pod_builder_frame(b, &f[1]);
|
||||
|
||||
for (i = 1, j = 0; i < SPA_N_ELEMENTS(format_info); i++) {
|
||||
const struct format_info *fi = &format_info[i];
|
||||
j = 0;
|
||||
SPA_FOR_EACH_ELEMENT_VAR(format_info, fi) {
|
||||
if (fi->format == SND_PCM_FORMAT_UNKNOWN)
|
||||
continue;
|
||||
|
||||
if (snd_pcm_format_mask_test(fmask, fi->format)) {
|
||||
if ((snd_pcm_access_mask_test(amask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED) ||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue