Merge branch 'spa_bluez_follow_MediaPlayer1' into 'master'

Draft: RFC: spa: bluez: follow MediaPlayer1 objects and set media.* keys in a2dp-source

See merge request pipewire/pipewire!802
This commit is contained in:
Barnabás Pőcze 2021-08-20 09:02:01 +00:00
commit 3b79ecad7a
4 changed files with 498 additions and 14 deletions

View file

@ -307,6 +307,40 @@ static inline bool spa_atod(const char *str, double *val)
return true;
}
/**
* Find \a needle in the \a haystack array of \a n strings.
*
* \param haystack an array of \a n strings
* \param n number of strings in \a haystack
* \param cmp a three-way comparator
* \param index pointer to save the index into if \a needle is found,
* may be NULL; it is not modified if \a needle is not found
*
* \return true if \a needle is found, false otherwise
*
* \since 0.3.31
*/
static inline bool spa_find_str(const char * const haystack[], size_t n,
const char *needle,
int (*cmp)(const char *, const char *),
size_t *index)
{
for (size_t i = 0; i < n; i++) {
if (cmp(needle, haystack[i]) != 0)
continue;
if (index != NULL)
*index = i;
return true;
}
return false;
}
#define spa_find_str_arr(haystack, needle, cmp, index) \
(spa_find_str((haystack), SPA_N_ELEMENTS(haystack), (needle), (cmp), (index)))
/**
* \}
*/