summaryrefslogtreecommitdiffstats
path: root/src/SinkWindow.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/SinkWindow.cc')
-rw-r--r--src/SinkWindow.cc35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/SinkWindow.cc b/src/SinkWindow.cc
index 1999693..d6971dd 100644
--- a/src/SinkWindow.cc
+++ b/src/SinkWindow.cc
@@ -32,6 +32,7 @@ SinkWindow::SinkWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade:
descriptionLabel(NULL),
indexLabel(NULL),
sampleTypeLabel(NULL),
+ channelMapLabel(NULL),
latencyLabel(NULL),
ownerModuleLabel(NULL),
monitorSourceLabel(NULL),
@@ -49,6 +50,7 @@ SinkWindow::SinkWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade:
refGlade->get_widget("descriptionLabel", descriptionLabel);
refGlade->get_widget("indexLabel", indexLabel);
refGlade->get_widget("sampleTypeLabel", sampleTypeLabel);
+ refGlade->get_widget("channelMapLabel", channelMapLabel);
refGlade->get_widget("latencyLabel", latencyLabel);
refGlade->get_widget("ownerModuleLabel", ownerModuleLabel);
refGlade->get_widget("monitorSourceLabel", monitorSourceLabel);
@@ -78,15 +80,15 @@ SinkWindow* SinkWindow::create() {
}
void SinkWindow::updateInfo(const SinkInfo &i) {
- char t[64], ss[PA_SAMPLE_SPEC_SNPRINT_MAX];
- double percent, db;
+ char t[64], ss[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
+ double percent;
nameLabel->set_text(i.name);
descriptionLabel->set_text(i.description);
snprintf(t, sizeof(t), "#%u", i.index);
indexLabel->set_text(t);
- pa_sample_spec_snprint(ss, sizeof(ss), &i.sample_spec);
- sampleTypeLabel->set_text(ss);
+ sampleTypeLabel->set_text(pa_sample_spec_snprint(ss, sizeof(ss), &i.sample_spec));
+ channelMapLabel->set_text(pa_channel_map_snprint(cm, sizeof(cm), &i.channel_map));
snprintf(t, sizeof(t), "#%u", i.owner_module);
ownerModuleLabel->set_text(t);
@@ -96,16 +98,23 @@ void SinkWindow::updateInfo(const SinkInfo &i) {
SourceInfo *source = serverInfoManager->getSourceInfo(i.monitor_source);
monitorSourceLabel->set_text(source->name);
- percent = pa_sw_volume_to_linear(pa_cvolume_avg(&i.volume)) * 100;
- /* FIXME: Hardware volume doesn't translate well to dB. */
- db = pa_sw_volume_to_dB(pa_cvolume_avg(&i.volume));
+ percent = ((double) pa_cvolume_avg(&i.volume) * 100) / PA_VOLUME_NORM;
scaleEnabled = false;
volumeScale->set_value(percent);
scaleEnabled = true;
- if (db != PA_DECIBEL_MININFTY)
- snprintf(t, sizeof(t), "%0.0f%% (%0.2fdB)", percent, db);
- else
- snprintf(t, sizeof(t), "%0.0f%% (-&#8734;dB)", percent);
+
+ if (i.hw_volume_supported)
+ snprintf(t, sizeof(t), "%0.0f%%", percent);
+ else {
+ double db;
+
+ db = pa_sw_volume_to_dB(pa_cvolume_avg(&i.volume));
+
+ if (db != PA_DECIBEL_MININFTY)
+ snprintf(t, sizeof(t), "%0.0f%% (%0.2fdB)", percent, db);
+ else
+ snprintf(t, sizeof(t), "%0.0f%% (-&#8734;dB)", percent);
+ }
volumeLabel->set_markup(t);
set_title("Sink: "+i.name);
@@ -115,7 +124,7 @@ void SinkWindow::updateInfo(const SinkInfo &i) {
index = i.index;
monitor_source_name = i.monitor_source_name;
- toOwnerModuleButton->set_sensitive(owner_module != (uint32_t) -1);
+ toOwnerModuleButton->set_sensitive(owner_module != PA_INVALID_INDEX);
}
void SinkWindow::onCloseButton() {
@@ -133,7 +142,7 @@ void SinkWindow::onToOwnerModuleButton() {
void SinkWindow::onVolumeScaleValueChanged() {
if (scaleEnabled)
- serverInfoManager->setSinkVolume(index, pa_sw_volume_from_linear(volumeScale->get_value()/100));
+ serverInfoManager->setSinkVolume(index, (pa_volume_t) (((double) volumeScale->get_value()/100) * PA_VOLUME_NORM));
}
void SinkWindow::onVolumeResetButton() {