From 7b738b897f6e523024faadef9c1efb6a9aa32f59 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 16 Aug 2004 19:55:43 +0000 Subject: add sink input/source output support (currently broken) git-svn-id: file:///home/lennart/svn/public/paman/trunk@12 cdefa82f-4ce1-0310-97f5-ab6066f37c3c --- src/MainWindow.cc | 59 +++ src/MainWindow.hh | 6 +- src/Makefile.am | 4 +- src/ServerInfoManager.cc | 172 +++++++- src/ServerInfoManager.hh | 57 +++ src/SinkInputWindow.cc | 102 +++-- src/SinkInputWindow.hh | 26 +- src/SourceOutputWindow.cc | 108 ++--- src/SourceOutputWindow.hh | 37 +- src/paman.glade | 1076 ++++++++++++++++++++++++++++++++++++++++++++- 10 files changed, 1505 insertions(+), 142 deletions(-) diff --git a/src/MainWindow.cc b/src/MainWindow.cc index fdb817a..26a3b90 100644 --- a/src/MainWindow.cc +++ b/src/MainWindow.cc @@ -12,6 +12,8 @@ enum { ROW_TYPE_SOURCE_CATEGORY, ROW_TYPE_SINK, ROW_TYPE_SOURCE, + ROW_TYPE_SINK_INPUT, + ROW_TYPE_SOURCE_OUTPUT, }; MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade) : @@ -136,6 +138,44 @@ void MainWindow::updateInfo(ModuleInfo &i) { moduleOpenButton->set_sensitive(true); } +void MainWindow::updateInfo(SinkInputInfo &i) { + if (!i.treeRef) { + SinkInfo *si = serverInfoManager->getSinkInfo(i.sink); + if (!si) + return; + + Gtk::TreeIter iter = deviceTreeStore->get_iter(si->treeRef.get_path()); + i.treeRef = Gtk::TreeRowReference(deviceTreeStore, Gtk::TreePath(deviceTreeStore->append(iter->children()))); + } + + Gtk::TreeRow row = *(deviceTreeStore->get_iter(i.treeRef.get_path())); + row[deviceTreeModelColumns.name] = i.name; + row[deviceTreeModelColumns.index] = i.index; + row[deviceTreeModelColumns.type] = ROW_TYPE_SINK_INPUT; + + deviceTreeView->expand_row(sinkRef.get_path(), true); + onDeviceTreeViewCursorChanged(); +} + +void MainWindow::updateInfo(SourceOutputInfo &i) { + if (!i.treeRef) { + SourceInfo *si = serverInfoManager->getSourceInfo(i.source); + if (!si) + return; + + Gtk::TreeIter iter = deviceTreeStore->get_iter(si->treeRef.get_path()); + i.treeRef = Gtk::TreeRowReference(deviceTreeStore, Gtk::TreePath(deviceTreeStore->append(iter->children()))); + } + + Gtk::TreeRow row = *(deviceTreeStore->get_iter(i.treeRef.get_path())); + row[deviceTreeModelColumns.name] = i.name; + row[deviceTreeModelColumns.index] = i.index; + row[deviceTreeModelColumns.type] = ROW_TYPE_SOURCE_OUTPUT; + + deviceTreeView->expand_row(sinkRef.get_path(), true); + onDeviceTreeViewCursorChanged(); +} + void MainWindow::removeInfo(SinkInfo &i) { if (i.treeRef) deviceTreeStore->erase(deviceTreeStore->get_iter(i.treeRef.get_path())); @@ -164,6 +204,21 @@ void MainWindow::removeInfo(ModuleInfo &i) { moduleOpenButton->set_sensitive(!moduleTreeStore->children().empty()); } +void MainWindow::removeInfo(SourceOutputInfo &i) { + if (!i.treeRef) + deviceTreeStore->erase(deviceTreeStore->get_iter(i.treeRef.get_path())); + + onDeviceTreeViewCursorChanged(); +} + +void MainWindow::removeInfo(SinkInputInfo &i) { + if (!i.treeRef) + deviceTreeStore->erase(deviceTreeStore->get_iter(i.treeRef.get_path())); + + onDeviceTreeViewCursorChanged(); +} + + void MainWindow::onDeviceTreeViewCursorChanged() { Gtk::TreeModel::Path p; Gtk::TreeViewColumn *c; @@ -271,6 +326,10 @@ void MainWindow::showDeviceWindow(const Gtk::TreePath &p) { serverInfoManager->showSinkWindow(row[deviceTreeModelColumns.index]); else if (row[deviceTreeModelColumns.type] == ROW_TYPE_SOURCE) serverInfoManager->showSourceWindow(row[deviceTreeModelColumns.index]); + else if (row[deviceTreeModelColumns.type] == ROW_TYPE_SINK_INPUT) + serverInfoManager->showSinkInputWindow(row[deviceTreeModelColumns.index]); + else if (row[deviceTreeModelColumns.type] == ROW_TYPE_SOURCE_OUTPUT) + serverInfoManager->showSourceOutputWindow(row[deviceTreeModelColumns.index]); } void MainWindow::showClientWindow(const Gtk::TreePath &p) { diff --git a/src/MainWindow.hh b/src/MainWindow.hh index 0157f9c..d843acf 100644 --- a/src/MainWindow.hh +++ b/src/MainWindow.hh @@ -89,12 +89,16 @@ public: virtual void updateInfo(SourceInfo &i); virtual void updateInfo(ClientInfo &i); virtual void updateInfo(ModuleInfo &i); + virtual void updateInfo(SinkInputInfo &i); + virtual void updateInfo(SourceOutputInfo &i); virtual void removeInfo(SinkInfo &i); virtual void removeInfo(SourceInfo &i); virtual void removeInfo(ClientInfo &i); virtual void removeInfo(ModuleInfo &i); - + virtual void removeInfo(SinkInputInfo &i); + virtual void removeInfo(SourceOutputInfo &i); + virtual void onDeviceTreeViewCursorChanged(); virtual void onDeviceTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */); virtual void onClientTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */); diff --git a/src/Makefile.am b/src/Makefile.am index ff42d0e..82f61d6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,7 +7,9 @@ paman_SOURCES=MainWindow.cc MainWindow.hh \ ServerInfoManager.cc ServerInfoManager.hh \ paman.cc paman.hh \ ClientWindow.cc ClientWindow.hh \ - ModuleWindow.cc ModuleWindow.hh + ModuleWindow.cc ModuleWindow.hh \ + SinkInputWindow.cc SinkInputWindow.hh \ + SourceOutputWindow.cc SourceOutputWindow.hh paman_LDADD=$(AM_LDADD) $(GUILIBS_LIBS) $(POLYP_LIBS) paman_CXXFLAGS=$(AM_CXXFLAGS) $(GUILIBS_CFLAGS) $(POLYP_CFLAGS) diff --git a/src/ServerInfoManager.cc b/src/ServerInfoManager.cc index c816f21..f271354 100644 --- a/src/ServerInfoManager.cc +++ b/src/ServerInfoManager.cc @@ -159,12 +159,96 @@ void ModuleInfo::showWindow() { } } +SinkInputInfo::SinkInputInfo(const struct pa_sink_input_info &i) : + name(i.name), + index(i.index), + sample_spec(i.sample_spec), + sink(i.sink), + client(i.client), + owner_module(i.owner_module), + volume(i.volume), + latency(i.latency), + window(NULL) { +} + +SinkInputInfo::~SinkInputInfo() { + if (window) + delete window; +} + +void SinkInputInfo::update(const struct pa_sink_input_info &i) { + name = i.name; + index = i.index; + sample_spec = i.sample_spec; + sink = i.sink; + client = i.client; + owner_module = i.owner_module; + volume = i.volume; + latency = i.latency; + + if (window) + window->updateInfo(*this); + g_assert(mainWindow); + mainWindow->updateInfo(*this); +} + +void SinkInputInfo::showWindow() { + if (window) + window->present(); + else { + window = SinkInputWindow::create(); + window->updateInfo(*this); + window->show(); + } +} + +SourceOutputInfo::SourceOutputInfo(const struct pa_source_output_info &i) : + name(i.name), + index(i.index), + sample_spec(i.sample_spec), + source(source), + client(client), + owner_module(owner_module), + window(NULL) { +} + +SourceOutputInfo::~SourceOutputInfo() { + if (window) + delete window; +} + +void SourceOutputInfo::update(const struct pa_source_output_info &i) { + index = i.index; + name = i.name; + sample_spec = i.sample_spec; + source = i.source; + client = i.client; + owner_module = i.owner_module; + + if (window) + window->updateInfo(*this); + g_assert(mainWindow); + mainWindow->updateInfo(*this); +} + +void SourceOutputInfo::showWindow() { + if (window) + window->present(); + else { + window = SourceOutputWindow::create(); + window->updateInfo(*this); + window->show(); + } +} + extern "C" { static void server_info_callback(struct pa_context *c, const struct pa_server_info *i, void *userdata); static void sink_info_callback(struct pa_context *c, const struct pa_sink_info *i, int is_last, void *userdata); static void source_info_callback(struct pa_context *c, const struct pa_source_info *i, int is_last, void *userdata); static void client_info_callback(struct pa_context *c, const struct pa_client_info *i, int is_last, void *userdata); static void module_info_callback(struct pa_context *c, const struct pa_module_info *i, int is_last, void *userdata); + static void sink_input_info_callback(struct pa_context *c, const struct pa_sink_input_info *i, int is_last, void *userdata); + static void source_output_info_callback(struct pa_context *c, const struct pa_source_output_info *i, int is_last, void *userdata); static void subscribe_callback(struct pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata); }; @@ -199,6 +283,16 @@ static void module_info_callback(struct pa_context *c, const struct pa_module_in if (i) si->updateInfo(*i); } +static void sink_input_info_callback(struct pa_context *c, const struct pa_sink_input_info *i, int is_last, void *userdata) { + ServerInfoManager *si = (ServerInfoManager*) userdata; + if (i) si->updateInfo(*i); +} + +static void source_output_info_callback(struct pa_context *c, const struct pa_source_output_info *i, int is_last, void *userdata) { + ServerInfoManager *si = (ServerInfoManager*) userdata; + if (i) si->updateInfo(*i); +} + static void subscribe_callback(struct pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata) { ServerInfoManager *si = (ServerInfoManager*) userdata; @@ -230,13 +324,19 @@ static void subscribe_callback(struct pa_context *c, enum pa_subscription_event_ pa_operation_unref(pa_context_get_client_info(c, index, client_info_callback, si)); break; case PA_SUBSCRIPTION_EVENT_SINK_INPUT: -// fprintf(stderr, "SINK INPUT EVENT\n"); + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) + si->removeSinkInputInfo(index); + else + pa_operation_unref(pa_context_get_sink_input_info(c, index, sink_input_info_callback, si)); break; case PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT: -// fprintf(stderr, "SOURCE OUTPUT EVENT\n"); + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) + si->removeSourceOutputInfo(index); + else + pa_operation_unref(pa_context_get_source_output_info(c, index, source_output_info_callback, si)); break; default: -// fprintf(stderr, "OTHER EVENT\n"); + fprintf(stderr, "OTHER EVENT\n"); break; } } @@ -248,6 +348,8 @@ ServerInfoManager::ServerInfoManager(struct pa_context &c) : pa_operation_unref(pa_context_get_source_info_list(&c, source_info_callback, this)); pa_operation_unref(pa_context_get_module_info_list(&c, module_info_callback, this)); pa_operation_unref(pa_context_get_client_info_list(&c, client_info_callback, this)); + pa_operation_unref(pa_context_get_sink_input_info_list(&c, sink_input_info_callback, this)); + pa_operation_unref(pa_context_get_source_output_info_list(&c, source_output_info_callback, this)); pa_context_set_subscribe_callback(&c, subscribe_callback, this); @@ -273,6 +375,12 @@ ServerInfoManager::~ServerInfoManager() { for (std::map::iterator i = modules.begin(); i != modules.end(); i++) delete i->second; + + for (std::map::iterator i = sinkInputs.begin(); i != sinkInputs.end(); i++) + delete i->second; + + for (std::map::iterator i = sourceOutputs.begin(); i != sourceOutputs.end(); i++) + delete i->second; } void ServerInfoManager::updateInfo(const struct pa_sink_info &i) { @@ -319,6 +427,28 @@ void ServerInfoManager::updateInfo(const struct pa_module_info &i) { } } +void ServerInfoManager::updateInfo(const struct pa_sink_input_info &i) { + SinkInputInfo *si; + if ((si = sinkInputs[i.index])) + si->update(i); + else { + SinkInputInfo *n = new SinkInputInfo(i); + sinkInputs[i.index] = n; + mainWindow->updateInfo(*n); + } +} + +void ServerInfoManager::updateInfo(const struct pa_source_output_info &i) { + SourceOutputInfo *si; + if ((si = sourceOutputs[i.index])) + si->update(i); + else { + SourceOutputInfo *n = new SourceOutputInfo(i); + sourceOutputs[i.index] = n; + mainWindow->updateInfo(*n); + } +} + void ServerInfoManager::showSinkWindow(uint32_t index) { SinkInfo *i; @@ -347,6 +477,20 @@ void ServerInfoManager::showModuleWindow(uint32_t index) { i->showWindow(); } +void ServerInfoManager::showSinkInputWindow(uint32_t index) { + SinkInputInfo *i; + + if ((i = sinkInputs[index])) + i->showWindow(); +} + +void ServerInfoManager::showSourceOutputWindow(uint32_t index) { + SourceOutputInfo *i; + + if ((i = sourceOutputs[index])) + i->showWindow(); +} + SourceInfo* ServerInfoManager::getSourceInfo(uint32_t index) { return sources[index]; @@ -402,6 +546,28 @@ void ServerInfoManager::removeModuleInfo(uint32_t index) { } } +void ServerInfoManager::removeSinkInputInfo(uint32_t index) { + SinkInputInfo *i; + if ((i = sinkInputs[index])) { + sinkInputs.erase(index); + mainWindow->removeInfo(*i); + delete i; + } +} + +void ServerInfoManager::removeSourceOutputInfo(uint32_t index) { + SourceOutputInfo *i; + if ((i = sourceOutputs[index])) { + sourceOutputs.erase(index); + mainWindow->removeInfo(*i); + 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)); } + +void ServerInfoManager::setSinkInputVolume(uint32_t index, uint32_t volume) { + pa_operation_unref(pa_context_set_sink_input_volume(&context, index, volume, NULL, NULL)); +} diff --git a/src/ServerInfoManager.hh b/src/ServerInfoManager.hh index 5c22f64..ba07800 100644 --- a/src/ServerInfoManager.hh +++ b/src/ServerInfoManager.hh @@ -11,12 +11,16 @@ class SourceInfo; class ServerInfo; class ClientInfo; class ModuleInfo; +class SinkInputInfo; +class SourceOutputInfo; #include "SinkWindow.hh" #include "SourceWindow.hh" #include "ClientWindow.hh" #include "ModuleWindow.hh" #include "MainWindow.hh" +#include "SinkInputWindow.hh" +#include "SourceOutputWindow.hh" class SinkInfo { public: @@ -91,6 +95,50 @@ public: ClientWindow *window; }; +class SinkInputInfo { +public: + + SinkInputInfo(const struct pa_sink_input_info &i); + ~SinkInputInfo(); + + void update(const struct pa_sink_input_info &i); + void showWindow(); + + Glib::ustring name; + uint32_t index; + struct pa_sample_spec sample_spec; + uint32_t sink; + uint32_t client; + uint32_t owner_module; + uint32_t volume; + uint32_t latency; + + Gtk::TreeRowReference treeRef; + + SinkInputWindow *window; +}; + +class SourceOutputInfo { +public: + + SourceOutputInfo(const struct pa_source_output_info &i); + ~SourceOutputInfo(); + + void update(const struct pa_source_output_info &i); + void showWindow(); + + Glib::ustring name; + uint32_t index; + struct pa_sample_spec sample_spec; + uint32_t source; + uint32_t client; + uint32_t owner_module; + + Gtk::TreeRowReference treeRef; + + SourceOutputWindow *window; +}; + class ServerInfoManager { public: ServerInfoManager(struct pa_context &c); @@ -100,11 +148,15 @@ public: void updateInfo(const struct pa_source_info &i); void updateInfo(const struct pa_client_info &i); void updateInfo(const struct pa_module_info &i); + void updateInfo(const struct pa_sink_input_info &i); + void updateInfo(const struct pa_source_output_info &i); void showSinkWindow(uint32_t index); void showSourceWindow(uint32_t index); void showClientWindow(uint32_t index); void showModuleWindow(uint32_t index); + void showSinkInputWindow(uint32_t index); + void showSourceOutputWindow(uint32_t index); SourceInfo* getSourceInfo(uint32_t index); SinkInfo* getSinkInfo(uint32_t index); @@ -115,14 +167,19 @@ public: void removeSourceInfo(uint32_t index); void removeClientInfo(uint32_t index); void removeModuleInfo(uint32_t index); + void removeSinkInputInfo(uint32_t index); + void removeSourceOutputInfo(uint32_t index); void setSinkVolume(uint32_t index, uint32_t volume); + void setSinkInputVolume(uint32_t index, uint32_t volume); protected: std::map sinks; std::map sources; std::map clients; std::map modules; + std::map sinkInputs; + std::map sourceOutputs; struct pa_context &context; }; diff --git a/src/SinkInputWindow.cc b/src/SinkInputWindow.cc index 68d3ec4..7baa13c 100644 --- a/src/SinkInputWindow.cc +++ b/src/SinkInputWindow.cc @@ -1,111 +1,131 @@ #include #include "paman.hh" -#include "SinkWindow.hh" +#include "SinkInputWindow.hh" -#define GLADE_NAME "sinkWindow" +#define GLADE_NAME "sinkInputWindow" -SinkWindow::SinkWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade) : +SinkInputWindow::SinkInputWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade) : Gtk::Window(cobject), nameLabel(NULL), - descriptionLabel(NULL), indexLabel(NULL), sampleTypeLabel(NULL), latencyLabel(NULL), + sinkLabel(NULL), + clientLabel(NULL), ownerModuleLabel(NULL), - monitorSourceLabel(NULL), volumeLabel(NULL), closeButton(NULL), - toMonitorSourceButton(NULL), toOwnerModuleButton(NULL), + toClientButton(NULL), + toSinkButton(NULL), volumeResetButton(NULL), volumeMuteButton(NULL), volumeScale(NULL) { refGlade->get_widget("nameLabel", nameLabel); - refGlade->get_widget("descriptionLabel", descriptionLabel); refGlade->get_widget("indexLabel", indexLabel); refGlade->get_widget("sampleTypeLabel", sampleTypeLabel); refGlade->get_widget("latencyLabel", latencyLabel); + refGlade->get_widget("sinkLabel", sinkLabel); + refGlade->get_widget("clientLabel", clientLabel); refGlade->get_widget("ownerModuleLabel", ownerModuleLabel); - refGlade->get_widget("monitorSourceLabel", monitorSourceLabel); refGlade->get_widget("closeButton", closeButton); - refGlade->get_widget("toMonitorSourceButton", toMonitorSourceButton); refGlade->get_widget("toOwnerModuleButton", toOwnerModuleButton); + refGlade->get_widget("toClientButton", toClientButton); + refGlade->get_widget("toSinkButton", toSinkButton); 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)); + closeButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onCloseButton)); + toOwnerModuleButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onToOwnerModuleButton)); + toClientButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onToClientButton)); + toSinkButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onToSinkButton)); + volumeScale->signal_value_changed().connect(sigc::mem_fun(*this, &SinkInputWindow::onVolumeScaleValueChanged)); + volumeResetButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onVolumeResetButton)); + volumeMuteButton->signal_clicked().connect(sigc::mem_fun(*this, &SinkInputWindow::onVolumeMuteButton)); } -SinkWindow* SinkWindow::create() { - SinkWindow *w = NULL; +SinkInputWindow* SinkInputWindow::create() { + SinkInputWindow *w = NULL; Glib::RefPtr refXml = Gnome::Glade::Xml::create(GLADE_FILE, GLADE_NAME); refXml->get_widget_derived(GLADE_NAME, w); return w; } -void SinkWindow::updateInfo(const SinkInfo &i) { +void SinkInputWindow::updateInfo(const SinkInputInfo &i) { char t[20], ss[PA_SAMPLE_SNPRINT_MAX_LENGTH]; nameLabel->set_text(i.name); - descriptionLabel->set_text(i.description); snprintf(t, sizeof(t), "#%u", i.index); indexLabel->set_text(t); pa_sample_snprint(ss, sizeof(ss), &i.sample_spec); sampleTypeLabel->set_text(ss); - snprintf(t, sizeof(t), "#%u", i.owner_module); - ownerModuleLabel->set_text(t); + + if (i.owner_module == PA_INVALID_INDEX) + ownerModuleLabel->set_markup("n/a"); + else { + snprintf(t, sizeof(t), "#%u", i.owner_module); + ownerModuleLabel->set_text(t); + } snprintf(t, sizeof(t), "%u usec", i.latency); latencyLabel->set_text(t); - SourceInfo *source = serverInfoManager->getSourceInfo(i.monitor_source); - monitorSourceLabel->set_text(source->name); + SinkInfo *sink = serverInfoManager->getSinkInfo(i.sink); + sinkLabel->set_text(sink->name); + + if (i.client == PA_INVALID_INDEX) + clientLabel->set_markup("n/a"); + else { + ClientInfo *client = serverInfoManager->getClientInfo(i.client); + clientLabel->set_text(client->name); + } - volumeScale->set_value(((double) i.volume / 0x100) * 100); - snprintf(t, sizeof(t), "%u%%", (i.volume*100)/0x100); + volumeScale->set_value((double) i.volume * 100 / 0x100); + snprintf(t, sizeof(t), "%u%%", (i.volume * 100)/ 0x100); volumeLabel->set_text(t); - set_title("Sink: "+i.name); - - monitor_source = i.monitor_source; + set_title("Sink Input: "+i.name); + + this->sink = i.sink; + client = i.client; owner_module = i.owner_module; index = i.index; - toOwnerModuleButton->set_sensitive(owner_module != (uint32_t) -1); + toOwnerModuleButton->set_sensitive(owner_module != PA_INVALID_INDEX); + toClientButton->set_sensitive(client != PA_INVALID_INDEX); } -void SinkWindow::onCloseButton() { +void SinkInputWindow::onCloseButton() { hide(); } -void SinkWindow::onToMonitorSourceButton() { - serverInfoManager->showSourceWindow(monitor_source); +void SinkInputWindow::onToOwnerModuleButton() { + if (owner_module != PA_INVALID_INDEX) + serverInfoManager->showModuleWindow(owner_module); } -void SinkWindow::onToOwnerModuleButton() { - if (owner_module != (uint32_t) -1) - serverInfoManager->showModuleWindow(owner_module); +void SinkInputWindow::onToSinkButton() { + serverInfoManager->showSinkWindow(sink); +} + +void SinkInputWindow::onToClientButton() { + serverInfoManager->showClientWindow(client); } -void SinkWindow::onVolumeScaleValueChanged() { - serverInfoManager->setSinkVolume(index, (uint32_t) ((volumeScale->get_value()*0x100)/100)); +void SinkInputWindow::onVolumeScaleValueChanged() { + serverInfoManager->setSinkInputVolume(index, (uint32_t) ((volumeScale->get_value()*0x100)/100)); } -void SinkWindow::onVolumeResetButton() { - serverInfoManager->setSinkVolume(index, PA_VOLUME_NORM); +void SinkInputWindow::onVolumeResetButton() { + serverInfoManager->setSinkInputVolume(index, PA_VOLUME_NORM); } -void SinkWindow::onVolumeMuteButton() { - serverInfoManager->setSinkVolume(index, PA_VOLUME_MUTE); +void SinkInputWindow::onVolumeMuteButton() { + serverInfoManager->setSinkInputVolume(index, PA_VOLUME_MUTE); } diff --git a/src/SinkInputWindow.hh b/src/SinkInputWindow.hh index b0417aa..aaf76f4 100644 --- a/src/SinkInputWindow.hh +++ b/src/SinkInputWindow.hh @@ -1,42 +1,44 @@ -#ifndef foosinkwindowhhfoo -#define foosinkwindowhhfoo +#ifndef foosinkinputwindowhhfoo +#define foosinkinputwindowhhfoo #include #include -class SinkWindow; +class SinkInputWindow; #include "ServerInfoManager.hh" -class SinkWindow : public Gtk::Window { +class SinkInputWindow : public Gtk::Window { public: - SinkWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade); - static SinkWindow* create(); + SinkInputWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade); + static SinkInputWindow* create(); Gtk::Label *nameLabel, - *descriptionLabel, *indexLabel, *sampleTypeLabel, *latencyLabel, + *sinkLabel, + *clientLabel, *ownerModuleLabel, - *monitorSourceLabel, *volumeLabel; Gtk::Button *closeButton, - *toMonitorSourceButton, *toOwnerModuleButton, + *toClientButton, + *toSinkButton, *volumeResetButton, *volumeMuteButton; Gtk::HScale *volumeScale; - uint32_t index, owner_module, monitor_source; + uint32_t index, owner_module, sink, client; - void updateInfo(const SinkInfo &i); + void updateInfo(const SinkInputInfo &i); virtual void onCloseButton(); - virtual void onToMonitorSourceButton(); virtual void onToOwnerModuleButton(); + virtual void onToClientButton(); + virtual void onToSinkButton(); virtual void onVolumeScaleValueChanged(); virtual void onVolumeResetButton(); virtual void onVolumeMuteButton(); diff --git a/src/SourceOutputWindow.cc b/src/SourceOutputWindow.cc index 68d3ec4..fd5ae35 100644 --- a/src/SourceOutputWindow.cc +++ b/src/SourceOutputWindow.cc @@ -1,111 +1,99 @@ #include #include "paman.hh" -#include "SinkWindow.hh" +#include "SourceOutputWindow.hh" -#define GLADE_NAME "sinkWindow" +#define GLADE_NAME "sourceOutputWindow" -SinkWindow::SinkWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade) : +SourceOutputWindow::SourceOutputWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade) : Gtk::Window(cobject), nameLabel(NULL), - descriptionLabel(NULL), indexLabel(NULL), sampleTypeLabel(NULL), - latencyLabel(NULL), + sourceLabel(NULL), + clientLabel(NULL), ownerModuleLabel(NULL), - monitorSourceLabel(NULL), - volumeLabel(NULL), closeButton(NULL), - toMonitorSourceButton(NULL), toOwnerModuleButton(NULL), - volumeResetButton(NULL), - volumeMuteButton(NULL), - volumeScale(NULL) { + toClientButton(NULL), + toSourceButton(NULL) { refGlade->get_widget("nameLabel", nameLabel); - refGlade->get_widget("descriptionLabel", descriptionLabel); refGlade->get_widget("indexLabel", indexLabel); refGlade->get_widget("sampleTypeLabel", sampleTypeLabel); - refGlade->get_widget("latencyLabel", latencyLabel); + refGlade->get_widget("sourceLabel", sourceLabel); + refGlade->get_widget("clientLabel", clientLabel); refGlade->get_widget("ownerModuleLabel", ownerModuleLabel); - refGlade->get_widget("monitorSourceLabel", monitorSourceLabel); refGlade->get_widget("closeButton", closeButton); - refGlade->get_widget("toMonitorSourceButton", toMonitorSourceButton); refGlade->get_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)); + refGlade->get_widget("toClientButton", toClientButton); + refGlade->get_widget("toSourceButton", toSourceButton); + + closeButton->signal_clicked().connect(sigc::mem_fun(*this, &SourceOutputWindow::onCloseButton)); + toOwnerModuleButton->signal_clicked().connect(sigc::mem_fun(*this, &SourceOutputWindow::onToOwnerModuleButton)); + toClientButton->signal_clicked().connect(sigc::mem_fun(*this, &SourceOutputWindow::onToClientButton)); + toSourceButton->signal_clicked().connect(sigc::mem_fun(*this, &SourceOutputWindow::onToSourceButton)); } -SinkWindow* SinkWindow::create() { - SinkWindow *w = NULL; +SourceOutputWindow* SourceOutputWindow::create() { + SourceOutputWindow *w = NULL; Glib::RefPtr refXml = Gnome::Glade::Xml::create(GLADE_FILE, GLADE_NAME); refXml->get_widget_derived(GLADE_NAME, w); return w; } -void SinkWindow::updateInfo(const SinkInfo &i) { +void SourceOutputWindow::updateInfo(const SourceOutputInfo &i) { char t[20], ss[PA_SAMPLE_SNPRINT_MAX_LENGTH]; nameLabel->set_text(i.name); - descriptionLabel->set_text(i.description); snprintf(t, sizeof(t), "#%u", i.index); indexLabel->set_text(t); pa_sample_snprint(ss, sizeof(ss), &i.sample_spec); sampleTypeLabel->set_text(ss); - snprintf(t, sizeof(t), "#%u", i.owner_module); - ownerModuleLabel->set_text(t); - snprintf(t, sizeof(t), "%u usec", i.latency); - latencyLabel->set_text(t); + if (i.owner_module == PA_INVALID_INDEX) + ownerModuleLabel->set_markup("n/a"); + else { + snprintf(t, sizeof(t), "#%u", i.owner_module); + ownerModuleLabel->set_text(t); + } - SourceInfo *source = serverInfoManager->getSourceInfo(i.monitor_source); - monitorSourceLabel->set_text(source->name); + SourceInfo *source = serverInfoManager->getSourceInfo(i.source); + sourceLabel->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); - - set_title("Sink: "+i.name); + if (i.client == PA_INVALID_INDEX) + clientLabel->set_markup("n/a"); + else { + ClientInfo *client = serverInfoManager->getClientInfo(i.client); + clientLabel->set_text(client->name); + } + + set_title("Source Output: "+i.name); - monitor_source = i.monitor_source; + this->source = i.source; owner_module = i.owner_module; - index = i.index; + client = i.client; - toOwnerModuleButton->set_sensitive(owner_module != (uint32_t) -1); + toOwnerModuleButton->set_sensitive(owner_module != PA_INVALID_INDEX); + toClientButton->set_sensitive(client != PA_INVALID_INDEX); } -void SinkWindow::onCloseButton() { +void SourceOutputWindow::onCloseButton() { hide(); } -void SinkWindow::onToMonitorSourceButton() { - serverInfoManager->showSourceWindow(monitor_source); -} - -void SinkWindow::onToOwnerModuleButton() { - if (owner_module != (uint32_t) -1) +void SourceOutputWindow::onToOwnerModuleButton() { + if (owner_module != PA_INVALID_INDEX) 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 SourceOutputWindow::onToClientButton() { + if (client != PA_INVALID_INDEX) + serverInfoManager->showClientWindow(client); } -void SinkWindow::onVolumeMuteButton() { - serverInfoManager->setSinkVolume(index, PA_VOLUME_MUTE); +void SourceOutputWindow::onToSourceButton() { + if (source != PA_INVALID_INDEX) + serverInfoManager->showSourceWindow(source); } - diff --git a/src/SourceOutputWindow.hh b/src/SourceOutputWindow.hh index b0417aa..a98a9d0 100644 --- a/src/SourceOutputWindow.hh +++ b/src/SourceOutputWindow.hh @@ -1,45 +1,38 @@ -#ifndef foosinkwindowhhfoo -#define foosinkwindowhhfoo +#ifndef foosourceoutputwindowhhfoo +#define foosourceoutputwindowhhfoo #include #include -class SinkWindow; +class SourceOutputWindow; #include "ServerInfoManager.hh" -class SinkWindow : public Gtk::Window { +class SourceOutputWindow : public Gtk::Window { public: - SinkWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade); - static SinkWindow* create(); + SourceOutputWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade); + static SourceOutputWindow* create(); Gtk::Label *nameLabel, - *descriptionLabel, *indexLabel, *sampleTypeLabel, - *latencyLabel, - *ownerModuleLabel, - *monitorSourceLabel, - *volumeLabel; + *sourceLabel, + *clientLabel, + *ownerModuleLabel; Gtk::Button *closeButton, - *toMonitorSourceButton, *toOwnerModuleButton, - *volumeResetButton, - *volumeMuteButton; + *toClientButton, + *toSourceButton; - Gtk::HScale *volumeScale; - - uint32_t index, owner_module, monitor_source; + uint32_t owner_module, source, client; - void updateInfo(const SinkInfo &i); + void updateInfo(const SourceOutputInfo &i); virtual void onCloseButton(); - virtual void onToMonitorSourceButton(); virtual void onToOwnerModuleButton(); - virtual void onVolumeScaleValueChanged(); - virtual void onVolumeResetButton(); - virtual void onVolumeMuteButton(); + virtual void onToClientButton(); + virtual void onToSourceButton(); }; #endif diff --git a/src/paman.glade b/src/paman.glade index e8915e9..464d278 100644 --- a/src/paman.glade +++ b/src/paman.glade @@ -1400,7 +1400,7 @@ True True True - To Owner Module + Go To Owner Module True GTK_RELIEF_NORMAL True @@ -1412,7 +1412,7 @@ True True True - To Monitor Source + Go To Monitor Source True GTK_RELIEF_NORMAL True @@ -2597,4 +2597,1076 @@ + + Sink Input + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + + + + 5 + True + False + 5 + + + + True + True + True + True + GTK_POS_TOP + False + False + + + + 5 + True + False + 5 + + + + True + 8 + 2 + False + 5 + 10 + + + + True + <b>Name:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + <b>Index:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + True + label4745 + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 0 + 1 + + + + + + + True + True + label4746 + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 1 + 2 + + + + + + + True + <b>Sample Type:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + <b>Latency:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + <b>Owner Module:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 6 + 7 + fill + + + + + + + True + <b>Connected to Sink:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + <b>Client:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 5 + 6 + fill + + + + + + + True + <b>Volume:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 7 + 8 + fill + + + + + + + True + True + label4755 + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 2 + 3 + fill + + + + + + + True + True + label4756 + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 3 + 4 + fill + + + + + + + True + True + label4757 + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 4 + 5 + fill + + + + + + + True + True + label4758 + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 5 + 6 + fill + + + + + + + True + label4759 + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 6 + 7 + fill + + + + + + + True + False + 5 + + + + 40 + True + True + 100% + False + True + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 100 + True + True + False + GTK_POS_LEFT + 0 + GTK_UPDATE_DISCONTINUOUS + False + 147.692 0 500 10 100 20 + + + 0 + True + 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 + 2 + 7 + 8 + fill + + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_START + 0 + + + + True + True + True + Go To Owner Module + True + GTK_RELIEF_NORMAL + True + + + + + + True + True + True + Go To Client + True + GTK_RELIEF_NORMAL + True + + + + + + True + True + True + Go To Sink + True + GTK_RELIEF_NORMAL + True + + + + + 0 + False + False + + + + + False + True + + + + + + True + Basic + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_END + 0 + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + True + + + + + 0 + False + False + + + + + + + + Source Output + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + + + + 5 + True + False + 5 + + + + True + True + True + True + GTK_POS_TOP + False + False + + + + 5 + True + False + 5 + + + + True + 6 + 2 + False + 5 + 10 + + + + True + <b>Name:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + <b>Index:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + True + label4745 + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 0 + 1 + + + + + + + True + True + label4746 + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 1 + 2 + + + + + + + True + <b>Sample Type:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + True + label4755 + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 2 + 3 + fill + + + + + + + True + <b>Connected to Source:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + <b>Client:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + <b>Owner Module:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 5 + 6 + fill + + + + + + + True + True + label4757 + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 3 + 4 + fill + + + + + + + True + True + label4758 + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 4 + 5 + fill + + + + + + + True + True + label4759 + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 5 + 6 + fill + + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_START + 0 + + + + True + True + True + Go To Owner Module + True + GTK_RELIEF_NORMAL + True + + + + + + True + True + True + Go To Client + True + GTK_RELIEF_NORMAL + True + + + + + + True + True + True + Go To Source + True + GTK_RELIEF_NORMAL + True + + + + + 0 + False + False + + + + + False + True + + + + + + True + Basic + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + 0 + True + True + + + + + + True + GTK_BUTTONBOX_END + 0 + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + True + + + + + 0 + False + False + + + + + + -- cgit