mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
alsa: use pa_strbuf
This commit is contained in:
parent
c7ca024607
commit
1d3c4501ef
2 changed files with 26 additions and 27 deletions
|
|
@ -4734,35 +4734,29 @@ static int profile_verify(pa_alsa_profile *p) {
|
|||
PA_ELEMENTSOF(well_known_descriptions)));
|
||||
|
||||
if (!p->description) {
|
||||
pa_strbuf *sb;
|
||||
uint32_t idx;
|
||||
pa_alsa_mapping *m;
|
||||
char *ptr;
|
||||
size_t size;
|
||||
FILE *f;
|
||||
int count = 0;
|
||||
|
||||
f = open_memstream(&ptr, &size);
|
||||
if (f == NULL) {
|
||||
pa_log("failed to open memstream: %m");
|
||||
return -1;
|
||||
}
|
||||
sb = pa_strbuf_new();
|
||||
|
||||
if (p->output_mappings)
|
||||
PA_IDXSET_FOREACH(m, p->output_mappings, idx) {
|
||||
if (count++ > 0)
|
||||
fprintf(f, " + ");
|
||||
fprintf(f, _("%s Output"), m->description);
|
||||
if (!pa_strbuf_isempty(sb))
|
||||
pa_strbuf_puts(sb, " + ");
|
||||
|
||||
pa_strbuf_printf(sb, _("%s Output"), m->description);
|
||||
}
|
||||
|
||||
if (p->input_mappings)
|
||||
PA_IDXSET_FOREACH(m, p->input_mappings, idx) {
|
||||
if (count++ > 0)
|
||||
fprintf(f, " + ");
|
||||
fprintf(f, _("%s Input"), m->description);
|
||||
if (!pa_strbuf_isempty(sb))
|
||||
pa_strbuf_puts(sb, " + ");
|
||||
|
||||
pa_strbuf_printf(sb, _("%s Input"), m->description);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
p->description = ptr;
|
||||
p->description = pa_strbuf_to_string_free(sb);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -4814,23 +4808,17 @@ void pa_alsa_decibel_fix_dump(pa_alsa_decibel_fix *db_fix) {
|
|||
pa_assert(db_fix);
|
||||
|
||||
if (db_fix->db_values) {
|
||||
pa_strbuf *buf;
|
||||
unsigned long i, nsteps;
|
||||
FILE *f;
|
||||
char *ptr;
|
||||
size_t size;
|
||||
|
||||
f = open_memstream(&ptr, &size);
|
||||
if (f == NULL)
|
||||
return;
|
||||
|
||||
pa_assert(db_fix->min_step <= db_fix->max_step);
|
||||
nsteps = db_fix->max_step - db_fix->min_step + 1;
|
||||
|
||||
buf = pa_strbuf_new();
|
||||
for (i = 0; i < nsteps; ++i)
|
||||
fprintf(f, "[%li]:%0.2f ", i + db_fix->min_step, db_fix->db_values[i] / 100.0);
|
||||
pa_strbuf_printf(buf, "[%li]:%0.2f ", i + db_fix->min_step, db_fix->db_values[i] / 100.0);
|
||||
|
||||
fclose(f);
|
||||
db_values = ptr;
|
||||
db_values = pa_strbuf_to_string_free(buf);
|
||||
}
|
||||
|
||||
pa_log_debug("Decibel fix %s, min_step=%li, max_step=%li, db_values=%s",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue