From 9f205ae53d29127c54d416b5ca024fb625b1b950 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 10 Apr 2006 17:14:45 +0000 Subject: * add volume control for sources * add channel map information to sinks/source/sink inputs/source outputs git-svn-id: file:///home/lennart/svn/public/paman/trunk@54 cdefa82f-4ce1-0310-97f5-ab6066f37c3c --- src/SinkWindow.cc | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'src/SinkWindow.cc') 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::RefPtrget_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%% (-∞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%% (-∞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() { -- cgit