File indexing completed on 2024-12-01 13:02:23

0001 /*
0002     SPDX-FileCopyrightText: 2018 Nicolas Fella <nicolas.fella@gmx.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #pragma once
0008 
0009 #include "port.h"
0010 #include "profile_p.h"
0011 #include <pulse/def.h>
0012 
0013 namespace PulseAudioQt
0014 {
0015 class PortPrivate
0016 {
0017 public:
0018     explicit PortPrivate(Port *q);
0019     virtual ~PortPrivate();
0020 
0021     Port *q;
0022     Port::Type m_type = Port::Type::Unknown;
0023 
0024     template<typename PAInfo>
0025     void setInfo(const PAInfo *info)
0026     {
0027         Profile::Availability newAvailability;
0028         switch (info->available) {
0029         case PA_PORT_AVAILABLE_NO:
0030             newAvailability = Profile::Unavailable;
0031             break;
0032         case PA_PORT_AVAILABLE_YES:
0033             newAvailability = Profile::Available;
0034             break;
0035         default:
0036             newAvailability = Profile::Unknown;
0037         }
0038 
0039 #if PA_CHECK_VERSION(14, 0, 0)
0040         m_type = static_cast<Port::Type>(info->type);
0041 #endif
0042         Q_EMIT q->typeChanged();
0043 
0044         q->Profile::d->setCommonInfo(info, newAvailability);
0045     }
0046 };
0047 }