> > Having an object model that properly links ports to both cards and > sinks/sources would very likely be useful in the future also. Actually, > poljar has had the same problem with his latency offset feature. I don't > know if he already has a solution that you could re-use... > I added a port class to the cardwidget. I don't know if we need the proplists or the profile list so suggestions are welcome. Note: this does nothing visible for now. Patch attached. -------------- next part -------------- >From 8c36669e9883a96ba77353f62c7539ccf6419ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?"poljar=20(Damir=20Jeli=C4=87)"?= <poljarinho@xxxxxxxxx> Date: Sat, 21 Jul 2012 13:43:54 +0200 Subject: [PATCH] cardwidget: Add a port class The cardwidget should cache all the relevant data for the ports. This change introduces a new port class which holds the port info for the card. --- src/cardwidget.h | 11 +++++++++++ src/mainwindow.cc | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/cardwidget.h b/src/cardwidget.h index 3837d5b..7c63681 100644 --- a/src/cardwidget.h +++ b/src/cardwidget.h @@ -23,6 +23,16 @@ #include "pavucontrol.h" +class PortInfo { +public: + Glib::ustring name; + Glib::ustring description; + uint32_t priority; + int available; + int direction; + int64_t latency_offset; +}; + class CardWidget : public Gtk::VBox { public: CardWidget(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& x); @@ -36,6 +46,7 @@ public: bool updating; std::vector< std::pair<Glib::ustring,Glib::ustring> > profiles; + std::map<Glib::ustring, PortInfo> ports; Glib::ustring activeProfile; bool hasSinks; bool hasSources; diff --git a/src/mainwindow.cc b/src/mainwindow.cc index dc84682..6a4094c 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -290,6 +290,24 @@ void MainWindow::updateCard(const pa_card_info &info) { w->activeProfile = info.active_profile ? info.active_profile->name : ""; + if (pa_context_get_server_protocol_version(get_context()) >= 26) { + for (uint32_t i = 0; i < info.n_ports; ++i) { + PortInfo p; + + p.name = info.ports[i]->name; + p.description = info.ports[i]->description; + p.priority = info.ports[i]->priority; + p.available = info.ports[i]->available; + p.direction = info.ports[i]->direction; + + if (pa_context_get_server_protocol_version(get_context()) >= 27) + p.latency_offset = info.ports[i]->latency_offset; + else p.latency_offset = 0; + + w->ports[p.name] = p; + } + } + w->updating = false; w->prepareMenu(); -- 1.7.11.2