File indexing completed on 2024-04-14 14:55:44

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 "sourceoutput.h"
0008 #include "sourceoutput_p.h"
0009 
0010 #include "context.h"
0011 #include "context_p.h"
0012 #include "stream_p.h"
0013 
0014 namespace PulseAudioQt
0015 {
0016 SourceOutput::SourceOutput(QObject *parent)
0017     : Stream(parent)
0018     , d(new SourceOutputPrivate(this))
0019 {
0020 }
0021 
0022 SourceOutput::~SourceOutput()
0023 {
0024     delete d;
0025 }
0026 
0027 SourceOutputPrivate::SourceOutputPrivate(SourceOutput *q)
0028     : q(q)
0029 {
0030 }
0031 
0032 void SourceOutputPrivate::update(const pa_source_output_info *info)
0033 {
0034     q->Stream::d->updateStream(info);
0035     if (q->Stream::d->m_deviceIndex != info->source) {
0036         q->Stream::d->m_deviceIndex = info->source;
0037         Q_EMIT q->deviceIndexChanged();
0038     }
0039 }
0040 
0041 void SourceOutput::setDeviceIndex(quint32 deviceIndex)
0042 {
0043     Context::instance()->d->setGenericDeviceForStream(index(), deviceIndex, &pa_context_move_source_output_by_index);
0044 }
0045 
0046 void SourceOutput::setVolume(qint64 volume)
0047 {
0048     Context::instance()->d->setGenericVolume(index(), -1, volume, VolumeObject::d->cvolume(), &pa_context_set_source_output_volume);
0049 }
0050 
0051 void SourceOutput::setMuted(bool muted)
0052 {
0053     Context::instance()->d->setGenericMute(index(), muted, &pa_context_set_source_output_mute);
0054 }
0055 
0056 void SourceOutput::setChannelVolume(int channel, qint64 volume)
0057 {
0058     Context::instance()->d->setGenericVolume(index(), channel, volume, VolumeObject::d->cvolume(), &pa_context_set_source_output_volume);
0059 }
0060 
0061 void SourceOutput::setChannelVolumes(const QVector<qint64> &channelVolumes)
0062 {
0063     Context::instance()->d->setGenericVolumes(index(), channelVolumes, VolumeObject::d->m_volume, &pa_context_set_source_output_volume);
0064 }
0065 
0066 } // PulseAudioQt