File indexing completed on 2024-04-21 15:32:40

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