PulseAudio Qt Bindings

source.cpp
1/*
2 SPDX-FileCopyrightText: 2014-2015 Harald Sitter <sitter@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "source.h"
8#include "source_p.h"
9
10#include "context.h"
11#include "context_p.h"
12#include "device_p.h"
13#include "server.h"
14#include "volumeobject_p.h"
15
16namespace PulseAudioQt
17{
18Source::Source(QObject *parent)
19 : Device(parent)
20 , d(new SourcePrivate(this))
21{
22 connect(Context::instance()->server(), &Server::defaultSourceChanged, this, &Source::defaultChanged);
23}
24
25SourcePrivate::SourcePrivate(Source *q)
26 : q(q)
27{
28}
29
30void SourcePrivate::update(const pa_source_info *info)
31{
32 q->Device::d->updateDevice(info);
33}
34
35void Source::setVolume(qint64 volume)
36{
37 qCDebug(PULSEAUDIOQT) << "Changing volume of Source" << name() << " to " << volume;
38 Context::instance()->d->setGenericVolume(index(), -1, volume, VolumeObject::d->cvolume(), &pa_context_set_source_volume_by_index);
39}
40
41void Source::setMuted(bool muted)
42{
43 Context::instance()->d->setGenericMute(index(), muted, &pa_context_set_source_mute_by_index);
44}
45
46void Source::setActivePortIndex(quint32 port_index)
47{
48 Port *port = qobject_cast<Port *>(ports().at(port_index));
49 if (!port) {
50 qCWarning(PULSEAUDIOQT) << "invalid port set request" << port_index;
51 return;
52 }
53 Context::instance()->d->setGenericPort(index(), port->name(), &pa_context_set_source_port_by_index);
54}
55
56void Source::setChannelVolume(int channel, qint64 volume)
57{
58 Context::instance()->d->setGenericVolume(index(), channel, volume, VolumeObject::d->cvolume(), &pa_context_set_source_volume_by_index);
59}
60
61bool Source::isDefault() const
62{
63 return Context::instance()->server()->defaultSource() == this;
64}
65
66void Source::setDefault(bool enable)
67{
68 if (!isDefault() && enable) {
69 Context::instance()->server()->setDefaultSource(this);
70 }
71}
72
73void Source::switchStreams()
74{
75 const auto sourceOutputs = Context::instance()->sourceOutputs();
76 for (const auto &sourceOutput : sourceOutputs) {
77 sourceOutput->setDeviceIndex(index());
78 }
79}
80
81void Source::setChannelVolumes(const QList<qint64> &volumes)
82{
83 Context::instance()->d->setGenericVolumes(index(), volumes, VolumeObject::d->m_volume, &pa_context_set_source_volume_by_index);
84}
85
86Source::~Source()
87{
88}
89} // PulseAudioQt
A PulseAudio port.
Definition port.h:19
The primary namespace of PulseAudioQt.
Definition card.cpp:17
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:01 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.