diff options
author | Simon Rettberg | 2022-08-18 20:27:25 +0200 |
---|---|---|
committer | Simon Rettberg | 2022-08-18 20:27:25 +0200 |
commit | c48cebd620d3f5330c104d85ac32f0aaffadaa14 (patch) | |
tree | 8fc74d8aa05fcdc75bfcdf93fdc89c0f071692eb /src/PulseAudioQt/sink.cpp | |
parent | When changing default output of card, also set default sink (diff) | |
download | pavucontrol-slx-c48cebd620d3f5330c104d85ac32f0aaffadaa14.tar.gz pavucontrol-slx-c48cebd620d3f5330c104d85ac32f0aaffadaa14.tar.xz pavucontrol-slx-c48cebd620d3f5330c104d85ac32f0aaffadaa14.zip |
Replace everything with new "slxmix" (work in progress)
Diffstat (limited to 'src/PulseAudioQt/sink.cpp')
-rw-r--r-- | src/PulseAudioQt/sink.cpp | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/PulseAudioQt/sink.cpp b/src/PulseAudioQt/sink.cpp new file mode 100644 index 0000000..6b36762 --- /dev/null +++ b/src/PulseAudioQt/sink.cpp @@ -0,0 +1,93 @@ +/* + SPDX-FileCopyrightText: 2014-2015 Harald Sitter <sitter@kde.org> + + SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL +*/ + +#include "sink.h" +#include "sink_p.h" + +#include "context.h" +#include "context_p.h" +#include "server.h" + +#include "device_p.h" +#include "volumeobject_p.h" + +namespace PulseAudioQt +{ +Sink::Sink(QObject *parent) + : Device(parent) + , d(new SinkPrivate(this)) +{ + connect(Context::instance()->server(), &Server::defaultSinkChanged, this, &Sink::defaultChanged); +} + +SinkPrivate::SinkPrivate(Sink *q) + : q(q) +{ +} + +Sink::~Sink() +{ + delete d; +} + +void SinkPrivate::update(const pa_sink_info *info) +{ + q->Device::d->updateDevice(info); + + if (m_monitorIndex != info->monitor_source) { + m_monitorIndex = info->monitor_source; + Q_EMIT q->monitorIndexChanged(); + } +} + +void Sink::setVolume(qint64 volume) +{ + Context::instance()->d->setGenericVolume(index(), -1, volume, VolumeObject::d->cvolume(), &pa_context_set_sink_volume_by_index); +} + +void Sink::setMuted(bool muted) +{ + Context::instance()->d->setGenericMute(index(), muted, &pa_context_set_sink_mute_by_index); +} + +void Sink::setActivePortIndex(quint32 port_index) +{ + Port *port = qobject_cast<Port *>(ports().at(port_index)); + if (!port) { + qWarning() << "invalid port set request" << port_index; + return; + } + Context::instance()->d->setGenericPort(index(), port->name(), &pa_context_set_sink_port_by_index); +} + +void Sink::setChannelVolume(int channel, qint64 volume) +{ + Context::instance()->d->setGenericVolume(index(), channel, volume, VolumeObject::d->cvolume(), &pa_context_set_sink_volume_by_index); +} + +bool Sink::isDefault() const +{ + return Context::instance()->server()->defaultSink() == this; +} + +void Sink::setDefault(bool enable) +{ + if (!isDefault() && enable) { + Context::instance()->server()->setDefaultSink(this); + } +} + +quint32 Sink::monitorIndex() const +{ + return d->m_monitorIndex; +} + +void Sink::setChannelVolumes(const QVector<qint64> &channelVolumes) +{ + Context::instance()->d->setGenericVolumes(index(), channelVolumes, VolumeObject::d->m_volume, &pa_context_set_sink_volume_by_index); +} + +} // PulseAudioQt |