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

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 <pulse/volume.h>
0008 
0009 #include "volumeobject.h"
0010 #include "volumeobject_p.h"
0011 
0012 namespace PulseAudioQt
0013 {
0014 VolumeObject::VolumeObject(QObject *parent)
0015     : IndexedPulseObject(parent)
0016     , d(new VolumeObjectPrivate(this))
0017 {
0018 }
0019 
0020 VolumeObjectPrivate::VolumeObjectPrivate(VolumeObject *q)
0021     : q(q)
0022 {
0023     pa_cvolume_init(&m_volume);
0024 }
0025 
0026 VolumeObject::~VolumeObject()
0027 {
0028     delete d;
0029 }
0030 
0031 qint64 VolumeObject::volume() const
0032 {
0033     return pa_cvolume_max(&d->m_volume);
0034 }
0035 
0036 bool VolumeObject::isMuted() const
0037 {
0038     return d->m_muted;
0039 }
0040 
0041 pa_cvolume VolumeObjectPrivate::cvolume() const
0042 {
0043     return m_volume;
0044 }
0045 
0046 bool VolumeObject::isVolumeWritable() const
0047 {
0048     return d->m_volumeWritable;
0049 }
0050 
0051 QVector<QString> VolumeObject::channels() const
0052 {
0053     return d->m_channels;
0054 }
0055 
0056 QStringList VolumeObject::rawChannels() const
0057 {
0058     return d->m_rawChannels;
0059 }
0060 
0061 QVector<qint64> VolumeObject::channelVolumes() const
0062 {
0063     QVector<qint64> ret;
0064     ret.reserve(d->m_volume.channels);
0065     for (int i = 0; i < d->m_volume.channels; ++i) {
0066         ret << d->m_volume.values[i];
0067     }
0068     return ret;
0069 }
0070 
0071 } // PulseAudioQt