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. --- src/modules/alsa/alsa-sink.c | 44 +++++------- src/modules/alsa/alsa-source.c | 44 +++++------- src/modules/module-device-restore.c | 16 ++--- src/modules/module-position-event-sounds.c | 9 ++- src/modules/module-stream-restore.c | 4 +- src/modules/oss/oss-util.c | 4 +- src/modules/raop/module-raop-sink.c | 9 +-- src/pulsecore/cli-command.c | 107 ++++++++++++++++++++++------ src/pulsecore/cli-text.c | 64 ++++++++--------- src/tests/volume-test.c | 30 +++++--- src/utils/pactl.c | 54 +++++--------- 11 files changed, 210 insertions(+), 175 deletions(-) diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index 97fddbf..ef85497 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -1273,7 +1273,7 @@ static int io_mixer_callback(snd_mixer_elem_t *elem, unsigned int mask) { static void sink_get_volume_cb(pa_sink *s) { struct userdata *u = s->userdata; pa_cvolume r; - char vol_str_pcnt[PA_CVOLUME_SNPRINT_MAX]; + char volume_buf[PA_CVOLUME_SNPRINT_VERBOSE_MAX]; pa_assert(u); pa_assert(u->mixer_path); @@ -1285,13 +1285,8 @@ static void sink_get_volume_cb(pa_sink *s) { /* Shift down by the base volume, so that 0dB becomes maximum volume */ pa_sw_cvolume_multiply_scalar(&r, &r, s->base_volume); - pa_log_debug("Read hardware volume: %s", pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &r)); - - if (u->mixer_path->has_dB) { - char vol_str_db[PA_SW_CVOLUME_SNPRINT_DB_MAX]; - - pa_log_debug(" in dB: %s", pa_sw_cvolume_snprint_dB(vol_str_db, sizeof(vol_str_db), &r)); - } + pa_log_debug("Read hardware volume: %s", + pa_cvolume_snprint_verbose(volume_buf, sizeof(volume_buf), &r, &s->channel_map, u->mixer_path->has_dB)); if (pa_cvolume_equal(&u->hardware_volume, &r)) return; @@ -1306,7 +1301,7 @@ static void sink_get_volume_cb(pa_sink *s) { static void sink_set_volume_cb(pa_sink *s) { struct userdata *u = s->userdata; pa_cvolume r; - char vol_str_pcnt[PA_CVOLUME_SNPRINT_MAX]; + char volume_buf[PA_CVOLUME_SNPRINT_VERBOSE_MAX]; pa_bool_t deferred_volume = !!(s->flags & PA_SINK_DEFERRED_VOLUME); pa_assert(u); @@ -1327,7 +1322,6 @@ static void sink_set_volume_cb(pa_sink *s) { if (u->mixer_path->has_dB) { pa_cvolume new_soft_volume; pa_bool_t accurate_enough; - char vol_str_db[PA_SW_CVOLUME_SNPRINT_DB_MAX]; /* Match exactly what the user requested by software */ pa_sw_cvolume_divide(&new_soft_volume, &s->real_volume, &u->hardware_volume); @@ -1339,20 +1333,20 @@ static void sink_set_volume_cb(pa_sink *s) { (pa_cvolume_min(&new_soft_volume) >= (PA_VOLUME_NORM - VOLUME_ACCURACY)) && (pa_cvolume_max(&new_soft_volume) <= (PA_VOLUME_NORM + VOLUME_ACCURACY)); - pa_log_debug("Requested volume: %s", pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &s->real_volume)); - pa_log_debug(" in dB: %s", pa_sw_cvolume_snprint_dB(vol_str_db, sizeof(vol_str_db), &s->real_volume)); - pa_log_debug("Got hardware volume: %s", pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &u->hardware_volume)); - pa_log_debug(" in dB: %s", pa_sw_cvolume_snprint_dB(vol_str_db, sizeof(vol_str_db), &u->hardware_volume)); + pa_log_debug("Requested volume: %s", + pa_cvolume_snprint_verbose(volume_buf, sizeof(volume_buf), &s->real_volume, &s->channel_map, true)); + pa_log_debug("Got hardware volume: %s", + pa_cvolume_snprint_verbose(volume_buf, sizeof(volume_buf), &u->hardware_volume, &s->channel_map, true)); pa_log_debug("Calculated software volume: %s (accurate-enough=%s)", - pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &new_soft_volume), + pa_cvolume_snprint_verbose(volume_buf, sizeof(volume_buf), &new_soft_volume, &s->channel_map, true), pa_yes_no(accurate_enough)); - pa_log_debug(" in dB: %s", pa_sw_cvolume_snprint_dB(vol_str_db, sizeof(vol_str_db), &new_soft_volume)); if (!accurate_enough) s->soft_volume = new_soft_volume; } else { - pa_log_debug("Wrote hardware volume: %s", pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &r)); + pa_log_debug("Wrote hardware volume: %s", + pa_cvolume_snprint_verbose(volume_buf, sizeof(volume_buf), &r, &s->channel_map, false)); /* We can't match exactly what the user requested, hence let's * at least tell the user about it */ @@ -1388,17 +1382,15 @@ static void sink_write_volume_cb(pa_sink *s) { (pa_cvolume_max(&tmp_vol) <= (PA_VOLUME_NORM + VOLUME_ACCURACY)); if (!accurate_enough) { - union { - char db[2][PA_SW_CVOLUME_SNPRINT_DB_MAX]; - char pcnt[2][PA_CVOLUME_SNPRINT_MAX]; - } vol; + char volume_buf[2][PA_CVOLUME_SNPRINT_VERBOSE_MAX]; pa_log_debug("Written HW volume did not match with the request: %s (request) != %s", - pa_cvolume_snprint(vol.pcnt[0], sizeof(vol.pcnt[0]), &s->thread_info.current_hw_volume), - pa_cvolume_snprint(vol.pcnt[1], sizeof(vol.pcnt[1]), &hw_vol)); - pa_log_debug(" in dB: %s (request) != %s", - pa_sw_cvolume_snprint_dB(vol.db[0], sizeof(vol.db[0]), &s->thread_info.current_hw_volume), - pa_sw_cvolume_snprint_dB(vol.db[1], sizeof(vol.db[1]), &hw_vol)); + pa_cvolume_snprint_verbose(volume_buf[0], + sizeof(volume_buf[0]), + &s->thread_info.current_hw_volume, + &s->channel_map, + true), + pa_cvolume_snprint_verbose(volume_buf[1], sizeof(volume_buf[1]), &hw_vol, &s->channel_map, true)); } } } diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c index 1481c98..055727a 100644 --- a/src/modules/alsa/alsa-source.c +++ b/src/modules/alsa/alsa-source.c @@ -1154,7 +1154,7 @@ static int io_mixer_callback(snd_mixer_elem_t *elem, unsigned int mask) { static void source_get_volume_cb(pa_source *s) { struct userdata *u = s->userdata; pa_cvolume r; - char vol_str_pcnt[PA_CVOLUME_SNPRINT_MAX]; + char volume_buf[PA_CVOLUME_SNPRINT_VERBOSE_MAX]; pa_assert(u); pa_assert(u->mixer_path); @@ -1166,13 +1166,8 @@ static void source_get_volume_cb(pa_source *s) { /* Shift down by the base volume, so that 0dB becomes maximum volume */ pa_sw_cvolume_multiply_scalar(&r, &r, s->base_volume); - pa_log_debug("Read hardware volume: %s", pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &r)); - - if (u->mixer_path->has_dB) { - char vol_str_db[PA_SW_CVOLUME_SNPRINT_DB_MAX]; - - pa_log_debug(" in dB: %s", pa_sw_cvolume_snprint_dB(vol_str_db, sizeof(vol_str_db), &r)); - } + pa_log_debug("Read hardware volume: %s", + pa_cvolume_snprint_verbose(volume_buf, sizeof(volume_buf), &r, &s->channel_map, u->mixer_path->has_dB)); if (pa_cvolume_equal(&u->hardware_volume, &r)) return; @@ -1187,7 +1182,7 @@ static void source_get_volume_cb(pa_source *s) { static void source_set_volume_cb(pa_source *s) { struct userdata *u = s->userdata; pa_cvolume r; - char vol_str_pcnt[PA_CVOLUME_SNPRINT_MAX]; + char volume_buf[PA_CVOLUME_SNPRINT_VERBOSE_MAX]; pa_bool_t deferred_volume = !!(s->flags & PA_SOURCE_DEFERRED_VOLUME); pa_assert(u); @@ -1208,7 +1203,6 @@ static void source_set_volume_cb(pa_source *s) { if (u->mixer_path->has_dB) { pa_cvolume new_soft_volume; pa_bool_t accurate_enough; - char vol_str_db[PA_SW_CVOLUME_SNPRINT_DB_MAX]; /* Match exactly what the user requested by software */ pa_sw_cvolume_divide(&new_soft_volume, &s->real_volume, &u->hardware_volume); @@ -1220,20 +1214,20 @@ static void source_set_volume_cb(pa_source *s) { (pa_cvolume_min(&new_soft_volume) >= (PA_VOLUME_NORM - VOLUME_ACCURACY)) && (pa_cvolume_max(&new_soft_volume) <= (PA_VOLUME_NORM + VOLUME_ACCURACY)); - pa_log_debug("Requested volume: %s", pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &s->real_volume)); - pa_log_debug(" in dB: %s", pa_sw_cvolume_snprint_dB(vol_str_db, sizeof(vol_str_db), &s->real_volume)); - pa_log_debug("Got hardware volume: %s", pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &u->hardware_volume)); - pa_log_debug(" in dB: %s", pa_sw_cvolume_snprint_dB(vol_str_db, sizeof(vol_str_db), &u->hardware_volume)); + pa_log_debug("Requested volume: %s", + pa_cvolume_snprint_verbose(volume_buf, sizeof(volume_buf), &s->real_volume, &s->channel_map, true)); + pa_log_debug("Got hardware volume: %s", + pa_cvolume_snprint_verbose(volume_buf, sizeof(volume_buf), &u->hardware_volume, &s->channel_map, true)); pa_log_debug("Calculated software volume: %s (accurate-enough=%s)", - pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &new_soft_volume), + pa_cvolume_snprint_verbose(volume_buf, sizeof(volume_buf), &new_soft_volume, &s->channel_map, true), pa_yes_no(accurate_enough)); - pa_log_debug(" in dB: %s", pa_sw_cvolume_snprint_dB(vol_str_db, sizeof(vol_str_db), &new_soft_volume)); if (!accurate_enough) s->soft_volume = new_soft_volume; } else { - pa_log_debug("Wrote hardware volume: %s", pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &r)); + pa_log_debug("Wrote hardware volume: %s", + pa_cvolume_snprint_verbose(volume_buf, sizeof(volume_buf), &r, &s->channel_map, false)); /* We can't match exactly what the user requested, hence let's * at least tell the user about it */ @@ -1269,17 +1263,15 @@ static void source_write_volume_cb(pa_source *s) { (pa_cvolume_max(&tmp_vol) <= (PA_VOLUME_NORM + VOLUME_ACCURACY)); if (!accurate_enough) { - union { - char db[2][PA_SW_CVOLUME_SNPRINT_DB_MAX]; - char pcnt[2][PA_CVOLUME_SNPRINT_MAX]; - } vol; + char volume_buf[2][PA_CVOLUME_SNPRINT_VERBOSE_MAX]; pa_log_debug("Written HW volume did not match with the request: %s (request) != %s", - pa_cvolume_snprint(vol.pcnt[0], sizeof(vol.pcnt[0]), &s->thread_info.current_hw_volume), - pa_cvolume_snprint(vol.pcnt[1], sizeof(vol.pcnt[1]), &hw_vol)); - pa_log_debug(" in dB: %s (request) != %s", - pa_sw_cvolume_snprint_dB(vol.db[0], sizeof(vol.db[0]), &s->thread_info.current_hw_volume), - pa_sw_cvolume_snprint_dB(vol.db[1], sizeof(vol.db[1]), &hw_vol)); + pa_cvolume_snprint_verbose(volume_buf[0], + sizeof(volume_buf[0]), + &s->thread_info.current_hw_volume, + &s->channel_map, + true), + pa_cvolume_snprint_verbose(volume_buf[1], sizeof(volume_buf[1]), &hw_vol, &s->channel_map, true)); } } } diff --git a/src/modules/module-device-restore.c b/src/modules/module-device-restore.c index 8360a05..c37851d 100644 --- a/src/modules/module-device-restore.c +++ b/src/modules/module-device-restore.c @@ -779,13 +779,13 @@ static pa_hook_result_t sink_fixate_hook_callback(pa_core *c, pa_sink_new_data * if (!new_data->volume_is_set) { pa_cvolume v; - char buf[PA_CVOLUME_SNPRINT_MAX]; + char buf[PA_CVOLUME_SNPRINT_VERBOSE_MAX]; - pa_log_info("Restoring volume for sink %s.", new_data->name); v = e->volume; pa_cvolume_remap(&v, &e->channel_map, &new_data->channel_map); pa_sink_new_data_set_volume(new_data, &v); - pa_log_info("Restored volume: %s", pa_cvolume_snprint(buf, PA_CVOLUME_SNPRINT_MAX, &new_data->volume)); + pa_log_info("Restoring volume for sink %s: %s", new_data->name, + pa_cvolume_snprint_verbose(buf, sizeof(buf), &new_data->volume, &new_data->channel_map, false)); new_data->save_volume = TRUE; } else @@ -825,13 +825,11 @@ static pa_hook_result_t sink_port_hook_callback(pa_core *c, pa_sink *sink, struc if (u->restore_volume && e->volume_valid) { pa_cvolume v; - char buf[PA_CVOLUME_SNPRINT_MAX]; pa_log_info("Restoring volume for sink %s.", sink->name); v = e->volume; pa_cvolume_remap(&v, &e->channel_map, &sink->channel_map); pa_sink_set_volume(sink, &v, TRUE, FALSE); - pa_log_info("Restored volume: %s", pa_cvolume_snprint(buf, PA_CVOLUME_SNPRINT_MAX, &sink->reference_volume)); sink->save_volume = TRUE; } @@ -922,13 +920,13 @@ static pa_hook_result_t source_fixate_hook_callback(pa_core *c, pa_source_new_da if (!new_data->volume_is_set) { pa_cvolume v; - char buf[PA_CVOLUME_SNPRINT_MAX]; + char buf[PA_CVOLUME_SNPRINT_VERBOSE_MAX]; - pa_log_info("Restoring volume for source %s.", new_data->name); v = e->volume; pa_cvolume_remap(&v, &e->channel_map, &new_data->channel_map); pa_source_new_data_set_volume(new_data, &v); - pa_log_info("Restored volume: %s", pa_cvolume_snprint(buf, PA_CVOLUME_SNPRINT_MAX, &new_data->volume)); + pa_log_info("Restoring volume for source %s: %s", new_data->name, + pa_cvolume_snprint_verbose(buf, sizeof(buf), &new_data->volume, &new_data->channel_map, false)); new_data->save_volume = TRUE; } else @@ -968,13 +966,11 @@ static pa_hook_result_t source_port_hook_callback(pa_core *c, pa_source *source, if (u->restore_volume && e->volume_valid) { pa_cvolume v; - char buf[PA_CVOLUME_SNPRINT_MAX]; pa_log_info("Restoring volume for source %s.", source->name); v = e->volume; pa_cvolume_remap(&v, &e->channel_map, &source->channel_map); pa_source_set_volume(source, &v, TRUE, FALSE); - pa_log_info("Restored volume: %s", pa_cvolume_snprint(buf, PA_CVOLUME_SNPRINT_MAX, &source->reference_volume)); source->save_volume = TRUE; } diff --git a/src/modules/module-position-event-sounds.c b/src/modules/module-position-event-sounds.c index c298e74..2289f02 100644 --- a/src/modules/module-position-event-sounds.c +++ b/src/modules/module-position-event-sounds.c @@ -74,7 +74,7 @@ static int parse_pos(const char *pos, double *f) { static pa_hook_result_t sink_input_fixate_hook_callback(pa_core *core, pa_sink_input_new_data *data, struct userdata *u) { const char *hpos, *vpos, *role, *id; double f; - char t[PA_CVOLUME_SNPRINT_MAX]; + char t[PA_CVOLUME_SNPRINT_VERBOSE_MAX]; pa_cvolume v; pa_assert(data); @@ -132,7 +132,12 @@ static pa_hook_result_t sink_input_fixate_hook_callback(pa_core *core, pa_sink_i } } - pa_log_debug("Final volume factor %s.", pa_cvolume_snprint(t, sizeof(t), &v)); + pa_log_debug("Final volume factor %s.", + pa_cvolume_snprint_verbose(t, + sizeof(t), + &v, + &data->sink->channel_map, + data->sink->flags & PA_SINK_DECIBEL_VOLUME)); pa_sink_input_new_data_add_volume_factor_sink(data, u->name, &v); return PA_HOOK_OK; diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c index 23f4780..832ad42 100644 --- a/src/modules/module-stream-restore.c +++ b/src/modules/module-stream-restore.c @@ -1996,7 +1996,9 @@ PA_GCC_UNUSED static void stream_restore_dump_database(struct userdata *u) { pa_log("name=%s", name); pa_log("device=%s %s", e->device, pa_yes_no(e->device_valid)); pa_log("channel_map=%s", pa_channel_map_snprint(t, sizeof(t), &e->channel_map)); - pa_log("volume=%s %s", pa_cvolume_snprint(t, sizeof(t), &e->volume), pa_yes_no(e->volume_valid)); + pa_log("volume=%s %s", + pa_cvolume_snprint_verbose(t, sizeof(t), &e->volume, &e->channel_map, true), + pa_yes_no(e->volume_valid)); pa_log("mute=%s %s", pa_yes_no(e->muted), pa_yes_no(e->volume_valid)); entry_free(e); } diff --git a/src/modules/oss/oss-util.c b/src/modules/oss/oss-util.c index 3c7f0eb..cbc81e3 100644 --- a/src/modules/oss/oss-util.c +++ b/src/modules/oss/oss-util.c @@ -249,7 +249,7 @@ int pa_oss_set_fragments(int fd, int nfrags, int frag_size) { } int pa_oss_get_volume(int fd, unsigned long mixer, const pa_sample_spec *ss, pa_cvolume *volume) { - char cv[PA_CVOLUME_SNPRINT_MAX]; + char cv[PA_CVOLUME_SNPRINT_VERBOSE_MAX]; unsigned vol; pa_assert(fd >= 0); @@ -266,7 +266,7 @@ int pa_oss_get_volume(int fd, unsigned long mixer, const pa_sample_spec *ss, pa_ if (volume->channels >= 2) volume->values[1] = PA_CLAMP_VOLUME((((vol >> 8) & 0xFF) * PA_VOLUME_NORM) / 100); - pa_log_debug("Read mixer settings: %s", pa_cvolume_snprint(cv, sizeof(cv), volume)); + pa_log_debug("Read mixer settings: %s", pa_cvolume_snprint_verbose(cv, sizeof(cv), volume, NULL, false)); return 0; } diff --git a/src/modules/raop/module-raop-sink.c b/src/modules/raop/module-raop-sink.c index 1816fee..05ddc3f 100644 --- a/src/modules/raop/module-raop-sink.c +++ b/src/modules/raop/module-raop-sink.c @@ -266,7 +266,7 @@ static void sink_set_volume_cb(pa_sink *s) { struct userdata *u = s->userdata; pa_cvolume hw; pa_volume_t v; - char t[PA_CVOLUME_SNPRINT_MAX]; + char t[PA_CVOLUME_SNPRINT_VERBOSE_MAX]; pa_assert(u); @@ -285,9 +285,10 @@ static void sink_set_volume_cb(pa_sink *s) { /* Perform any software manipulation of the volume needed */ pa_sw_cvolume_divide(&s->soft_volume, &s->real_volume, &hw); - pa_log_debug("Requested volume: %s", pa_cvolume_snprint(t, sizeof(t), &s->real_volume)); - pa_log_debug("Got hardware volume: %s", pa_cvolume_snprint(t, sizeof(t), &hw)); - pa_log_debug("Calculated software volume: %s", pa_cvolume_snprint(t, sizeof(t), &s->soft_volume)); + pa_log_debug("Requested volume: %s", pa_cvolume_snprint_verbose(t, sizeof(t), &s->real_volume, &s->channel_map, false)); + pa_log_debug("Got hardware volume: %s", pa_cvolume_snprint_verbose(t, sizeof(t), &hw, &s->channel_map, false)); + pa_log_debug("Calculated software volume: %s", + pa_cvolume_snprint_verbose(t, sizeof(t), &s->soft_volume, &s->channel_map, true)); /* Any necessary software volume manipulation is done so set our hw volume (or v as a single value) on the device */ diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c index 1ec8054..c1a0a45 100644 --- a/src/pulsecore/cli-command.c +++ b/src/pulsecore/cli-command.c @@ -1877,7 +1877,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); @@ -1885,41 +1886,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)); } } diff --git a/src/pulsecore/cli-text.c b/src/pulsecore/cli-text.c index 963f130..16d5fcd 100644 --- a/src/pulsecore/cli-text.c +++ b/src/pulsecore/cli-text.c @@ -247,10 +247,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; @@ -266,9 +264,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" @@ -297,13 +295,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, @@ -368,10 +366,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; @@ -386,9 +382,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" @@ -414,13 +410,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, @@ -489,7 +485,7 @@ char *pa_source_output_list_to_string(pa_core *c) { pa_strbuf_printf(s, "%u source outputs(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; @@ -506,9 +502,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"); @@ -589,7 +584,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; @@ -606,9 +601,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"); @@ -682,7 +676,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); @@ -702,7 +696,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", @@ -714,8 +707,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"); diff --git a/src/tests/volume-test.c b/src/tests/volume-test.c index d8d2149..a2daf3e 100644 --- a/src/tests/volume-test.c +++ b/src/tests/volume-test.c @@ -54,39 +54,47 @@ START_TEST (volume_test) { v, (v*100)/PA_VOLUME_NORM, dB, f, pa_sw_volume_from_dB(dB), pa_sw_volume_from_linear(f)); } + map.channels = cv.channels = 2; + map.map[0] = PA_CHANNEL_POSITION_LEFT; + map.map[1] = PA_CHANNEL_POSITION_RIGHT; + for (v = PA_VOLUME_MUTED; v <= PA_VOLUME_NORM*2; v += 256) { - char s[PA_CVOLUME_SNPRINT_MAX], t[PA_SW_CVOLUME_SNPRINT_DB_MAX]; + char s[PA_CVOLUME_SNPRINT_VERBOSE_MAX]; pa_cvolume_set(&cv, 2, v); - pa_log_debug("Volume: %3i [%s] [%s]", v, pa_cvolume_snprint(s, sizeof(s), &cv), pa_sw_cvolume_snprint_dB(t, sizeof(t), &cv)); + pa_log_debug("Volume: %3i [%s]", v, pa_cvolume_snprint_verbose(s, sizeof(s), &cv, &map, true)); } - map.channels = cv.channels = 2; - map.map[0] = PA_CHANNEL_POSITION_LEFT; - map.map[1] = PA_CHANNEL_POSITION_RIGHT; - for (cv.values[0] = PA_VOLUME_MUTED; cv.values[0] <= PA_VOLUME_NORM*2; cv.values[0] += 4096) for (cv.values[1] = PA_VOLUME_MUTED; cv.values[1] <= PA_VOLUME_NORM*2; cv.values[1] += 4096) { - char s[PA_CVOLUME_SNPRINT_MAX]; + char s[PA_CVOLUME_SNPRINT_VERBOSE_MAX]; - pa_log_debug("Volume: [%s]; balance: %2.1f", pa_cvolume_snprint(s, sizeof(s), &cv), pa_cvolume_get_balance(&cv, &map)); + pa_log_debug("Volume: [%s]; balance: %2.1f", + pa_cvolume_snprint_verbose(s, sizeof(s), &cv, &map, true), + pa_cvolume_get_balance(&cv, &map)); } for (cv.values[0] = PA_VOLUME_MUTED+4096; cv.values[0] <= PA_VOLUME_NORM*2; cv.values[0] += 4096) for (cv.values[1] = PA_VOLUME_MUTED; cv.values[1] <= PA_VOLUME_NORM*2; cv.values[1] += 4096) for (b = -1.0f; b <= 1.0f; b += 0.2f) { - char s[PA_CVOLUME_SNPRINT_MAX]; + char s[PA_CVOLUME_SNPRINT_VERBOSE_MAX]; pa_cvolume r; float k; - pa_log_debug("Before: volume: [%s]; balance: %2.1f", pa_cvolume_snprint(s, sizeof(s), &cv), pa_cvolume_get_balance(&cv, &map)); + pa_log_debug("Before: volume: [%s]; balance: %2.1f", + pa_cvolume_snprint_verbose(s, sizeof(s), &cv, &map, true), + pa_cvolume_get_balance(&cv, &map)); r = cv; pa_cvolume_set_balance(&r, &map,b); k = pa_cvolume_get_balance(&r, &map); - pa_log_debug("After: volume: [%s]; balance: %2.1f (intended: %2.1f) %s", pa_cvolume_snprint(s, sizeof(s), &r), k, b, k < b-.05 || k > b+.5 ? "MISMATCH" : ""); + pa_log_debug("After: volume: [%s]; balance: %2.1f (intended: %2.1f) %s", + pa_cvolume_snprint_verbose(s, sizeof(s), &r, &map, true), + k, + b, + k < b - .05 || k > b + .5 ? "MISMATCH" : ""); } for (v = PA_VOLUME_MUTED; v <= PA_VOLUME_NORM*2; v += 51) { diff --git a/src/utils/pactl.c b/src/utils/pactl.c index 0fb62cb..d74f309 100644 --- a/src/utils/pactl.c +++ b/src/utils/pactl.c @@ -243,10 +243,8 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_ char s[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], f[PA_FORMAT_INFO_SNPRINT_MAX]; char *pl; @@ -287,9 +285,9 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_ "\tChannel Map: %s\n" "\tOwner Module: %u\n" "\tMute: %s\n" - "\tVolume: %s%s%s\n" + "\tVolume: %s\n" "\t balance %0.2f\n" - "\tBase Volume: %s%s%s\n" + "\tBase Volume: %s\n" "\tMonitor Source: %s\n" "\tLatency: %0.0f usec, configured %0.0f usec\n" "\tFlags: %s%s%s%s%s%s%s\n" @@ -303,13 +301,9 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_ pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map), i->owner_module, pa_yes_no(i->mute), - pa_cvolume_snprint(cv, sizeof(cv), &i->volume), - i->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t " : "", - i->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &i->volume) : "", + pa_cvolume_snprint_verbose(cv, sizeof(cv), &i->volume, &i->channel_map, i->flags & PA_SINK_DECIBEL_VOLUME), pa_cvolume_get_balance(&i->volume, &i->channel_map), - pa_volume_snprint(v, sizeof(v), i->base_volume), - i->flags & PA_SINK_DECIBEL_VOLUME ? "\n\t " : "", - i->flags & PA_SINK_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), i->base_volume) : "", + pa_volume_snprint_verbose(v, sizeof(v), i->base_volume, i->flags & PA_SINK_DECIBEL_VOLUME), pa_strnull(i->monitor_source_name), (double) i->latency, (double) i->configured_latency, i->flags & PA_SINK_HARDWARE ? "HARDWARE " : "", @@ -356,10 +350,8 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int char s[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], f[PA_FORMAT_INFO_SNPRINT_MAX]; char *pl; @@ -400,9 +392,9 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int "\tChannel Map: %s\n" "\tOwner Module: %u\n" "\tMute: %s\n" - "\tVolume: %s%s%s\n" + "\tVolume: %s\n" "\t balance %0.2f\n" - "\tBase Volume: %s%s%s\n" + "\tBase Volume: %s\n" "\tMonitor of Sink: %s\n" "\tLatency: %0.0f usec, configured %0.0f usec\n" "\tFlags: %s%s%s%s%s%s\n" @@ -416,13 +408,9 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map), i->owner_module, pa_yes_no(i->mute), - pa_cvolume_snprint(cv, sizeof(cv), &i->volume), - i->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t " : "", - i->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &i->volume) : "", + pa_cvolume_snprint_verbose(cv, sizeof(cv), &i->volume, &i->channel_map, i->flags & PA_SOURCE_DECIBEL_VOLUME), pa_cvolume_get_balance(&i->volume, &i->channel_map), - pa_volume_snprint(v, sizeof(v), i->base_volume), - i->flags & PA_SOURCE_DECIBEL_VOLUME ? "\n\t " : "", - i->flags & PA_SOURCE_DECIBEL_VOLUME ? pa_sw_volume_snprint_dB(vdb, sizeof(vdb), i->base_volume) : "", + pa_volume_snprint_verbose(v, sizeof(v), i->base_volume, i->flags & PA_SOURCE_DECIBEL_VOLUME), i->monitor_of_sink_name ? i->monitor_of_sink_name : _("n/a"), (double) i->latency, (double) i->configured_latency, i->flags & PA_SOURCE_HARDWARE ? "HARDWARE " : "", @@ -624,7 +612,7 @@ static void get_card_info_callback(pa_context *c, const pa_card_info *i, int is_ } static void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info *i, int is_last, void *userdata) { - char t[32], k[32], s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], f[PA_FORMAT_INFO_SNPRINT_MAX]; + char t[32], k[32], s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_VERBOSE_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], f[PA_FORMAT_INFO_SNPRINT_MAX]; char *pl; if (is_last < 0) { @@ -668,7 +656,6 @@ static void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info "\tCorked: %s\n" "\tMute: %s\n" "\tVolume: %s\n" - "\t %s\n" "\t balance %0.2f\n" "\tBuffer Latency: %0.0f usec\n" "\tSink Latency: %0.0f usec\n" @@ -684,8 +671,7 @@ static void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info pa_format_info_snprint(f, sizeof(f), i->format), pa_yes_no(i->corked), pa_yes_no(i->mute), - pa_cvolume_snprint(cv, sizeof(cv), &i->volume), - pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &i->volume), + pa_cvolume_snprint_verbose(cv, sizeof(cv), &i->volume, &i->channel_map, true), pa_cvolume_get_balance(&i->volume, &i->channel_map), (double) i->buffer_usec, (double) i->sink_usec, @@ -696,7 +682,7 @@ static void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info } static void get_source_output_info_callback(pa_context *c, const pa_source_output_info *i, int is_last, void *userdata) { - char t[32], k[32], s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], f[PA_FORMAT_INFO_SNPRINT_MAX]; + char t[32], k[32], s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_VERBOSE_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX], f[PA_FORMAT_INFO_SNPRINT_MAX]; char *pl; if (is_last < 0) { @@ -741,7 +727,6 @@ static void get_source_output_info_callback(pa_context *c, const pa_source_outpu "\tCorked: %s\n" "\tMute: %s\n" "\tVolume: %s\n" - "\t %s\n" "\t balance %0.2f\n" "\tBuffer Latency: %0.0f usec\n" "\tSource Latency: %0.0f usec\n" @@ -757,8 +742,7 @@ static void get_source_output_info_callback(pa_context *c, const pa_source_outpu pa_format_info_snprint(f, sizeof(f), i->format), pa_yes_no(i->corked), pa_yes_no(i->mute), - pa_cvolume_snprint(cv, sizeof(cv), &i->volume), - pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &i->volume), + pa_cvolume_snprint_verbose(cv, sizeof(cv), &i->volume, &i->channel_map, true), pa_cvolume_get_balance(&i->volume, &i->channel_map), (double) i->buffer_usec, (double) i->source_usec, @@ -769,7 +753,7 @@ static void get_source_output_info_callback(pa_context *c, const pa_source_outpu } static void get_sample_info_callback(pa_context *c, const pa_sample_info *i, int is_last, void *userdata) { - char t[PA_BYTES_SNPRINT_MAX], s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_MAX], cvdb[PA_SW_CVOLUME_SNPRINT_DB_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX]; + char t[PA_BYTES_SNPRINT_MAX], s[PA_SAMPLE_SPEC_SNPRINT_MAX], cv[PA_CVOLUME_SNPRINT_VERBOSE_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX]; char *pl; if (is_last < 0) { @@ -805,7 +789,6 @@ static void get_sample_info_callback(pa_context *c, const pa_sample_info *i, int "\tSample Specification: %s\n" "\tChannel Map: %s\n" "\tVolume: %s\n" - "\t %s\n" "\t balance %0.2f\n" "\tDuration: %0.1fs\n" "\tSize: %s\n" @@ -816,8 +799,7 @@ static void get_sample_info_callback(pa_context *c, const pa_sample_info *i, int i->name, pa_sample_spec_valid(&i->sample_spec) ? pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec) : _("n/a"), pa_sample_spec_valid(&i->sample_spec) ? pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map) : _("n/a"), - pa_cvolume_snprint(cv, sizeof(cv), &i->volume), - pa_sw_cvolume_snprint_dB(cvdb, sizeof(cvdb), &i->volume), + pa_cvolume_snprint_verbose(cv, sizeof(cv), &i->volume, &i->channel_map, true), pa_cvolume_get_balance(&i->volume, &i->channel_map), (double) i->duration/1000000.0, t, -- 1.7.10.4