[pulseaudio-commits] 2 commits - src/cardwidget.h src/mainwindow.cc

Tanu Kaskinen tanuk at kemper.freedesktop.org
Sat Nov 24 06:39:55 PST 2012


 src/cardwidget.h  |    1 
 src/mainwindow.cc |   67 +++++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 58 insertions(+), 10 deletions(-)

New commits:
commit cc06ae90299a5535a0d00564256722750f077e0b
Author: Tanu Kaskinen <tanuk at iki.fi>
Date:   Sat Nov 24 16:39:05 2012 +0200

    mainwindow: Fix iterator dereferencing style.

diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 5170b45..be6fb93 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -263,7 +263,7 @@ static void updatePorts(DeviceWidget *w, std::map<Glib::ustring, PortInfo> &port
         if (it == ports.end())
             continue;
 
-        p = (*it).second;
+        p = it->second;
         desc = p.description;
 
         if (p.available == PA_PORT_AVAILABLE_YES)
@@ -282,7 +282,7 @@ static void updatePorts(DeviceWidget *w, std::map<Glib::ustring, PortInfo> &port
     it = ports.find(w->activePort);
 
     if (it != ports.end()) {
-        p = (*it).second;
+        p = it->second;
         w->setLatencyOffset(p.latency_offset);
     }
 }
@@ -342,7 +342,7 @@ void MainWindow::updateCard(const pa_card_info &info) {
         Glib::ustring desc = profileIt->description;
 
         for (portIt = w->ports.begin(); portIt != w->ports.end(); portIt++) {
-            PortInfo port = (*portIt).second;
+            PortInfo port = portIt->second;
 
             if (std::find(port.profiles.begin(), port.profiles.end(), profileIt->name) == port.profiles.end())
                 continue;
@@ -369,7 +369,7 @@ void MainWindow::updateCard(const pa_card_info &info) {
         std::map<uint32_t, SinkWidget*>::iterator it;
 
         for (it = sinkWidgets.begin() ; it != sinkWidgets.end(); it++) {
-            SinkWidget *sw = (*it).second;
+            SinkWidget *sw = it->second;
 
             if (sw->card_index == w->index) {
                 sw->updating = true;
@@ -383,7 +383,7 @@ void MainWindow::updateCard(const pa_card_info &info) {
         std::map<uint32_t, SourceWidget*>::iterator it;
 
         for (it = sourceWidgets.begin() ; it != sourceWidgets.end(); it++) {
-            SourceWidget *sw = (*it).second;
+            SourceWidget *sw = it->second;
 
             if (sw->card_index == w->index) {
                 sw->updating = true;

commit 1bff6399d636b016b5c60fba33113d3b3eac9e6e
Author: poljar (Damir Jelić) <poljarinho at gmail.com>
Date:   Fri Nov 16 00:12:58 2012 +0100

    mainwindow: Show the availability of the ports and profiles.
    
    If we know if a certain port is available/unavailable, we can print
    that out, as a help to the user (and as debugging for ourselves).
    A profile is also available/unavailable if all ports which have that
    profile are available/unavailable.
    
    Credit goes to David Henningson for the original idea and some of the code.

diff --git a/src/cardwidget.h b/src/cardwidget.h
index 7c63681..821aae5 100644
--- a/src/cardwidget.h
+++ b/src/cardwidget.h
@@ -31,6 +31,7 @@ public:
       int available;
       int direction;
       int64_t latency_offset;
+      std::vector<Glib::ustring> profiles;
 };
 
 class CardWidget : public Gtk::VBox {
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 720a4db..5170b45 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -254,12 +254,36 @@ static void set_icon_name_fallback(Gtk::Image *i, const char *name, Gtk::IconSiz
 
 static void updatePorts(DeviceWidget *w, std::map<Glib::ustring, PortInfo> &ports) {
     std::map<Glib::ustring, PortInfo>::iterator it;
+    PortInfo p;
+
+    for (uint32_t i = 0; i < w->ports.size(); i++) {
+        Glib::ustring desc;
+        it = ports.find(w->ports[i].first);
+
+        if (it == ports.end())
+            continue;
+
+        p = (*it).second;
+        desc = p.description;
+
+        if (p.available == PA_PORT_AVAILABLE_YES)
+            desc +=  _(" (plugged in)");
+        else if (p.available == PA_PORT_AVAILABLE_NO) {
+            if (p.name == "analog-output-speaker" ||
+                p.name == "analog-input-microphone-internal")
+                desc += _(" (unavailable)");
+            else
+                desc += _(" (unplugged)");
+        }
+
+        w->ports[i].second = desc;
+    }
 
     it = ports.find(w->activePort);
 
     if (it != ports.end()) {
-        PortInfo &activePort = it->second;
-        w->setLatencyOffset(activePort.latency_offset);
+        p = (*it).second;
+        w->setLatencyOffset(p.latency_offset);
     }
 }
 
@@ -295,12 +319,6 @@ void MainWindow::updateCard(const pa_card_info &info) {
         profile_priorities.insert(info.profiles[i]);
     }
 
-    w->profiles.clear();
-    for (std::set<pa_card_profile_info>::iterator i = profile_priorities.begin(); i != profile_priorities.end(); ++i)
-        w->profiles.push_back(std::pair<Glib::ustring,Glib::ustring>(i->name, i->description));
-
-    w->activeProfile = info.active_profile ? info.active_profile->name : "";
-
     w->ports.clear();
     for (uint32_t i = 0; i < info.n_ports; ++i) {
         PortInfo p;
@@ -311,10 +329,39 @@ void MainWindow::updateCard(const pa_card_info &info) {
         p.available = info.ports[i]->available;
         p.direction = info.ports[i]->direction;
         p.latency_offset = info.ports[i]->latency_offset;
+        for (uint32_t j = 0; j < info.ports[i]->n_profiles; j++)
+            p.profiles.push_back(info.ports[i]->profiles[j]->name);
 
         w->ports[p.name] = p;
     }
 
+    w->profiles.clear();
+    for (std::set<pa_card_profile_info>::iterator profileIt = profile_priorities.begin(); profileIt != profile_priorities.end(); ++profileIt) {
+        bool hasNo = false, hasOther = false;
+        std::map<Glib::ustring, PortInfo>::iterator portIt;
+        Glib::ustring desc = profileIt->description;
+
+        for (portIt = w->ports.begin(); portIt != w->ports.end(); portIt++) {
+            PortInfo port = (*portIt).second;
+
+            if (std::find(port.profiles.begin(), port.profiles.end(), profileIt->name) == port.profiles.end())
+                continue;
+
+            if (port.available == PA_PORT_AVAILABLE_NO)
+                hasNo = true;
+            else {
+                hasOther = true;
+                break;
+            }
+        }
+        if (hasNo && !hasOther)
+            desc += _(" (unplugged)");
+
+        w->profiles.push_back(std::pair<Glib::ustring,Glib::ustring>(profileIt->name, desc));
+    }
+
+    w->activeProfile = info.active_profile ? info.active_profile->name : "";
+
     /* Because the port info for sinks and sources is discontinued we need
      * to update the port info for them here. */
 



More information about the pulseaudio-commits mailing list