File indexing completed on 2024-12-08 10:59:36

0001 /*
0002     SPDX-FileCopyrightText: 2014-2015 Harald Sitter <sitter@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #include "volumeobject.h"
0008 
0009 namespace QPulseAudio
0010 {
0011 VolumeObject::VolumeObject(QObject *parent)
0012     : PulseObject(parent)
0013 {
0014     pa_cvolume_init(&m_volume);
0015 }
0016 
0017 VolumeObject::~VolumeObject() = default;
0018 
0019 qint64 VolumeObject::volume() const
0020 {
0021     return pa_cvolume_max(&m_volume);
0022 }
0023 
0024 bool VolumeObject::isMuted() const
0025 {
0026     return m_muted;
0027 }
0028 
0029 pa_cvolume VolumeObject::cvolume() const
0030 {
0031     return m_volume;
0032 }
0033 
0034 bool VolumeObject::hasVolume() const
0035 {
0036     return m_hasVolume;
0037 }
0038 
0039 bool VolumeObject::isVolumeWritable() const
0040 {
0041     return m_volumeWritable;
0042 }
0043 
0044 QStringList VolumeObject::channels() const
0045 {
0046     return m_channels;
0047 }
0048 
0049 QStringList VolumeObject::rawChannels() const
0050 {
0051     return m_rawChannels;
0052 }
0053 
0054 QVector<qint64> VolumeObject::channelVolumes() const
0055 {
0056     QVector<qint64> ret;
0057     ret.reserve(m_volume.channels);
0058     for (int i = 0; i < m_volume.channels; ++i) {
0059         ret << m_volume.values[i];
0060     }
0061     return ret;
0062 }
0063 
0064 } // QPulseAudio