From 75f8b2249cad94708ddb5bfff7361ea996d0c82b Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 16 Feb 2006 13:00:42 +0000 Subject: Update to the new polypaudio API. git-svn-id: file:///home/lennart/svn/public/paman/trunk@47 cdefa82f-4ce1-0310-97f5-ab6066f37c3c --- src/ClientWindow.cc | 6 +++--- src/ClientWindow.hh | 2 +- src/SampleWindow.cc | 2 +- src/ServerInfoManager.cc | 38 ++++++++++++++++++++++---------------- src/ServerInfoManager.hh | 26 +++++++++++--------------- src/SinkInputWindow.cc | 7 ++++--- src/SinkWindow.cc | 7 ++++--- src/paman.cc | 4 +--- src/paman.glade | 4 ++-- 9 files changed, 49 insertions(+), 47 deletions(-) diff --git a/src/ClientWindow.cc b/src/ClientWindow.cc index 014095b..5a1221a 100644 --- a/src/ClientWindow.cc +++ b/src/ClientWindow.cc @@ -8,7 +8,7 @@ ClientWindow::ClientWindow(BaseObjectType* cobject, const Glib::RefPtr& refGlade) : Gtk::Window(cobject), nameLabel(NULL), - typeidLabel(NULL), + driverLabel(NULL), indexLabel(NULL), ownerModuleLabel(NULL), closeButton(NULL), @@ -16,7 +16,7 @@ ClientWindow::ClientWindow(BaseObjectType* cobject, const Glib::RefPtrget_widget("nameLabel", nameLabel); - refGlade->get_widget("typeidLabel", typeidLabel); + refGlade->get_widget("driverLabel", driverLabel); refGlade->get_widget("indexLabel", indexLabel); refGlade->get_widget("ownerModuleLabel", ownerModuleLabel); refGlade->get_widget("closeButton", closeButton); @@ -40,7 +40,7 @@ void ClientWindow::updateInfo(const ClientInfo &i) { nameLabel->set_text(i.name); - typeidLabel->set_text(pa_typeid_to_string(i._typeid, t, sizeof(t))); + driverLabel->set_text(i.driver); snprintf(t, sizeof(t), "#%u", i.index); indexLabel->set_text(t); diff --git a/src/ClientWindow.hh b/src/ClientWindow.hh index 74bd601..c354a7c 100644 --- a/src/ClientWindow.hh +++ b/src/ClientWindow.hh @@ -14,7 +14,7 @@ public: static ClientWindow* create(); Gtk::Label *nameLabel, - *typeidLabel, + *driverLabel, *indexLabel, *ownerModuleLabel; diff --git a/src/SampleWindow.cc b/src/SampleWindow.cc index 81ddaa0..29998c5 100644 --- a/src/SampleWindow.cc +++ b/src/SampleWindow.cc @@ -44,7 +44,7 @@ void SampleWindow::updateInfo(const SampleInfo &i) { snprintf(t, sizeof(t), "#%u", i.index); indexLabel->set_text(t); - snprintf(t, sizeof(t), "%0.0f%%", (double) i.volume / 0x100 * 100); + snprintf(t, sizeof(t), "%0.0f%%", (double) pa_sw_volume_to_linear(pa_cvolume_avg(&i.volume)) * 100); volumeLabel->set_text(t); if (pa_sample_spec_valid(&i.sample_spec)) { diff --git a/src/ServerInfoManager.cc b/src/ServerInfoManager.cc index 44e668f..5f285b9 100644 --- a/src/ServerInfoManager.cc +++ b/src/ServerInfoManager.cc @@ -5,6 +5,7 @@ #include "paman.hh" SinkInfo::SinkInfo(const struct pa_sink_info &i) : + driver(i.driver), name(i.name), index(i.index), sample_spec(i.sample_spec), @@ -13,7 +14,6 @@ SinkInfo::SinkInfo(const struct pa_sink_info &i) : volume(i.volume), latency(i.latency), monitor_source_name(i.monitor_source_name), - _typeid(i._typeid), window(NULL) { if (i.description) @@ -26,6 +26,7 @@ SinkInfo::~SinkInfo() { } void SinkInfo::update(const struct pa_sink_info &i) { + driver = Glib::ustring(i.driver); name = Glib::ustring(i.name); index = i.index; sample_spec = i.sample_spec; @@ -34,7 +35,6 @@ void SinkInfo::update(const struct pa_sink_info &i) { volume = i.volume; latency = i.latency; monitor_source_name = i.monitor_source_name; - _typeid = i._typeid; description = i.description ? i.description : ""; @@ -55,13 +55,13 @@ void SinkInfo::showWindow() { } SourceInfo::SourceInfo(const struct pa_source_info &i) : + driver(i.driver), name(i.name), index(i.index), sample_spec(i.sample_spec), owner_module(i.owner_module), monitor_of_sink(i.monitor_of_sink), latency(i.latency), - _typeid(i._typeid), window(NULL) { if (i.description) @@ -74,13 +74,13 @@ SourceInfo::~SourceInfo() { } void SourceInfo::update(const struct pa_source_info &i) { + driver = i.driver; name = i.name; index = i.index; sample_spec = i.sample_spec; owner_module = i.owner_module; monitor_of_sink = i.monitor_of_sink; latency = i.latency; - _typeid = i._typeid; description = i.description ? i.description : ""; @@ -102,9 +102,9 @@ void SourceInfo::showWindow() { ClientInfo::ClientInfo(const struct pa_client_info &i) : index(i.index), + driver(i.driver), name(i.name), owner_module(i.owner_module), - _typeid(i._typeid), window(NULL) { } @@ -114,10 +114,10 @@ ClientInfo::~ClientInfo() { } void ClientInfo::update(const struct pa_client_info &i) { + driver = i.driver; name = i.name; index = i.index; owner_module = i.owner_module; - _typeid = i._typeid; if (window) window->updateInfo(*this); @@ -177,6 +177,7 @@ void ModuleInfo::showWindow() { } SinkInputInfo::SinkInputInfo(const struct pa_sink_input_info &i) : + driver(i.driver), name(i.name), index(i.index), sample_spec(i.sample_spec), @@ -187,7 +188,6 @@ SinkInputInfo::SinkInputInfo(const struct pa_sink_input_info &i) : buffer_usec(i.buffer_usec), sink_usec(i.sink_usec), resample_method(i.resample_method ? i.resample_method : "n/a"), - _typeid(i._typeid), window(NULL) { } @@ -197,6 +197,7 @@ SinkInputInfo::~SinkInputInfo() { } void SinkInputInfo::update(const struct pa_sink_input_info &i) { + driver = i.driver; name = i.name; index = i.index; sample_spec = i.sample_spec; @@ -206,7 +207,6 @@ void SinkInputInfo::update(const struct pa_sink_input_info &i) { volume = i.volume; buffer_usec = i.buffer_usec; sink_usec = i.sink_usec; - _typeid = i._typeid; resample_method = i.resample_method ? i.resample_method : "n/a"; if (window) @@ -226,6 +226,7 @@ void SinkInputInfo::showWindow() { } SourceOutputInfo::SourceOutputInfo(const struct pa_source_output_info &i) : + driver(i.driver), name(i.name), index(i.index), sample_spec(i.sample_spec), @@ -235,7 +236,6 @@ SourceOutputInfo::SourceOutputInfo(const struct pa_source_output_info &i) : buffer_usec(i.buffer_usec), source_usec(i.source_usec), resample_method(i.resample_method ? i.resample_method : "n/a"), - _typeid(i._typeid), window(NULL) { } @@ -245,6 +245,7 @@ SourceOutputInfo::~SourceOutputInfo() { } void SourceOutputInfo::update(const struct pa_source_output_info &i) { + driver = i.driver; name = i.name; index = i.index; sample_spec = i.sample_spec; @@ -253,7 +254,6 @@ void SourceOutputInfo::update(const struct pa_source_output_info &i) { owner_module = i.owner_module; buffer_usec = i.buffer_usec; source_usec = i.source_usec; - _typeid = i._typeid; resample_method = i.resample_method ? i.resample_method : "n/a"; if (window) @@ -276,9 +276,9 @@ 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), bytes(i.bytes), + volume(i.volume), lazy(!!i.lazy), filename_valid(false), window(NULL) { @@ -298,9 +298,9 @@ 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; bytes = i.bytes; + volume = i.volume; lazy = !!i.lazy; filename_valid = !!i.filename; @@ -704,12 +704,18 @@ void ServerInfoManager::removeSampleInfo(uint32_t index) { } } -void ServerInfoManager::setSinkVolume(uint32_t index, uint32_t volume) { - pa_operation_unref(pa_context_set_sink_volume_by_index(&context, index, volume, NULL, NULL)); +/* FIXME: Handle all channels separately. */ +void ServerInfoManager::setSinkVolume(uint32_t index, pa_volume_t volume) { + pa_cvolume cvol; + pa_cvolume_set(&cvol, sinks[index]->volume.channels, volume); + pa_operation_unref(pa_context_set_sink_volume_by_index(&context, index, &cvol, 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)); +/* FIXME: Handle all channels separately. */ +void ServerInfoManager::setSinkInputVolume(uint32_t index, pa_volume_t volume) { + pa_cvolume cvol; + pa_cvolume_set(&cvol, sinkInputs[index]->volume.channels, volume); + pa_operation_unref(pa_context_set_sink_input_volume(&context, index, &cvol, NULL, NULL)); } void ServerInfoManager::showStatWindow() { diff --git a/src/ServerInfoManager.hh b/src/ServerInfoManager.hh index df9f37a..fb6bacf 100644 --- a/src/ServerInfoManager.hh +++ b/src/ServerInfoManager.hh @@ -34,15 +34,14 @@ public: void update(const struct pa_sink_info &i); void showWindow(); - Glib::ustring name, description; + Glib::ustring driver, name, description; uint32_t index; struct pa_sample_spec sample_spec; uint32_t monitor_source; uint32_t owner_module; - pa_volume_t volume; + pa_cvolume volume; pa_usec_t latency; Glib::ustring monitor_source_name; - pa_typeid_t _typeid; Gtk::TreeRowReference treeRef, sinkComboBoxTreeRef; @@ -57,13 +56,12 @@ public: void update(const struct pa_source_info &i); void showWindow(); - Glib::ustring name, description; + Glib::ustring driver, name, description; uint32_t index; struct pa_sample_spec sample_spec; uint32_t owner_module; uint32_t monitor_of_sink; pa_usec_t latency; - pa_typeid_t _typeid; Gtk::TreeRowReference treeRef; SourceWindow *window; @@ -95,9 +93,8 @@ public: void showWindow(); uint32_t index; - Glib::ustring name; + Glib::ustring driver, name; uint32_t owner_module; - pa_typeid_t _typeid; Gtk::TreeRowReference treeRef; ClientWindow *window; @@ -112,16 +109,15 @@ public: void update(const struct pa_sink_input_info &i); void showWindow(); - Glib::ustring name; + Glib::ustring driver, name; uint32_t index; struct pa_sample_spec sample_spec; uint32_t sink; uint32_t client; uint32_t owner_module; - pa_volume_t volume; + pa_cvolume volume; pa_usec_t buffer_usec, sink_usec; Glib::ustring resample_method; - pa_typeid_t _typeid; Gtk::TreeRowReference treeRef; @@ -137,7 +133,7 @@ public: void update(const struct pa_source_output_info &i); void showWindow(); - Glib::ustring name; + Glib::ustring driver, name; uint32_t index; struct pa_sample_spec sample_spec; uint32_t source; @@ -145,7 +141,6 @@ public: uint32_t owner_module; pa_usec_t buffer_usec, source_usec; Glib::ustring resample_method; - pa_typeid_t _typeid; Gtk::TreeRowReference treeRef; @@ -164,7 +159,8 @@ public: uint32_t index; Glib::ustring name; struct pa_sample_spec sample_spec; - uint32_t volume, duration, bytes; + uint32_t duration, bytes; + pa_cvolume volume; bool lazy; Glib::ustring filename; @@ -210,8 +206,8 @@ public: 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 setSinkVolume(uint32_t index, pa_volume_t volume); + void setSinkInputVolume(uint32_t index, pa_volume_t volume); void showStatWindow(); diff --git a/src/SinkInputWindow.cc b/src/SinkInputWindow.cc index 784cb90..09d5433 100644 --- a/src/SinkInputWindow.cc +++ b/src/SinkInputWindow.cc @@ -91,8 +91,9 @@ void SinkInputWindow::updateInfo(const SinkInputInfo &i) { clientLabel->set_text(client->name); } - percent = pa_volume_to_user(i.volume) * 100; - db = pa_volume_to_dB(i.volume); + percent = pa_sw_volume_to_linear(pa_cvolume_avg(&i.volume)) * 100; + /* FIXME: Hardware volume doesn't translate well to dB. */ + db = pa_sw_volume_to_dB(pa_cvolume_avg(&i.volume)); scaleEnabled = false; volumeScale->set_value(percent); scaleEnabled = true; @@ -134,7 +135,7 @@ void SinkInputWindow::onToClientButton() { void SinkInputWindow::onVolumeScaleValueChanged() { if (scaleEnabled) - serverInfoManager->setSinkInputVolume(index, pa_volume_from_user(volumeScale->get_value()/100)); + serverInfoManager->setSinkInputVolume(index, pa_sw_volume_from_linear(volumeScale->get_value()/100)); } void SinkInputWindow::onVolumeResetButton() { diff --git a/src/SinkWindow.cc b/src/SinkWindow.cc index bcf1681..ed21820 100644 --- a/src/SinkWindow.cc +++ b/src/SinkWindow.cc @@ -75,8 +75,9 @@ void SinkWindow::updateInfo(const SinkInfo &i) { SourceInfo *source = serverInfoManager->getSourceInfo(i.monitor_source); monitorSourceLabel->set_text(source->name); - percent = pa_volume_to_user(i.volume) * 100; - db = pa_volume_to_dB(i.volume); + percent = pa_sw_volume_to_linear(pa_cvolume_avg(&i.volume)) * 100; + /* FIXME: Hardware volume doesn't translate well to dB. */ + db = pa_sw_volume_to_dB(pa_cvolume_avg(&i.volume)); scaleEnabled = false; volumeScale->set_value(percent); scaleEnabled = true; @@ -111,7 +112,7 @@ void SinkWindow::onToOwnerModuleButton() { void SinkWindow::onVolumeScaleValueChanged() { if (scaleEnabled) - serverInfoManager->setSinkVolume(index, pa_volume_from_user(volumeScale->get_value()/100)); + serverInfoManager->setSinkVolume(index, pa_sw_volume_from_linear(volumeScale->get_value()/100)); } void SinkWindow::onVolumeResetButton() { diff --git a/src/paman.cc b/src/paman.cc index de397c1..07eb06a 100644 --- a/src/paman.cc +++ b/src/paman.cc @@ -16,11 +16,9 @@ ServerInfoManager *serverInfoManager = NULL; struct pa_context *context = NULL; struct pa_mainloop_api *mainloop_api = NULL; -extern "C" static void context_state_callback(struct pa_context *c, void *userdata); - #define WINDOW_TITLE "Polypaudio Manager" -static void context_state_callback(struct pa_context *c, void *) { +extern "C" static void context_state_callback(struct pa_context *c, void *) { g_assert(c && mainWindow); switch (pa_context_get_state(c)) { diff --git a/src/paman.glade b/src/paman.glade index 7c8ed5b..98e390a 100644 --- a/src/paman.glade +++ b/src/paman.glade @@ -3323,7 +3323,7 @@ - + True foo False @@ -3373,7 +3373,7 @@ True - <b>Type ID:</b> + <b>Driver:</b> False True GTK_JUSTIFY_LEFT -- cgit