diff options
Diffstat (limited to 'src/helper.cc')
-rw-r--r-- | src/helper.cc | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/src/helper.cc b/src/helper.cc deleted file mode 100644 index fac1bb9..0000000 --- a/src/helper.cc +++ /dev/null @@ -1,75 +0,0 @@ -#include "helper.h" - -#include "mainwindow.h" -#include <QDebug> - -void populatePorts(const pa_card_info &info, std::map<QByteArray, PortInfo> &ports) -{ - ports.clear(); - 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; - p.latency_offset = info.ports[i]->latency_offset; - for (pa_card_profile_info2 ** p_profile = info.ports[i]->profiles2; p_profile && *p_profile != nullptr; ++p_profile) - p.profiles.push_back((*p_profile)->name); - - ports[p.name] = p; - } -} - -void groupProfiles(const std::set<pa_card_profile_info2 *, profile_prio_compare> &profile_priorities, - const std::map<QByteArray, PortInfo> &ports, - QMap<QString, ProfileGroup> &profiles) -{ - profiles.clear(); - for (auto p_profile : profile_priorities) { - bool hasNo = false, hasOther = false; - std::map<QByteArray, PortInfo>::const_iterator portIt; - QByteArray desc = p_profile->description; - - for (portIt = ports.begin(); portIt != ports.end(); portIt++) { - PortInfo port = portIt->second; - - if (std::find(port.profiles.begin(), port.profiles.end(), p_profile->name) == port.profiles.end()) - continue; - - if (port.available == PA_PORT_AVAILABLE_NO) - hasNo = true; - else { - hasOther = true; - break; - } - } - if (hasNo && !hasOther) - desc += MainWindow::tr(" (unplugged)").toUtf8().constData(); - - if (!p_profile->available) - desc += MainWindow::tr(" (unavailable)").toUtf8().constData(); - - QString parseId = QString::fromUtf8(p_profile->name); - int plus = parseId.indexOf(QLatin1Char('+')); - if (plus != -1) { - parseId = parseId.left(plus); - } - auto list = parseId.split(QRegularExpression(QLatin1String("[:\\-]"))); - parseId.clear(); - for (auto p : list) { - if (p == QLatin1String("input") || p == QLatin1String("output")) - continue; - if (parseId.isEmpty() || p.startsWith(QLatin1String("extra"))) { - parseId.append(p); - } - } - //qDebug() << "ParseID:" << parseId; - ProfileGroup &group = profiles[parseId]; - if (p_profile->available) { - group.available = true; - } - group.addEntry(p_profile->name, desc.constData()); - } -} |