summaryrefslogtreecommitdiffstats
path: root/src/helper.h
blob: 823f3e1486c1012eced83e491c209caaa9c1639c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef _HELPER_H_
#define _HELPER_H_

#include "pavucontrol.h"
#include <pulse/ext-stream-restore.h>
#if HAVE_EXT_DEVICE_RESTORE_API
#  include <pulse/ext-device-restore.h>
#endif

#include <set>
#include <map>
#include <QByteArray>
#include <QMap>
#include <vector>

struct ProfileEntry {
      QByteArray id;
      QStringList tokens;
      QString getName() const;
};

struct ProfileGroup {
     ProfileGroup() : available(false) {}
      bool available;
      QString name;
      QList<ProfileEntry> entries;
      QString getProfileName();
      void addEntry(const char* id, const char* name);
      bool containsProfile(const QByteArray &pro) const;
};

struct PortInfo {
      QByteArray name;
      QByteArray description;
      uint32_t priority;
      int available;
      int direction;
      int64_t latency_offset;
      std::vector<QByteArray> profiles;
};


/* Used for profile sorting */
struct profile_prio_compare {
    bool operator() (pa_card_profile_info2 const * const lhs, pa_card_profile_info2 const * const rhs) const {

        if (lhs->priority == rhs->priority)
            return strcmp(lhs->name, rhs->name) > 0;

        return lhs->priority > rhs->priority;
    }
};

void populatePorts(const pa_card_info &info, std::map<QByteArray, PortInfo> &ports);


void groupProfiles(const std::set<pa_card_profile_info2 *, profile_prio_compare> &profile_priorities,
                   const std::map<QByteArray, PortInfo> &ports,
                   QMap<QString, ProfileGroup> &profiles);

#endif