summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-08-19 21:54:11 +0000
committerLennart Poettering <lennart@poettering.net>2004-08-19 21:54:11 +0000
commit33b0d86c66158b9aa0e1ab7b4b1c689fd83ab5ac (patch)
tree507283ce15b901dc31a372c0e9c0c1325f66ab2c /src
parent72f6cf7ca0d0baaef7fb0171e0d14cce50d1ef04 (diff)
sample cache stuff
git-svn-id: file:///home/lennart/svn/public/paman/trunk@16 cdefa82f-4ce1-0310-97f5-ab6066f37c3c
Diffstat (limited to 'src')
-rw-r--r--src/MainWindow.cc127
-rw-r--r--src/MainWindow.hh41
-rw-r--r--src/Makefile.am3
-rw-r--r--src/SampleWindow.cc55
-rw-r--r--src/SampleWindow.hh29
-rw-r--r--src/ServerInfoManager.cc98
-rw-r--r--src/ServerInfoManager.hh30
-rw-r--r--src/paman.glade365
8 files changed, 726 insertions, 22 deletions
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::RefPtr<Gnome::Glade:
deviceOpenButton(NULL),
clientOpenButton(NULL),
moduleOpenButton(NULL),
+ sampleOpenButton(NULL),
+ samplePlayButton(NULL),
connectButton(NULL),
disconnectButton(NULL),
statButton(NULL),
deviceTreeView(NULL),
clientTreeView(NULL),
moduleTreeView(NULL),
- titleEventBox(NULL) {
+ sampleTreeView(NULL),
+ titleEventBox(NULL),
+ sinkComboBox(NULL) {
refGlade->get_widget("statusLabel", statusLabel);
refGlade->get_widget("serverNameLabel", serverNameLabel);
@@ -48,15 +52,19 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade:
refGlade->get_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::RefPtr<Gnome::Glade:
moduleTreeView->append_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("<i>n/a</i>");
serverVersionLabel->set_markup("<i>n/a</i>");
@@ -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<Gtk::TreeStore> moduleTreeStore;
+ class SampleTreeModelColumns : public Gtk::TreeModel::ColumnRecord {
+ public:
+ SampleTreeModelColumns() {
+ add(name);
+ add(index);
+ }
+
+ Gtk::TreeModelColumn<Glib::ustring> name;
+ Gtk::TreeModelColumn<uint32_t> index;
+ };
+
+ SampleTreeModelColumns sampleTreeModelColumns;
+ Glib::RefPtr<Gtk::TreeStore> sampleTreeStore;
+
+ class SinkTreeModelColumns : public Gtk::TreeModel::ColumnRecord {
+ public:
+ SinkTreeModelColumns() {
+ add(name);
+ add(index);
+ }
+
+ Gtk::TreeModelColumn<Glib::ustring> name;
+ Gtk::TreeModelColumn<uint32_t> index;
+ };
+
+ SinkTreeModelColumns sinkTreeModelColumns;
+ Glib::RefPtr<Gtk::ListStore> 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 <iostream>
+
+#include "paman.hh"
+#include "SampleWindow.hh"
+
+#define GLADE_NAME "sampleWindow"
+
+SampleWindow::SampleWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& 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<Gnome::Glade::Xml> 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 <gtkmm.h>
+#include <libglademm.h>
+
+class SampleWindow;
+
+#include "ServerInfoManager.hh"
+
+class SampleWindow : public Gtk::Window {
+public:
+ SampleWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& 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<int, SourceOutputInfo*>::iterator i = sourceOutputs.begin(); i != sourceOutputs.end(); i++)
delete i->second;
+ for (std::map<int, SampleInfo*>::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<int, SinkInfo*> sinks;
@@ -183,6 +210,7 @@ protected:
std::map<int, ModuleInfo*> modules;
std::map<int, SinkInputInfo*> sinkInputs;
std::map<int, SourceOutputInfo*> sourceOutputs;
+ std::map<int, SampleInfo*> 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 @@
<child>
<widget class="GtkComboBox" id="sinkComboBox">
<property name="visible">True</property>
- <property name="items" translatable="yes">foo
-bar
-waldo</property>
+ <property name="items" translatable="yes"></property>
</widget>
<packing>
<property name="padding">0</property>
@@ -1313,7 +1311,7 @@ waldo</property>
<property name="spacing">0</property>
<child>
- <widget class="GtkButton" id="playButton">
+ <widget class="GtkButton" id="sampleCachePlayButton">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
@@ -1540,7 +1538,7 @@ waldo</property>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
- <property name="spacing">12</property>
+ <property name="spacing">6</property>
<child>
<widget class="GtkNotebook" id="notebook2">
@@ -2141,7 +2139,7 @@ waldo</property>
<widget class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="homogeneous">False</property>
- <property name="spacing">11</property>
+ <property name="spacing">6</property>
<child>
<widget class="GtkNotebook" id="notebook3">
@@ -2582,7 +2580,7 @@ waldo</property>
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
- <property name="spacing">12</property>
+ <property name="spacing">6</property>
<child>
<widget class="GtkNotebook" id="notebook4">
@@ -2922,7 +2920,7 @@ waldo</property>
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
- <property name="spacing">12</property>
+ <property name="spacing">6</property>
<child>
<widget class="GtkNotebook" id="notebook5">
@@ -3252,7 +3250,7 @@ waldo</property>
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
- <property name="spacing">12</property>
+ <property name="spacing">6</property>
<child>
<widget class="GtkNotebook" id="notebook6">
@@ -3871,7 +3869,7 @@ waldo</property>
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
- <property name="spacing">12</property>
+ <property name="spacing">6</property>
<child>
<widget class="GtkNotebook" id="notebook7">
@@ -4317,7 +4315,7 @@ waldo</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
- <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<child>
@@ -4647,4 +4645,349 @@ waldo</property>
</child>
</widget>
+<widget class="GtkWindow" id="sampleWindow">
+ <property name="title" translatable="yes">Sample</property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">False</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+
+ <child>
+ <widget class="GtkVBox" id="vbox21">
+ <property name="border_width">12</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">6</property>
+
+ <child>
+ <widget class="GtkNotebook" id="notebook8">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="show_tabs">True</property>
+ <property name="show_border">True</property>
+ <property name="tab_pos">GTK_POS_TOP</property>
+ <property name="scrollable">False</property>
+ <property name="enable_popup">False</property>
+
+ <child>
+ <widget class="GtkTable" id="table10">
+ <property name="border_width">12</property>
+ <property name="visible">True</property>
+ <property name="n_rows">5</property>
+ <property name="n_columns">2</property>
+ <property name="homogeneous">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">11</property>
+
+ <child>
+ <widget class="GtkLabel" id="label4807">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">&lt;b&gt;Name:&lt;/b&gt;</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">1</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label4809">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">&lt;b&gt;Sample Type:&lt;/b&gt;</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">1</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label4810">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">&lt;b&gt;Duration:&lt;/b&gt;</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">1</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="durationLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">label4811</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="nameLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">label4812</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="sampleTypeLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">label4814</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label4808">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">&lt;b&gt;Default Volume:&lt;/b&gt;</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">1</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label4815">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">&lt;b&gt;Index:&lt;/b&gt;</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">1</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="indexLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">label4816</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="volumeLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label" translatable="yes">label4813</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="tab_expand">False</property>
+ <property name="tab_fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label4806">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">&lt;b&gt;Basic&lt;/b&gt;</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHButtonBox" id="hbuttonbox19">
+ <property name="visible">True</property>
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkButton" id="closeButton">
+ <property name="visible">True</property>
+ <property name="can_default">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-close</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
</glade-interface>