mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-08 12:06:40 -04:00
modules: convert snprintf to strbuf
Use spa_strbuf instead of snprintf to handle errors better.
This commit is contained in:
parent
2c4dc2d22f
commit
51b635cc98
4 changed files with 25 additions and 16 deletions
|
|
@ -288,13 +288,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, pos[8];
|
||||
char *s, pos[8];
|
||||
struct spa_strbuf b;
|
||||
|
||||
pw_properties_setf(props, SPA_KEY_AUDIO_CHANNELS, "%u", info->channels);
|
||||
|
||||
p = s = alloca(info->channels * 8);
|
||||
s = alloca(info->channels * 8);
|
||||
spa_strbuf_init(&b, s, info->channels * 8);
|
||||
for (i = 0; i < info->channels; i++)
|
||||
p += spa_scnprintf(p, 8, "%s%s", i == 0 ? "" : ", ",
|
||||
spa_strbuf_append(&b, "%s%s", i == 0 ? "" : ", ",
|
||||
channel_id2name(info->position[i], pos, sizeof(pos)));
|
||||
pw_properties_setf(props, SPA_KEY_AUDIO_POSITION, "[ %s ]", s);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue