mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-02-08 10:06:23 -05:00
spa: make a function to make a channel short name
Make a function that can generate and parse a short name for the positions that are not in the type list, like the AUX channels.
This commit is contained in:
parent
7177f8269d
commit
11f1298f53
16 changed files with 74 additions and 38 deletions
|
|
@ -298,9 +298,9 @@ uint32_t channel_pa2id(enum channel_position channel)
|
|||
return audio_channels[channel].channel;
|
||||
}
|
||||
|
||||
const char *channel_id2name(uint32_t channel)
|
||||
const char *channel_id2name(uint32_t channel, char *buf, size_t size)
|
||||
{
|
||||
return spa_type_audio_channel_to_short_name(channel);
|
||||
return spa_type_audio_channel_make_short_name(channel, buf, size, "UNK");
|
||||
}
|
||||
|
||||
uint32_t channel_name2id(const char *name)
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ void sample_spec_fix(struct sample_spec *ss, struct channel_map *map,
|
|||
struct spa_dict *props);
|
||||
|
||||
uint32_t channel_pa2id(enum channel_position channel);
|
||||
const char *channel_id2name(uint32_t channel);
|
||||
const char *channel_id2name(uint32_t channel, char *buf, size_t size);
|
||||
uint32_t channel_name2id(const char *name);
|
||||
enum channel_position channel_id2pa(uint32_t id, uint32_t *aux);
|
||||
const char *channel_id2paname(uint32_t id, uint32_t *aux);
|
||||
|
|
|
|||
|
|
@ -761,11 +761,13 @@ int message_dump(enum spa_log_level level, const char *prefix, struct message *m
|
|||
case TAG_CHANNEL_MAP:
|
||||
{
|
||||
struct channel_map map;
|
||||
char pos[8];
|
||||
if ((res = read_channel_map(m, &map)) < 0)
|
||||
return res;
|
||||
pw_log(level, "%s %u: channelmap: channels:%u", prefix, o, map.channels);
|
||||
for (i = 0; i < map.channels; i++)
|
||||
pw_log(level, "%s %d: %s", prefix, i, channel_id2name(map.map[i]));
|
||||
pw_log(level, "%s %d: %s", prefix, i,
|
||||
channel_id2name(map.map[i], pos, sizeof(pos)));
|
||||
break;
|
||||
}
|
||||
case TAG_CVOLUME:
|
||||
|
|
|
|||
|
|
@ -283,14 +283,15 @@ void audioinfo_to_properties(struct spa_audio_info_raw *info, struct pw_properti
|
|||
if (info->rate)
|
||||
pw_properties_setf(props, SPA_KEY_AUDIO_RATE, "%u", info->rate);
|
||||
if (info->channels) {
|
||||
char *s, *p;
|
||||
char *s, *p, pos[8];
|
||||
|
||||
pw_properties_setf(props, SPA_KEY_AUDIO_CHANNELS, "%u", info->channels);
|
||||
|
||||
p = s = alloca(info->channels * 8);
|
||||
for (i = 0; i < info->channels; i++)
|
||||
p += spa_scnprintf(p, 8, "%s%s", i == 0 ? "" : ", ",
|
||||
channel_id2name(spa_format_audio_raw_get_position(info, i)));
|
||||
channel_id2name(spa_format_audio_raw_get_position(info, i),
|
||||
pos, sizeof(pos)));
|
||||
pw_properties_setf(props, SPA_KEY_AUDIO_POSITION, "[ %s ]", s);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -295,9 +295,11 @@ static int do_extension_stream_restore_write(struct module *module, struct clien
|
|||
fprintf(f, " ]");
|
||||
}
|
||||
if (map.channels > 0) {
|
||||
char pos[8];
|
||||
fprintf(f, ", \"channels\": [");
|
||||
for (i = 0; i < map.channels; i++)
|
||||
fprintf(f, "%s\"%s\"", (i == 0 ? " ":", "), channel_id2name(map.map[i]));
|
||||
fprintf(f, "%s\"%s\"", (i == 0 ? " ":", "),
|
||||
channel_id2name(map.map[i], pos, sizeof(pos)));
|
||||
fprintf(f, " ]");
|
||||
}
|
||||
if (device_name != NULL && device_name[0] &&
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue