mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
pulse-server: use PipeWire format and channel names
Use the PipeWire format and channel names in the config to avoid confusion.
This commit is contained in:
parent
b305f57e4d
commit
44e6e7f5c8
3 changed files with 32 additions and 6 deletions
|
|
@ -40,8 +40,8 @@ context.modules = [
|
|||
#pulse.default.frag = 96000/48000 # 2 seconds
|
||||
#pulse.default.tlength = 96000/48000 # 2 seconds
|
||||
#pulse.min.quantum = 256/48000 # 5ms
|
||||
#pulse.default.format = "float32ne"
|
||||
#pulse.default.channel_map = "front-left,front-right"
|
||||
#pulse.default.format = F32LE
|
||||
#pulse.default.position = [ FL FR ]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -117,6 +117,15 @@ static inline const char *format_id2name(uint32_t format)
|
|||
}
|
||||
return "UNKNOWN";
|
||||
}
|
||||
static inline uint32_t format_name2id(const char *name)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; spa_type_audio_format[i].name; i++) {
|
||||
if (strcmp(name, spa_debug_type_short_name(spa_type_audio_format[i].name)) == 0)
|
||||
return spa_type_audio_format[i].type;
|
||||
}
|
||||
return SPA_AUDIO_CHANNEL_UNKNOWN;
|
||||
}
|
||||
|
||||
static inline uint32_t format_paname2id(const char *name, size_t size)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -92,8 +92,12 @@ struct stats {
|
|||
#define DEFAULT_DEFAULT_FRAG "96000/48000"
|
||||
#define DEFAULT_DEFAULT_TLENGTH "96000/48000"
|
||||
#define DEFAULT_MIN_QUANTUM "256/48000"
|
||||
#define DEFAULT_FORMAT "float32le"
|
||||
#define DEFAULT_CHANNEL_MAP "front-left,front-right"
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
#define DEFAULT_FORMAT "F32BE"
|
||||
#else
|
||||
#define DEFAULT_FORMAT "F32LE"
|
||||
#endif
|
||||
#define DEFAULT_CHANNEL_MAP "[ FL FR ]"
|
||||
|
||||
#define MAX_FORMATS 32
|
||||
|
||||
|
|
@ -6357,14 +6361,27 @@ static int parse_frac(struct pw_properties *props, const char *key, const char *
|
|||
pw_log_info(NAME": defaults: %s = %u/%u", key, res->num, res->denom);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parse_channel_map(struct pw_properties *props, const char *key, const char *def,
|
||||
struct channel_map *res)
|
||||
{
|
||||
const char *str;
|
||||
struct spa_json it[2];
|
||||
char v[256];
|
||||
|
||||
if (props == NULL ||
|
||||
(str = pw_properties_get(props, key)) == NULL)
|
||||
str = def;
|
||||
channel_map_parse(str, res);
|
||||
|
||||
spa_json_init(&it[0], str, strlen(str));
|
||||
if (spa_json_enter_array(&it[0], &it[1]) <= 0)
|
||||
spa_json_init(&it[1], str, strlen(str));
|
||||
|
||||
res->channels = 0;
|
||||
while (spa_json_get_string(&it[1], v, sizeof(v)) > 0 &&
|
||||
res->channels < SPA_AUDIO_MAX_CHANNELS) {
|
||||
res->map[res->channels++] = channel_name2id(v);
|
||||
}
|
||||
pw_log_info(NAME": defaults: %s = %s", key, str);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -6375,7 +6392,7 @@ static int parse_format(struct pw_properties *props, const char *key, const char
|
|||
if (props == NULL ||
|
||||
(str = pw_properties_get(props, key)) == NULL)
|
||||
str = def;
|
||||
res->format = format_paname2id(str, strlen(str));
|
||||
res->format = format_name2id(str);
|
||||
if (res->format == SPA_AUDIO_FORMAT_UNKNOWN)
|
||||
res->format = SPA_AUDIO_FORMAT_F32;
|
||||
pw_log_info(NAME": defaults: %s = %s", key, str);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue