summaryrefslogtreecommitdiffstats
path: root/src/PulseAudioQt/port_p.h
blob: 7501c6654988e9ab8c19a25f0a83eaae58cde859 (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
/*
    SPDX-FileCopyrightText: 2018 Nicolas Fella <nicolas.fella@gmx.de>

    SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/

#pragma once

#include "port.h"
#include "profile_p.h"
#include <pulse/def.h>

namespace PulseAudioQt
{
class PortPrivate
{
public:
    explicit PortPrivate(Port *q);
    virtual ~PortPrivate();

    Port *q;
    Port::Type m_type = Port::Type::Unknown;

    template<typename PAInfo>
    void setInfo(const PAInfo *info)
    {
        Profile::Availability newAvailability;
        switch (info->available) {
        case PA_PORT_AVAILABLE_NO:
            newAvailability = Profile::Unavailable;
            break;
        case PA_PORT_AVAILABLE_YES:
            newAvailability = Profile::Available;
            break;
        default:
            newAvailability = Profile::Unknown;
        }

#if PA_CHECK_VERSION(14, 0, 0)
        m_type = static_cast<Port::Type>(info->type);
#endif
        Q_EMIT q->typeChanged();

        q->Profile::d->setCommonInfo(info, newAvailability);
    }
};
}