File indexing completed on 2025-01-12 07:22:36
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 #ifndef VOLUMEOBJECT_P_H 0007 #define VOLUMEOBJECT_P_H 0008 0009 #include <pulse/volume.h> 0010 0011 #include "indexedpulseobject_p.h" 0012 #include "volumeobject.h" 0013 0014 namespace PulseAudioQt 0015 { 0016 class VolumeObjectPrivate 0017 { 0018 public: 0019 explicit VolumeObjectPrivate(VolumeObject *q); 0020 0021 VolumeObject *q; 0022 pa_channel_map foo; 0023 pa_cvolume m_volume; 0024 bool m_muted = true; 0025 bool m_volumeWritable = true; 0026 QVector<QString> m_channels; 0027 QStringList m_rawChannels; 0028 0029 pa_cvolume cvolume() const; 0030 0031 template<typename PAInfo> 0032 void updateVolumeObject(PAInfo *info) 0033 { 0034 q->IndexedPulseObject::d->updatePulseObject(info); 0035 q->PulseObject::d->updateProperties(info); 0036 if (m_muted != info->mute) { 0037 m_muted = info->mute; 0038 Q_EMIT q->mutedChanged(); 0039 } 0040 if (!pa_cvolume_equal(&m_volume, &info->volume)) { 0041 m_volume = info->volume; 0042 Q_EMIT q->volumeChanged(); 0043 Q_EMIT q->channelVolumesChanged(); 0044 } 0045 QVector<QString> infoChannels; 0046 infoChannels.reserve(info->channel_map.channels); 0047 for (int i = 0; i < info->channel_map.channels; ++i) { 0048 infoChannels << QString::fromUtf8(pa_channel_position_to_pretty_string(info->channel_map.map[i])); 0049 } 0050 if (m_channels != infoChannels) { 0051 m_channels = infoChannels; 0052 Q_EMIT q->channelsChanged(); 0053 } 0054 0055 QStringList infoRawChannels; 0056 infoRawChannels.reserve(info->channel_map.channels); 0057 for (int i = 0; i < info->channel_map.channels; ++i) { 0058 infoRawChannels << QString::fromUtf8(pa_channel_position_to_string(info->channel_map.map[i])); 0059 } 0060 if (m_rawChannels != infoRawChannels) { 0061 m_rawChannels = infoRawChannels; 0062 Q_EMIT q->rawChannelsChanged(); 0063 } 0064 } 0065 }; 0066 } 0067 #endif