From 33b0d86c66158b9aa0e1ab7b4b1c689fd83ab5ac Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 19 Aug 2004 21:54:11 +0000 Subject: sample cache stuff git-svn-id: file:///home/lennart/svn/public/paman/trunk@16 cdefa82f-4ce1-0310-97f5-ab6066f37c3c --- src/MainWindow.cc | 127 ++++++++++++++++- src/MainWindow.hh | 41 +++++- src/Makefile.am | 3 +- src/SampleWindow.cc | 55 +++++++ src/SampleWindow.hh | 29 ++++ src/ServerInfoManager.cc | 98 ++++++++++++- src/ServerInfoManager.hh | 30 +++- src/paman.glade | 365 +++++++++++++++++++++++++++++++++++++++++++++-- 8 files changed, 726 insertions(+), 22 deletions(-) create mode 100644 src/SampleWindow.cc create mode 100644 src/SampleWindow.hh diff --git a/src/MainWindow.cc b/src/MainWindow.cc index ae6836c..6e2dbe2 100644 --- a/src/MainWindow.cc +++ b/src/MainWindow.cc @@ -30,13 +30,17 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtrget_widget("statusLabel", statusLabel); refGlade->get_widget("serverNameLabel", serverNameLabel); @@ -48,15 +52,19 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtrget_widget("deviceTreeView", deviceTreeView); refGlade->get_widget("clientTreeView", clientTreeView); refGlade->get_widget("moduleTreeView", moduleTreeView); + refGlade->get_widget("sampleCacheTreeView", sampleTreeView); refGlade->get_widget("deviceOpenButton", deviceOpenButton); refGlade->get_widget("clientOpenButton", clientOpenButton); refGlade->get_widget("moduleOpenButton", moduleOpenButton); + refGlade->get_widget("sampleCacheOpenButton", sampleOpenButton); + refGlade->get_widget("sampleCachePlayButton", samplePlayButton); refGlade->get_widget("connectButton", connectButton); refGlade->get_widget("disconnectButton", disconnectButton); refGlade->get_widget("linkLibraryVersionLabel", linkLibraryVersionLabel); refGlade->get_widget("compiledLibraryVersionLabel", compiledLibraryVersionLabel); refGlade->get_widget("statButton", statButton); refGlade->get_widget("titleEventBox", titleEventBox); + refGlade->get_widget("sinkComboBox", sinkComboBox); deviceTreeStore = Gtk::TreeStore::create(deviceTreeModelColumns); deviceTreeView->set_model(deviceTreeStore); @@ -75,12 +83,23 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtrappend_column("Name", moduleTreeModelColumns.name); moduleTreeView->append_column("Argument", moduleTreeModelColumns.argument); moduleTreeView->signal_row_activated().connect(sigc::mem_fun(*this, &MainWindow::onModuleTreeViewRowActivated)); - + + sampleTreeStore = Gtk::TreeStore::create(sampleTreeModelColumns); + sampleTreeView->set_model(sampleTreeStore); + sampleTreeView->append_column("Name", sampleTreeModelColumns.name); + sampleTreeView->signal_row_activated().connect(sigc::mem_fun(*this, &MainWindow::onSampleTreeViewRowActivated)); + + sinkListStore = Gtk::ListStore::create(sinkTreeModelColumns); + sinkComboBox->set_model(sinkListStore); +// sinkComboBox->append_column("Name", sinkTreeModelColumns.name); + connectButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onConnectButton)); disconnectButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onDisconnectButton)); deviceOpenButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onDeviceOpenButton)); clientOpenButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onClientOpenButton)); moduleOpenButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onModuleOpenButton)); + sampleOpenButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onSampleOpenButton)); + samplePlayButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onSamplePlayButton)); statButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onStatButton)); linkLibraryVersionLabel->set_text(pa_get_library_version()); @@ -119,6 +138,20 @@ void MainWindow::updateInfo(SinkInfo &i) { deviceTreeView->expand_row(sinkRef.get_path(), false); onDeviceTreeViewCursorChanged(); + + if (!i.sinkComboBoxTreeRef) + i.sinkComboBoxTreeRef = Gtk::TreeRowReference(sinkListStore, Gtk::TreePath(sinkListStore->append())); + + row = *(sinkListStore->get_iter(i.sinkComboBoxTreeRef.get_path())); + row[sinkTreeModelColumns.name] = i.name; + row[sinkTreeModelColumns.index] = i.index; + + if (sinkComboBox->get_active_row_number() == -1) + sinkComboBox->set_active(0); + + bool b = !sampleTreeStore->children().empty(); + sinkComboBox->set_sensitive(b); + samplePlayButton->set_sensitive(b); } void MainWindow::updateInfo(SourceInfo &i) { @@ -197,11 +230,32 @@ void MainWindow::updateInfo(SourceOutputInfo &i) { onDeviceTreeViewCursorChanged(); } +void MainWindow::updateInfo(SampleInfo &i) { + if (!i.treeRef) + i.treeRef = Gtk::TreeRowReference(sampleTreeStore, Gtk::TreePath(sampleTreeStore->append())); + + Gtk::TreeRow row = *(sampleTreeStore->get_iter(i.treeRef.get_path())); + row[sampleTreeModelColumns.name] = i.name; + row[sampleTreeModelColumns.index] = i.index; + sampleOpenButton->set_sensitive(true); + + bool b = !sinkListStore->children().empty(); + samplePlayButton->set_sensitive(b); + sinkComboBox->set_sensitive(b); +} + void MainWindow::removeInfo(SinkInfo &i) { if (i.treeRef) deviceTreeStore->erase(deviceTreeStore->get_iter(i.treeRef.get_path())); - + onDeviceTreeViewCursorChanged(); + + if (i.sinkComboBoxTreeRef) + sinkListStore->erase(sinkListStore->get_iter(i.sinkComboBoxTreeRef.get_path())); + + bool b = !sinkListStore->children().empty() && !sampleTreeStore->children().empty(); + samplePlayButton->set_sensitive(b); + sinkComboBox->set_sensitive(b); } void MainWindow::removeInfo(SourceInfo &i) { @@ -233,13 +287,23 @@ void MainWindow::removeInfo(SinkInputInfo &i) { } void MainWindow::removeInfo(SourceOutputInfo &i) { - if (i.treeRef) deviceTreeStore->erase(deviceTreeStore->get_iter(i.treeRef.get_path())); onDeviceTreeViewCursorChanged(); } +void MainWindow::removeInfo(SampleInfo &i) { + if (i.treeRef) + sampleTreeStore->erase(sampleTreeStore->get_iter(i.treeRef.get_path())); + + sampleOpenButton->set_sensitive(!sampleTreeStore->children().empty()); + + bool b = !sinkListStore->children().empty() && !sampleTreeStore->children().empty(); + samplePlayButton->set_sensitive(b); + sinkComboBox->set_sensitive(b); +} + void MainWindow::onDeviceTreeViewCursorChanged() { Gtk::TreeModel::Path p; Gtk::TreeViewColumn *c; @@ -263,6 +327,10 @@ void MainWindow::onModuleTreeViewRowActivated(const Gtk::TreeModel::Path& path, showModuleWindow(path); } +void MainWindow::onSampleTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */) { + showSampleWindow(path); +} + void MainWindow::updateInfo(const struct pa_server_info &i) { char t[PA_SAMPLE_SNPRINT_MAX_LENGTH]; serverNameLabel->set_text(i.server_name); @@ -300,10 +368,15 @@ void MainWindow::clearAllData() { clientTreeStore->clear(); moduleTreeStore->clear(); + sampleTreeStore->clear(); + sinkListStore->clear(); deviceOpenButton->set_sensitive(false); clientOpenButton->set_sensitive(false); moduleOpenButton->set_sensitive(false); + sampleOpenButton->set_sensitive(false); + samplePlayButton->set_sensitive(false); + sinkComboBox->set_sensitive(false); serverNameLabel->set_markup("n/a"); serverVersionLabel->set_markup("n/a"); @@ -316,21 +389,36 @@ void MainWindow::onDeviceOpenButton() { Gtk::TreeModel::Path p; Gtk::TreeViewColumn *c; deviceTreeView->get_cursor(p, c); - showDeviceWindow(p); + + if (p.gobj()) + showDeviceWindow(p); } void MainWindow::onClientOpenButton() { Gtk::TreeModel::Path p; Gtk::TreeViewColumn *c; clientTreeView->get_cursor(p, c); - showClientWindow(p); + + if (p.gobj()) + showClientWindow(p); } void MainWindow::onModuleOpenButton() { Gtk::TreeModel::Path p; Gtk::TreeViewColumn *c; moduleTreeView->get_cursor(p, c); - showModuleWindow(p); + + if (p.gobj()) + showModuleWindow(p); +} + +void MainWindow::onSampleOpenButton() { + Gtk::TreeModel::Path p; + Gtk::TreeViewColumn *c; + sampleTreeView->get_cursor(p, c); + + if (p.gobj()) + showSampleWindow(p); } void MainWindow::onConnectButton() { @@ -373,9 +461,34 @@ void MainWindow::showModuleWindow(const Gtk::TreePath &p) { serverInfoManager->showModuleWindow(row[moduleTreeModelColumns.index]); } +void MainWindow::showSampleWindow(const Gtk::TreePath &p) { + if (!serverInfoManager) + return; + + Gtk::TreeModel::Row row = *(sampleTreeStore->get_iter(p)); + serverInfoManager->showSampleWindow(row[sampleTreeModelColumns.index]); +} + void MainWindow::onStatButton() { if (!serverInfoManager) return; serverInfoManager->showStatWindow(); } + +void MainWindow::onSamplePlayButton() { + Gtk::TreeModel::Path p; + Gtk::TreeViewColumn *c; + sampleTreeView->get_cursor(p, c); + + if (!p.gobj()) + return; + + Gtk::TreeModel::Row sampleRow = *(sampleTreeStore->get_iter(p)); + Gtk::TreeModel::Row sinkRow = *sinkComboBox->get_active(); + + uint32_t sampleIndex = sampleRow[sampleTreeModelColumns.index]; + uint32_t sinkIndex = sinkRow[sinkTreeModelColumns.index]; + + serverInfoManager->playSample(sampleIndex, sinkIndex); +} diff --git a/src/MainWindow.hh b/src/MainWindow.hh index 75c18f2..4ddf403 100644 --- a/src/MainWindow.hh +++ b/src/MainWindow.hh @@ -28,16 +28,21 @@ public: Gtk::Button *deviceOpenButton, *clientOpenButton, *moduleOpenButton, + *sampleOpenButton, + *samplePlayButton, *connectButton, *disconnectButton, *statButton; Gtk::TreeView *deviceTreeView, *clientTreeView, - *moduleTreeView; + *moduleTreeView, + *sampleTreeView; Gtk::EventBox *titleEventBox; + Gtk::ComboBox *sinkComboBox; + protected: class DeviceTreeModelColumns : public Gtk::TreeModel::ColumnRecord { @@ -90,6 +95,34 @@ protected: ModuleTreeModelColumns moduleTreeModelColumns; Glib::RefPtr moduleTreeStore; + class SampleTreeModelColumns : public Gtk::TreeModel::ColumnRecord { + public: + SampleTreeModelColumns() { + add(name); + add(index); + } + + Gtk::TreeModelColumn name; + Gtk::TreeModelColumn index; + }; + + SampleTreeModelColumns sampleTreeModelColumns; + Glib::RefPtr sampleTreeStore; + + class SinkTreeModelColumns : public Gtk::TreeModel::ColumnRecord { + public: + SinkTreeModelColumns() { + add(name); + add(index); + } + + Gtk::TreeModelColumn name; + Gtk::TreeModelColumn index; + }; + + SinkTreeModelColumns sinkTreeModelColumns; + Glib::RefPtr sinkListStore; + public: virtual void updateInfo(const struct pa_server_info &i); virtual void updateInfo(SinkInfo &i); @@ -98,6 +131,7 @@ public: virtual void updateInfo(ModuleInfo &i); virtual void updateInfo(SinkInputInfo &i); virtual void updateInfo(SourceOutputInfo &i); + virtual void updateInfo(SampleInfo &i); virtual void removeInfo(SinkInfo &i); virtual void removeInfo(SourceInfo &i); @@ -105,11 +139,13 @@ public: virtual void removeInfo(ModuleInfo &i); virtual void removeInfo(SinkInputInfo &i); virtual void removeInfo(SourceOutputInfo &i); + virtual void removeInfo(SampleInfo &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 */); virtual void onModuleTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */); + virtual void onSampleTreeViewRowActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */); virtual void showSuccess(const char *t); virtual void showFailure(const char *t); @@ -118,6 +154,8 @@ public: virtual void onDeviceOpenButton(); virtual void onClientOpenButton(); virtual void onModuleOpenButton(); + virtual void onSampleOpenButton(); + virtual void onSamplePlayButton(); virtual void onConnectButton(); virtual void onDisconnectButton(); virtual void onStatButton(); @@ -125,6 +163,7 @@ public: virtual void showDeviceWindow(const Gtk::TreePath &p); virtual void showClientWindow(const Gtk::TreePath &p); virtual void showModuleWindow(const Gtk::TreePath &p); + virtual void showSampleWindow(const Gtk::TreePath &p); }; #endif diff --git a/src/Makefile.am b/src/Makefile.am index 523b925..d374193 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,7 +10,8 @@ paman_SOURCES=MainWindow.cc MainWindow.hh \ ModuleWindow.cc ModuleWindow.hh \ SinkInputWindow.cc SinkInputWindow.hh \ SourceOutputWindow.cc SourceOutputWindow.hh \ - StatWindow.cc StatWindow.hh + StatWindow.cc StatWindow.hh \ + SampleWindow.cc SampleWindow.hh paman_LDADD=$(AM_LDADD) $(GUILIBS_LIBS) $(POLYP_LIBS) paman_CXXFLAGS=$(AM_CXXFLAGS) $(GUILIBS_CFLAGS) $(POLYP_CFLAGS) diff --git a/src/SampleWindow.cc b/src/SampleWindow.cc new file mode 100644 index 0000000..b1ea149 --- /dev/null +++ b/src/SampleWindow.cc @@ -0,0 +1,55 @@ +#include + +#include "paman.hh" +#include "SampleWindow.hh" + +#define GLADE_NAME "sampleWindow" + +SampleWindow::SampleWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade) : + Gtk::Window(cobject), + nameLabel(NULL), + indexLabel(NULL), + volumeLabel(NULL), + sampleTypeLabel(NULL), + durationLabel(NULL), + closeButton(NULL) { + + refGlade->get_widget("nameLabel", nameLabel); + refGlade->get_widget("indexLabel", indexLabel); + refGlade->get_widget("volumeLabel", volumeLabel); + refGlade->get_widget("sampleTypeLabel", sampleTypeLabel); + refGlade->get_widget("durationLabel", durationLabel); + refGlade->get_widget("closeButton", closeButton); + + closeButton->signal_clicked().connect(sigc::mem_fun(*this, &SampleWindow::onCloseButton)); +} + +SampleWindow* SampleWindow::create() { + SampleWindow *w = NULL; + Glib::RefPtr refXml = Gnome::Glade::Xml::create(GLADE_FILE, GLADE_NAME); + refXml->get_widget_derived(GLADE_NAME, w); + return w; +} + +void SampleWindow::updateInfo(const SampleInfo &i) { + char t[20], ss[PA_SAMPLE_SNPRINT_MAX_LENGTH]; + + nameLabel->set_text(i.name); + snprintf(t, sizeof(t), "#%u", i.index); + indexLabel->set_text(t); + + snprintf(t, sizeof(t), "%0.0f%%", (double) i.volume / 0x100 * 100); + volumeLabel->set_text(t); + + pa_sample_spec_snprint(ss, sizeof(ss), &i.sample_spec); + sampleTypeLabel->set_text(ss); + + snprintf(t, sizeof(t), "%0.1fs", (double) i.duration/1000000); + durationLabel->set_text(t); + + set_title("Sample: "+i.name); +} + +void SampleWindow::onCloseButton() { + hide(); +} diff --git a/src/SampleWindow.hh b/src/SampleWindow.hh new file mode 100644 index 0000000..61c8535 --- /dev/null +++ b/src/SampleWindow.hh @@ -0,0 +1,29 @@ +#ifndef foosamplewindowhhfoo +#define foosamplewindowhhfoo + +#include +#include + +class SampleWindow; + +#include "ServerInfoManager.hh" + +class SampleWindow : public Gtk::Window { +public: + SampleWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade); + static SampleWindow* create(); + + Gtk::Label *nameLabel, + *indexLabel, + *volumeLabel, + *sampleTypeLabel, + *durationLabel; + + Gtk::Button *closeButton; + + void updateInfo(const SampleInfo &i); + + virtual void onCloseButton(); +}; + +#endif diff --git a/src/ServerInfoManager.cc b/src/ServerInfoManager.cc index 9542773..bd16938 100644 --- a/src/ServerInfoManager.cc +++ b/src/ServerInfoManager.cc @@ -241,6 +241,43 @@ void SourceOutputInfo::showWindow() { } } +SampleInfo::SampleInfo(const struct pa_sample_info &i) : + index(i.index), + name(i.name), + sample_spec(i.sample_spec), + volume(i.volume), + duration(i.duration), + window(NULL) { +} + +SampleInfo::~SampleInfo() { + if (window) + delete window; +} + +void SampleInfo::update(const struct pa_sample_info &i) { + index = i.index; + name = i.name; + sample_spec = i.sample_spec; + volume = i.volume; + duration = i.duration; + + if (window) + window->updateInfo(*this); + g_assert(mainWindow); + mainWindow->updateInfo(*this); +} + +void SampleInfo::showWindow() { + if (window) + window->present(); + else { + window = SampleWindow::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); @@ -249,6 +286,7 @@ extern "C" { 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 sample_info_callback(struct pa_context *c, const struct pa_sample_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); }; @@ -293,6 +331,11 @@ static void source_output_info_callback(struct pa_context *c, const struct pa_so if (i) si->updateInfo(*i); } +static void sample_info_callback(struct pa_context *c, const struct pa_sample_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; @@ -335,6 +378,12 @@ static void subscribe_callback(struct pa_context *c, enum pa_subscription_event_ else pa_operation_unref(pa_context_get_source_output_info(c, index, source_output_info_callback, si)); break; + case PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE: + if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) + si->removeSampleInfo(index); + else + pa_operation_unref(pa_context_get_sample_info_by_index(c, index, sample_info_callback, si)); + break; default: fprintf(stderr, "OTHER EVENT\n"); break; @@ -351,6 +400,7 @@ ServerInfoManager::ServerInfoManager(struct pa_context &c) : 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_operation_unref(pa_context_get_sample_info_list(&c, sample_info_callback, this)); pa_context_set_subscribe_callback(&c, subscribe_callback, this); @@ -360,7 +410,8 @@ ServerInfoManager::ServerInfoManager(struct pa_context &c) : PA_SUBSCRIPTION_MASK_MODULE| PA_SUBSCRIPTION_MASK_SINK_INPUT| PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT| - PA_SUBSCRIPTION_MASK_CLIENT), NULL, NULL)); + PA_SUBSCRIPTION_MASK_CLIENT| + PA_SUBSCRIPTION_MASK_SAMPLE_CACHE), NULL, NULL)); } @@ -383,6 +434,9 @@ ServerInfoManager::~ServerInfoManager() { for (std::map::iterator i = sourceOutputs.begin(); i != sourceOutputs.end(); i++) delete i->second; + for (std::map::iterator i = samples.begin(); i != samples.end(); i++) + delete i->second; + if (statWindow) delete statWindow; } @@ -454,6 +508,17 @@ void ServerInfoManager::updateInfo(const struct pa_source_output_info &i) { } } +void ServerInfoManager::updateInfo(const struct pa_sample_info &i) { + SampleInfo *si; + if ((si = samples[i.index])) + si->update(i); + else { + SampleInfo *n = new SampleInfo(i); + samples[i.index] = n; + mainWindow->updateInfo(*n); + } +} + void ServerInfoManager::showSinkWindow(uint32_t index) { SinkInfo *i; @@ -496,6 +561,13 @@ void ServerInfoManager::showSourceOutputWindow(uint32_t index) { i->showWindow(); } +void ServerInfoManager::showSampleWindow(uint32_t index) { + SampleInfo *i; + + if ((i = samples[index])) + i->showWindow(); +} + SourceInfo* ServerInfoManager::getSourceInfo(uint32_t index) { return sources[index]; @@ -513,6 +585,11 @@ ModuleInfo* ServerInfoManager::getModuleInfo(uint32_t index) { return modules[index]; } +SampleInfo* ServerInfoManager::getSampleInfo(uint32_t index) { + return samples[index]; +} + + void ServerInfoManager::removeSinkInfo(uint32_t index) { SinkInfo *i; @@ -569,6 +646,15 @@ void ServerInfoManager::removeSourceOutputInfo(uint32_t index) { } } +void ServerInfoManager::removeSampleInfo(uint32_t index) { + SampleInfo *i; + if ((i = samples[index])) { + samples.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)); } @@ -586,3 +672,13 @@ void ServerInfoManager::showStatWindow() { } } + +void ServerInfoManager::playSample(uint32_t sample, uint32_t sink) { + SinkInfo *sinki = getSinkInfo(sink); + SampleInfo *samplei = getSampleInfo(sample); + + if (!sinki || !samplei) + return; + + pa_operation_unref(pa_context_play_sample(&context, samplei->name.c_str(), sinki->name.c_str(), PA_VOLUME_NORM, NULL, NULL)); +} diff --git a/src/ServerInfoManager.hh b/src/ServerInfoManager.hh index d80a717..6fa8342 100644 --- a/src/ServerInfoManager.hh +++ b/src/ServerInfoManager.hh @@ -13,6 +13,7 @@ class ClientInfo; class ModuleInfo; class SinkInputInfo; class SourceOutputInfo; +class SampleInfo; #include "SinkWindow.hh" #include "SourceWindow.hh" @@ -22,6 +23,7 @@ class SourceOutputInfo; #include "SinkInputWindow.hh" #include "SourceOutputWindow.hh" #include "StatWindow.hh" +#include "SampleWindow.hh" class SinkInfo { public: @@ -40,7 +42,7 @@ public: uint32_t volume; uint32_t latency; - Gtk::TreeRowReference treeRef; + Gtk::TreeRowReference treeRef, sinkComboBoxTreeRef; SinkWindow *window; }; @@ -140,6 +142,25 @@ public: SourceOutputWindow *window; }; +class SampleInfo { +public: + + SampleInfo(const struct pa_sample_info &i); + ~SampleInfo(); + + void update(const struct pa_sample_info &i); + void showWindow(); + + uint32_t index; + Glib::ustring name; + struct pa_sample_spec sample_spec; + uint32_t volume, duration; + + Gtk::TreeRowReference treeRef; + + SampleWindow *window; +}; + class ServerInfoManager { public: ServerInfoManager(struct pa_context &c); @@ -151,6 +172,7 @@ public: 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 updateInfo(const struct pa_sample_info &i); void showSinkWindow(uint32_t index); void showSourceWindow(uint32_t index); @@ -158,11 +180,13 @@ public: void showModuleWindow(uint32_t index); void showSinkInputWindow(uint32_t index); void showSourceOutputWindow(uint32_t index); + void showSampleWindow(uint32_t index); SourceInfo* getSourceInfo(uint32_t index); SinkInfo* getSinkInfo(uint32_t index); ClientInfo* getClientInfo(uint32_t index); ModuleInfo* getModuleInfo(uint32_t index); + SampleInfo* getSampleInfo(uint32_t index); void removeSinkInfo(uint32_t index); void removeSourceInfo(uint32_t index); @@ -170,11 +194,14 @@ public: void removeModuleInfo(uint32_t index); void removeSinkInputInfo(uint32_t index); void removeSourceOutputInfo(uint32_t index); + void removeSampleInfo(uint32_t index); void setSinkVolume(uint32_t index, uint32_t volume); void setSinkInputVolume(uint32_t index, uint32_t volume); void showStatWindow(); + + void playSample(uint32_t sample, uint32_t sink); protected: std::map sinks; @@ -183,6 +210,7 @@ protected: std::map modules; std::map sinkInputs; std::map sourceOutputs; + std::map samples; struct pa_context &context; StatWindow *statWindow; diff --git a/src/paman.glade b/src/paman.glade index 18b6bae..f454f57 100644 --- a/src/paman.glade +++ b/src/paman.glade @@ -1288,9 +1288,7 @@ True - foo -bar -waldo + 0 @@ -1313,7 +1311,7 @@ waldo 0 - + True True True @@ -1540,7 +1538,7 @@ waldo True False - 12 + 6 @@ -2141,7 +2139,7 @@ waldo True False - 11 + 6 @@ -2582,7 +2580,7 @@ waldo 12 True False - 12 + 6 @@ -2922,7 +2920,7 @@ waldo 12 True False - 12 + 6 @@ -3252,7 +3250,7 @@ waldo 12 True False - 12 + 6 @@ -3871,7 +3869,7 @@ waldo 12 True False - 12 + 6 @@ -4317,7 +4315,7 @@ waldo True False False - GDK_WINDOW_TYPE_HINT_NORMAL + GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST @@ -4647,4 +4645,349 @@ waldo + + Sample + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + + + + 12 + True + False + 6 + + + + True + True + True + True + GTK_POS_TOP + False + False + + + + 12 + True + 5 + 2 + False + 6 + 11 + + + + True + <b>Name:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + <b>Sample Type:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + <b>Duration:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + True + label4811 + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 3 + 4 + fill + + + + + + + True + True + label4812 + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + True + label4814 + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 2 + 3 + fill + + + + + + + True + <b>Default Volume:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + <b>Index:</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 1 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + True + label4816 + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 1 + 2 + fill + + + + + + + True + True + label4813 + False + False + GTK_JUSTIFY_LEFT + False + True + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 4 + 5 + fill + + + + + + False + True + + + + + + True + <b>Basic</b> + False + True + 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