mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-21 08:56:56 -05:00
alsa/acp: make pa_ato* functions behave as PA ones
The pulseaudio pa_ato* functions set errno and return -1, when the number cannot be parsed. Some parts of parsing the profile files (e.g. parse_eld_device) rely on these functions returning errors when the input is not a number.
This commit is contained in:
parent
2b102a1046
commit
d33779cd11
1 changed files with 23 additions and 10 deletions
|
|
@ -34,6 +34,9 @@ extern "C" {
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include <spa/utils/string.h>
|
||||||
|
|
||||||
typedef struct pa_core pa_core;
|
typedef struct pa_core pa_core;
|
||||||
|
|
||||||
|
|
@ -545,25 +548,35 @@ static inline char *pa_strip(char *s)
|
||||||
|
|
||||||
static inline int pa_atod(const char *s, double *ret_d)
|
static inline int pa_atod(const char *s, double *ret_d)
|
||||||
{
|
{
|
||||||
char *x;
|
if (spa_atod(s, ret_d) && !isnan(*ret_d))
|
||||||
*ret_d = strtod(s, &x);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
static inline int pa_atoi(const char *s, int32_t *ret_i)
|
static inline int pa_atoi(const char *s, int32_t *ret_i)
|
||||||
{
|
{
|
||||||
*ret_i = (int32_t) atoi(s);
|
if (spa_atoi32(s, ret_i, 0))
|
||||||
return 0;
|
return 0;
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
static inline int pa_atou(const char *s, uint32_t *ret_u)
|
static inline int pa_atou(const char *s, uint32_t *ret_u)
|
||||||
{
|
{
|
||||||
*ret_u = (uint32_t) atoi(s);
|
if (spa_atou32(s, ret_u, 0))
|
||||||
return 0;
|
return 0;
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
static inline int pa_atol(const char *s, long *ret_l)
|
static inline int pa_atol(const char *s, long *ret_l)
|
||||||
{
|
{
|
||||||
char *x;
|
int64_t res;
|
||||||
*ret_l = strtol(s, &x, 0);
|
if (spa_atoi64(s, &res, 0)) {
|
||||||
|
*ret_l = res;
|
||||||
|
if (*ret_l == res)
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int pa_parse_boolean(const char *v)
|
static inline int pa_parse_boolean(const char *v)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue