mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
context: fall back to default rate in case of errors
When the allowed rates does not contain the default rate, also fall back to only the default rate. See the configured rates in the properties so it can be inspected.
This commit is contained in:
parent
df92c09ff5
commit
11cb77c577
1 changed files with 12 additions and 10 deletions
|
|
@ -137,6 +137,15 @@ static bool get_default_bool(struct pw_properties *properties, const char *name,
|
|||
return val;
|
||||
}
|
||||
|
||||
static bool rates_contains(uint32_t *rates, uint32_t n_rates, uint32_t rate)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < n_rates; i++)
|
||||
if (rates[i] == rate)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static uint32_t parse_clock_rate(struct pw_properties *properties, const char *name,
|
||||
uint32_t *rates, uint32_t def)
|
||||
{
|
||||
|
|
@ -157,11 +166,13 @@ static uint32_t parse_clock_rate(struct pw_properties *properties, const char *n
|
|||
if (spa_atou32(v, &r, 0))
|
||||
rates[count++] = r;
|
||||
}
|
||||
if (count == 0)
|
||||
if (count == 0 ||!rates_contains(rates, count, def))
|
||||
goto fallback;
|
||||
|
||||
return count;
|
||||
fallback:
|
||||
rates[0] = def;
|
||||
pw_properties_setf(properties, name, "[ %u ]", def);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -1048,15 +1059,6 @@ static inline uint32_t *get_rates(struct pw_context *context, uint32_t *def, uin
|
|||
return s->clock_rates;
|
||||
}
|
||||
}
|
||||
static bool rates_contains(uint32_t *rates, uint32_t n_rates, uint32_t rate)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < n_rates; i++)
|
||||
if (rates[i] == rate)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void suspend_driver(struct pw_context *context, struct pw_impl_node *n)
|
||||
{
|
||||
struct pw_impl_node *s;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue