From f8b436993e3ea7059984538cd65d50bd50671fe6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 15 Aug 2004 11:26:05 +0000 Subject: Implement volume changing git-svn-id: file:///home/lennart/svn/public/paman/trunk@7 cdefa82f-4ce1-0310-97f5-ab6066f37c3c --- ServerInfo.cc | 4 ++++ ServerInfo.hh | 2 ++ SinkWindow.cc | 22 ++++++++++++++++++++++ SinkWindow.hh | 9 +++++++-- paman.glade | 38 ++++++++++++++++++++++++++++++++++++-- 5 files changed, 71 insertions(+), 4 deletions(-) diff --git a/ServerInfo.cc b/ServerInfo.cc index 7866683..fc7fe4e 100644 --- a/ServerInfo.cc +++ b/ServerInfo.cc @@ -392,3 +392,7 @@ void ServerInfoManager::removeModuleInfo(uint32_t index) { delete i; } } + +void ServerInfoManager::setSinkVolume(uint32_t index, uint32_t volume) { + pa_operation_unref(pa_context_set_sink_volume_by_index(&context, index, volume, NULL, NULL)); +} diff --git a/ServerInfo.hh b/ServerInfo.hh index bba87b3..5c22f64 100644 --- a/ServerInfo.hh +++ b/ServerInfo.hh @@ -115,6 +115,8 @@ public: void removeSourceInfo(uint32_t index); void removeClientInfo(uint32_t index); void removeModuleInfo(uint32_t index); + + void setSinkVolume(uint32_t index, uint32_t volume); protected: std::map sinks; diff --git a/SinkWindow.cc b/SinkWindow.cc index 5ecd27d..68d3ec4 100644 --- a/SinkWindow.cc +++ b/SinkWindow.cc @@ -18,6 +18,8 @@ SinkWindow::SinkWindow(BaseObjectType* cobject, const Glib::RefPtrget_widget("nameLabel", nameLabel); @@ -32,10 +34,15 @@ SinkWindow::SinkWindow(BaseObjectType* cobject, const Glib::RefPtrget_widget("toOwnerModuleButton", toOwnerModuleButton); refGlade->get_widget("volumeLabel", volumeLabel); refGlade->get_widget("volumeScale", volumeScale); + refGlade->get_widget("volumeResetButton", volumeResetButton); + refGlade->get_widget("volumeMuteButton", volumeMuteButton); closeButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkWindow::onCloseButton)); toMonitorSourceButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkWindow::onToMonitorSourceButton)); toOwnerModuleButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkWindow::onToOwnerModuleButton)); + volumeScale->signal_value_changed().connect(sigc::mem_fun(*this, &SinkWindow::onVolumeScaleValueChanged)); + volumeResetButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkWindow::onVolumeResetButton)); + volumeMuteButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkWindow::onVolumeMuteButton)); } SinkWindow* SinkWindow::create() { @@ -71,6 +78,7 @@ void SinkWindow::updateInfo(const SinkInfo &i) { monitor_source = i.monitor_source; owner_module = i.owner_module; + index = i.index; toOwnerModuleButton->set_sensitive(owner_module != (uint32_t) -1); } @@ -87,3 +95,17 @@ void SinkWindow::onToOwnerModuleButton() { if (owner_module != (uint32_t) -1) serverInfoManager->showModuleWindow(owner_module); } + +void SinkWindow::onVolumeScaleValueChanged() { + serverInfoManager->setSinkVolume(index, (uint32_t) ((volumeScale->get_value()*0x100)/100)); +} + +void SinkWindow::onVolumeResetButton() { + serverInfoManager->setSinkVolume(index, PA_VOLUME_NORM); +} + +void SinkWindow::onVolumeMuteButton() { + serverInfoManager->setSinkVolume(index, PA_VOLUME_MUTE); +} + + diff --git a/SinkWindow.hh b/SinkWindow.hh index 39901b6..32557c4 100644 --- a/SinkWindow.hh +++ b/SinkWindow.hh @@ -24,17 +24,22 @@ public: Gtk::Button *closeButton, *toMonitorSourceButton, - *toOwnerModuleButton; + *toOwnerModuleButton, + *volumeResetButton, + *volumeMuteButton; Gtk::HScale *volumeScale; - uint32_t owner_module, monitor_source; + uint32_t index, owner_module, monitor_source; void updateInfo(const SinkInfo &i); virtual void onCloseButton(); virtual void onToMonitorSourceButton(); virtual void onToOwnerModuleButton(); + virtual void onVolumeScaleValueChanged(); + virtual void onVolumeResetButton(); + virtual void onVolumeMuteButton(); }; #endif diff --git a/paman.glade b/paman.glade index a4e8179..e8915e9 100644 --- a/paman.glade +++ b/paman.glade @@ -1281,9 +1281,9 @@ False GTK_POS_LEFT 0 - GTK_UPDATE_DELAYED + GTK_UPDATE_DISCONTINUOUS False - 100 0 1000 10 100 0 + 147.692 0 500 10 100 20 0 @@ -1291,6 +1291,40 @@ True + + + + True + Reset to 100%, i.e. normal volume + True + Reset + True + GTK_RELIEF_NONE + True + + + 0 + False + False + + + + + + True + Mute to 0%, i.e. turn this sink off + True + Mute + True + GTK_RELIEF_NONE + True + + + 0 + False + False + + 1 -- cgit