From 2b3c1967c118346c1d73491877cc346e142191e3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 1 Sep 2004 14:46:18 +0000 Subject: show volumes in dB as well git-svn-id: file:///home/lennart/svn/public/paman/trunk@27 cdefa82f-4ce1-0310-97f5-ab6066f37c3c --- src/SinkWindow.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/SinkWindow.cc') diff --git a/src/SinkWindow.cc b/src/SinkWindow.cc index f632078..37a84b4 100644 --- a/src/SinkWindow.cc +++ b/src/SinkWindow.cc @@ -53,7 +53,8 @@ SinkWindow* SinkWindow::create() { } void SinkWindow::updateInfo(const SinkInfo &i) { - char t[20], ss[PA_SAMPLE_SNPRINT_MAX_LENGTH]; + char t[64], ss[PA_SAMPLE_SNPRINT_MAX_LENGTH]; + double percent, db; nameLabel->set_text(i.name); descriptionLabel->set_text(i.description); @@ -70,9 +71,14 @@ void SinkWindow::updateInfo(const SinkInfo &i) { SourceInfo *source = serverInfoManager->getSourceInfo(i.monitor_source); monitorSourceLabel->set_text(source->name); - volumeScale->set_value(((double) i.volume / 0x100) * 100); - snprintf(t, sizeof(t), "%u%%", (i.volume*100)/0x100); - volumeLabel->set_text(t); + percent = ((double) i.volume / 0x100) * 100; + db = pa_volume_to_dB(i.volume); + volumeScale->set_value(percent); + if (db != PA_DECIBEL_MININFTY) + snprintf(t, sizeof(t), "%0.0f%% (%0.2fdB)", percent, db); + else + snprintf(t, sizeof(t), "%0.0f%% (-∞dB)", percent); + volumeLabel->set_markup(t); set_title("Sink: "+i.name); -- cgit