Use pa_(c)volume_snprint_verbose() everywhere

All pa_cvolume_snprint(), pa_volume_snprint(),
pa_sw_cvolume_snprint_dB() and pa_sw_volume_snprint_dB() calls have
been replaced with pa_cvolume_snprint_verbose() and
pa_volume_snprint_verbose() calls, making the log output more
informative and the code sometimes simpler.
This commit is contained in:
Tanu Kaskinen 2013-04-03 16:36:43 +03:00
parent 596b2988a5
commit ee5e245afa
11 changed files with 212 additions and 177 deletions

View file

@ -1873,7 +1873,8 @@ static int pa_cli_command_dump_volumes(pa_core *c, pa_tokenizer *t, pa_strbuf *b
pa_sink_input *i;
pa_source_output *o;
uint32_t s_idx, i_idx;
char v_str[PA_CVOLUME_SNPRINT_MAX];
char v_str[PA_CVOLUME_SNPRINT_VERBOSE_MAX];
pa_channel_map *map;
pa_core_assert_ref(c);
pa_assert(t);
@ -1881,41 +1882,105 @@ static int pa_cli_command_dump_volumes(pa_core *c, pa_tokenizer *t, pa_strbuf *b
pa_assert(fail);
PA_IDXSET_FOREACH(s, c->sinks, s_idx) {
map = &s->channel_map;
pa_strbuf_printf(buf, "Sink %d: ", s_idx);
pa_strbuf_printf(buf, "reference = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &s->reference_volume));
pa_strbuf_printf(buf, "real = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &s->real_volume));
pa_strbuf_printf(buf, "soft = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &s->soft_volume));
pa_strbuf_printf(buf, "current_hw = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &s->thread_info.current_hw_volume));
pa_strbuf_printf(buf,
"reference = %s, ",
pa_cvolume_snprint_verbose(v_str,
sizeof(v_str),
&s->reference_volume,
map,
s->flags & PA_SINK_DECIBEL_VOLUME));
pa_strbuf_printf(buf,
"real = %s, ",
pa_cvolume_snprint_verbose(v_str,
sizeof(v_str),
&s->real_volume,
&s->channel_map,
s->flags & PA_SINK_DECIBEL_VOLUME));
pa_strbuf_printf(buf, "soft = %s, ", pa_cvolume_snprint_verbose(v_str, sizeof(v_str), &s->soft_volume, map, true));
pa_strbuf_printf(buf,
"current_hw = %s, ",
pa_cvolume_snprint_verbose(v_str,
sizeof(v_str),
&s->thread_info.current_hw_volume,
map,
s->flags & PA_SINK_DECIBEL_VOLUME));
pa_strbuf_printf(buf, "save = %s\n", pa_yes_no(s->save_volume));
PA_IDXSET_FOREACH(i, s->inputs, i_idx) {
map = &i->channel_map;
pa_strbuf_printf(buf, "\tInput %d: ", i_idx);
pa_strbuf_printf(buf, "volume = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &i->volume));
pa_strbuf_printf(buf, "reference_ratio = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &i->reference_ratio));
pa_strbuf_printf(buf, "real_ratio = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &i->real_ratio));
pa_strbuf_printf(buf, "soft = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &i->soft_volume));
pa_strbuf_printf(buf, "volume_factor = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &i->volume_factor));
pa_strbuf_printf(buf, "volume_factor_sink = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &i->volume_factor_sink));
pa_strbuf_printf(buf, "volume = %s, ", pa_cvolume_snprint_verbose(v_str, sizeof(v_str), &i->volume, map, true));
pa_strbuf_printf(buf,
"reference_ratio = %s, ",
pa_cvolume_snprint_verbose(v_str, sizeof(v_str), &i->reference_ratio, map, true));
pa_strbuf_printf(buf,
"real_ratio = %s, ",
pa_cvolume_snprint_verbose(v_str, sizeof(v_str), &i->real_ratio, map, true));
pa_strbuf_printf(buf, "soft = %s, ", pa_cvolume_snprint_verbose(v_str, sizeof(v_str), &i->soft_volume, map, true));
pa_strbuf_printf(buf,
"volume_factor = %s, ",
pa_cvolume_snprint_verbose(v_str, sizeof(v_str), &i->volume_factor, map, true));
pa_strbuf_printf(buf,
"volume_factor_sink = %s, ",
pa_cvolume_snprint_verbose(v_str,
sizeof(v_str),
&i->volume_factor_sink,
&i->sink->channel_map,
true));
pa_strbuf_printf(buf, "save = %s\n", pa_yes_no(i->save_volume));
}
}
PA_IDXSET_FOREACH(so, c->sources, s_idx) {
map = &so->channel_map;
pa_strbuf_printf(buf, "Source %d: ", s_idx);
pa_strbuf_printf(buf, "reference = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &so->reference_volume));
pa_strbuf_printf(buf, "real = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &so->real_volume));
pa_strbuf_printf(buf, "soft = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &so->soft_volume));
pa_strbuf_printf(buf, "current_hw = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &so->thread_info.current_hw_volume));
pa_strbuf_printf(buf,
"reference = %s, ",
pa_cvolume_snprint_verbose(v_str,
sizeof(v_str),
&so->reference_volume,
map,
so->flags & PA_SOURCE_DECIBEL_VOLUME));
pa_strbuf_printf(buf,
"real = %s, ",
pa_cvolume_snprint_verbose(v_str,
sizeof(v_str),
&so->real_volume,
map,
so->flags & PA_SOURCE_DECIBEL_VOLUME));
pa_strbuf_printf(buf, "soft = %s, ", pa_cvolume_snprint_verbose(v_str, sizeof(v_str), &so->soft_volume, map, true));
pa_strbuf_printf(buf,
"current_hw = %s, ",
pa_cvolume_snprint_verbose(v_str,
sizeof(v_str),
&so->thread_info.current_hw_volume,
map,
so->flags & PA_SOURCE_DECIBEL_VOLUME));
pa_strbuf_printf(buf, "save = %s\n", pa_yes_no(so->save_volume));
PA_IDXSET_FOREACH(o, so->outputs, i_idx) {
map = &o->channel_map;
pa_strbuf_printf(buf, "\tOutput %d: ", i_idx);
pa_strbuf_printf(buf, "volume = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &o->volume));
pa_strbuf_printf(buf, "reference_ratio = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &o->reference_ratio));
pa_strbuf_printf(buf, "real_ratio = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &o->real_ratio));
pa_strbuf_printf(buf, "soft = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &o->soft_volume));
pa_strbuf_printf(buf, "volume_factor = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &o->volume_factor));
pa_strbuf_printf(buf, "volume_factor_source = %s, ", pa_cvolume_snprint(v_str, sizeof(v_str), &o->volume_factor_source));
pa_strbuf_printf(buf, "volume = %s, ", pa_cvolume_snprint_verbose(v_str, sizeof(v_str), &o->volume, map, true));
pa_strbuf_printf(buf,
"reference_ratio = %s, ",
pa_cvolume_snprint_verbose(v_str, sizeof(v_str), &o->reference_ratio, map, true));
pa_strbuf_printf(buf,
"real_ratio = %s, ",
pa_cvolume_snprint_verbose(v_str, sizeof(v_str), &o->real_ratio, map, true));
pa_strbuf_printf(buf, "soft = %s, ", pa_cvolume_snprint_verbose(v_str, sizeof(v_str), &o->soft_volume, map, true));
pa_strbuf_printf(buf,
"volume_factor = %s, ",
pa_cvolume_snprint_verbose(v_str, sizeof(v_str), &o->volume_factor, map, true));
pa_strbuf_printf(buf,
"volume_factor_source = %s, ",
pa_cvolume_snprint_verbose(v_str,
sizeof(v_str),
&o->volume_factor_source,
&o->source->channel_map,
true));
pa_strbuf_printf(buf, "save = %s\n", pa_yes_no(o->save_volume));
}
}

View file

@ -246,10 +246,8 @@ char *pa_sink_list_to_string(pa_core *c) {
PA_IDXSET_FOREACH(sink, c->sinks, idx) {
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX],
cv[PA_CVOLUME_SNPRINT_MAX],
cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX],
v[PA_VOLUME_SNPRINT_MAX],
vdb[PA_SW_VOLUME_SNPRINT_DB_MAX],
cv[PA_CVOLUME_SNPRINT_VERBOSE_MAX],
v[PA_VOLUME_SNPRINT_VERBOSE_MAX],
cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t;
const char *cmn;
@ -264,9 +262,9 @@ char *pa_sink_list_to_string(pa_core *c) {
"\tstate: %s\n"
"\tsuspend cause: %s%s%s%s\n"
"\tpriority: %u\n"
"\tvolume: %s%s%s\n"
"\tvolume: %s\n"
"\t balance %0.2f\n"
"\tbase volume: %s%s%s\n"
"\tbase volume: %s\n"
"\tvolume steps: %u\n"
"\tmuted: %s\n"
"\tcurrent latency: %0.2f ms\n"
@ -295,13 +293,13 @@ char *pa_sink_list_to_string(pa_core *c) {
sink->suspend_cause & PA_SUSPEND_IDLE ? "IDLE " : "",
sink->suspend_cause & PA_SUSPEND_SESSION ? "SESSION" : "",
sink->priority,
pa_cvolume_snprint(cv, sizeof(cv), pa_sink_get_volume(sink, false)),
sink->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t " : "",
sink->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_sink_get_volume(sink, false)) : "",
pa_cvolume_snprint_verbose(cv,
sizeof(cv),
pa_sink_get_volume(sink, false),
&sink->channel_map,
sink->flags & PA_SINK_DECIBEL_VOLUME),
pa_cvolume_get_balance(pa_sink_get_volume(sink, false), &sink->channel_map),
pa_volume_snprint(v, sizeof(v), sink->base_volume),
sink->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t " : "",
sink->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), sink->base_volume) : "",
pa_volume_snprint_verbose(v, sizeof(v), sink->base_volume, sink->flags & PA_SINK_DECIBEL_VOLUME),
sink->n_volume_steps,
pa_yes_no(pa_sink_get_mute(sink, false)),
(double) pa_sink_get_latency(sink) / (double) PA_USEC_PER_MSEC,
@ -366,10 +364,8 @@ char *pa_source_list_to_string(pa_core *c) {
PA_IDXSET_FOREACH(source, c->sources, idx) {
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX],
cv[PA_CVOLUME_SNPRINT_MAX],
cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX],
v[PA_VOLUME_SNPRINT_MAX],
vdb[PA_SW_VOLUME_SNPRINT_DB_MAX],
cv[PA_CVOLUME_SNPRINT_VERBOSE_MAX],
v[PA_VOLUME_SNPRINT_VERBOSE_MAX],
cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t;
const char *cmn;
@ -384,9 +380,9 @@ char *pa_source_list_to_string(pa_core *c) {
"\tstate: %s\n"
"\tsuspend cause: %s%s%s%s\n"
"\tpriority: %u\n"
"\tvolume: %s%s%s\n"
"\tvolume: %s\n"
"\t balance %0.2f\n"
"\tbase volume: %s%s%s\n"
"\tbase volume: %s\n"
"\tvolume steps: %u\n"
"\tmuted: %s\n"
"\tcurrent latency: %0.2f ms\n"
@ -412,13 +408,13 @@ char *pa_source_list_to_string(pa_core *c) {
source->suspend_cause & PA_SUSPEND_IDLE ? "IDLE " : "",
source->suspend_cause & PA_SUSPEND_SESSION ? "SESSION" : "",
source->priority,
pa_cvolume_snprint(cv, sizeof(cv), pa_source_get_volume(source, false)),
source->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t " : "",
source->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), pa_source_get_volume(source, false)) : "",
pa_cvolume_snprint_verbose(cv,
sizeof(cv),
pa_source_get_volume(source, false),
&source->channel_map,
source->flags & PA_SOURCE_DECIBEL_VOLUME),
pa_cvolume_get_balance(pa_source_get_volume(source, false), &source->channel_map),
pa_volume_snprint(v, sizeof(v), source->base_volume),
source->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t " : "",
source->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), source->base_volume) : "",
pa_volume_snprint_verbose(v, sizeof(v), source->base_volume, source->flags & PA_SOURCE_DECIBEL_VOLUME),
source->n_volume_steps,
pa_yes_no(pa_source_get_mute(source, false)),
(double) pa_source_get_latency(source) / PA_USEC_PER_MSEC,
@ -486,7 +482,7 @@ char *pa_source_output_list_to_string(pa_core *c) {
pa_strbuf_printf(s, "%u source output(s) available.\n", pa_idxset_size(c->source_outputs));
PA_IDXSET_FOREACH(o, c->source_outputs, idx) {
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t, clt[28];
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_VERBOSE_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t, clt[28];
pa_usec_t cl;
const char *cmn;
pa_cvolume v;
@ -503,9 +499,8 @@ char *pa_source_output_list_to_string(pa_core *c) {
if (pa_source_output_is_volume_readable(o)) {
pa_source_output_get_volume(o, &v, true);
volume_str = pa_sprintf_malloc("%s\n\t %s\n\t balance %0.2f",
pa_cvolume_snprint(cv, sizeof(cv), &v),
pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &v),
volume_str = pa_sprintf_malloc("%s\n\t balance %0.2f",
pa_cvolume_snprint_verbose(cv, sizeof(cv), &v, &o->channel_map, true),
pa_cvolume_get_balance(&v, &o->channel_map));
} else
volume_str = pa_xstrdup("n/a");
@ -585,7 +580,7 @@ char *pa_sink_input_list_to_string(pa_core *c) {
pa_strbuf_printf(s, "%u sink input(s) available.\n", pa_idxset_size(c->sink_inputs));
PA_IDXSET_FOREACH(i, c->sink_inputs, idx) {
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t, clt[28];
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], *t, clt[28];
pa_usec_t cl;
const char *cmn;
pa_cvolume v;
@ -602,9 +597,8 @@ char *pa_sink_input_list_to_string(pa_core *c) {
if (pa_sink_input_is_volume_readable(i)) {
pa_sink_input_get_volume(i, &v, true);
volume_str = pa_sprintf_malloc("%s\n\t %s\n\t balance %0.2f",
pa_cvolume_snprint(cv, sizeof(cv), &v),
pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &v),
volume_str = pa_sprintf_malloc("%s\n\t balance %0.2f",
pa_cvolume_snprint_verbose(cv, sizeof(cv), &v, &i->channel_map, true),
pa_cvolume_get_balance(&v, &i->channel_map));
} else
volume_str = pa_xstrdup("n/a");
@ -678,7 +672,7 @@ char *pa_scache_list_to_string(pa_core *c) {
PA_IDXSET_FOREACH(e, c->scache, idx) {
double l = 0;
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX] = "n/a", cv[PA_CVOLUME_SNPRINT_MAX], cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX] = "n/a", *t;
char ss[PA_SAMPLE_SPEC_SNPRINT_MAX] = "n/a", cv[PA_CVOLUME_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX] = "n/a", *t;
const char *cmn;
cmn = pa_channel_map_to_pretty_name(&e->channel_map);
@ -698,7 +692,6 @@ char *pa_scache_list_to_string(pa_core *c) {
"\tlength: %lu\n"
"\tduration: %0.1f s\n"
"\tvolume: %s\n"
"\t %s\n"
"\t balance %0.2f\n"
"\tlazy: %s\n"
"\tfilename: <%s>\n",
@ -710,8 +703,7 @@ char *pa_scache_list_to_string(pa_core *c) {
cmn ? cmn : "",
(long unsigned)(e->memchunk.memblock ? e->memchunk.length : 0),
l,
e->volume_is_set ? pa_cvolume_snprint(cv, sizeof(cv), &e->volume) : "n/a",
e->volume_is_set ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &e->volume) : "n/a",
e->volume_is_set ? pa_cvolume_snprint_verbose(cv, sizeof(cv), &e->volume, &e->channel_map, true) : "n/a",
(e->memchunk.memblock && e->volume_is_set) ? pa_cvolume_get_balance(&e->volume, &e->channel_map) : 0.0f,
pa_yes_no(e->lazy),
e->filename ? e->filename : "n/a");