Phonon

audiooutput.h
1/* This file is part of the KDE project
2 Copyright (C) 2005-2006 Matthias Kretz <kretz@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) version 3, or any
8 later version accepted by the membership of KDE e.V. (or its
9 successor approved by the membership of KDE e.V.), Nokia Corporation
10 (or its successors, if any) and the KDE Free Qt Foundation, which shall
11 act as a proxy defined in Section 6 of version 3 of the license.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library. If not, see <http://www.gnu.org/licenses/>.
20
21*/
22#ifndef Phonon_AUDIOOUTPUT_H
23#define Phonon_AUDIOOUTPUT_H
24
25#include "phonon_export.h"
26#include "abstractaudiooutput.h"
27#include "phonondefs.h"
28#include "phononnamespace.h"
29#include "objectdescription.h"
30
31
32class QString;
33
34class AudioOutputAdaptor;
35namespace Phonon
36{
37 class AudioOutputPrivate;
38
39 /** \class AudioOutput audiooutput.h phonon/AudioOutput
40 * \short Class for audio output to the soundcard.
41 *
42 * Use this class to define the audio output.
43 *
44 * \ingroup Frontend
45 * \author Matthias Kretz <kretz@kde.org>
46 * \see Phonon::Ui::VolumeSlider
47 */
48 class PHONON_EXPORT AudioOutput : public AbstractAudioOutput
49 {
50 friend class FactoryPrivate;
51 friend class ::AudioOutputAdaptor;
53 P_DECLARE_PRIVATE(AudioOutput)
54 /**
55 * This is the name that appears in Mixer applications that control
56 * the volume of this output.
57 *
58 * \see category
59 */
60 Q_PROPERTY(QString name READ name WRITE setName)
61 /**
62 * This is the current loudness of the output (it is using Stevens' law
63 * to calculate the change in voltage internally).
64 *
65 * \see volumeDecibel
66 */
67 Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
68 /**
69 * This is the current volume of the output in decibel.
70 *
71 * 0 dB means no change in volume, -6dB means an attenuation of the
72 * voltage to 50% and an attenuation of the power to 25%, -inf dB means
73 * silence.
74 *
75 * \see volume
76 */
77 Q_PROPERTY(qreal volumeDecibel READ volumeDecibel WRITE setVolumeDecibel)
78 /**
79 * This property holds the (hardware) destination for the output.
80 *
81 * The default device is determined by the category and the global
82 * configuration for that category of outputs. Normally you don't need
83 * to override this setting - letting the user change the global
84 * configuration is the right choice. You can still override the
85 * device though, if you have good reasons to do so.
86 *
87 * \see outputDeviceChanged
88 */
89 Q_PROPERTY(AudioOutputDevice outputDevice READ outputDevice WRITE setOutputDevice)
90
91 /**
92 * This property tells whether the output is muted.
93 *
94 * Muting the output has the same effect as calling setVolume(0.0).
95 */
96 Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
97 public:
98 /**
99 * Creates a new AudioOutput that defines output to a physical
100 * device.
101 *
102 * \param category The category can be used by mixer applications to group volume
103 * controls of applications into categories. That makes it easier for
104 * the user to identify the programs.
105 * The category is also used for the default output device that is
106 * configured centrally. As an example: often users want to have the
107 * audio signal of a VoIP application go to their USB headset while
108 * all other sounds should go to the internal soundcard.
109 *
110 * \param parent QObject parent
111 *
112 * \see Phonon::categoryToString
113 * \see outputDevice
114 */
115 explicit AudioOutput(Phonon::Category category, QObject *parent = nullptr);
116 explicit AudioOutput(QObject *parent = nullptr);
117
118 QString name() const;
119 qreal volume() const;
120 qreal volumeDecibel() const;
121
122 /**
123 * Returns the category of this output.
124 *
125 * \see AudioOutput(Phonon::Category, QObject *)
126 */
127 Phonon::Category category() const;
128 AudioOutputDevice outputDevice() const;
129 bool isMuted() const;
130
131 public Q_SLOTS:
132 void setName(const QString &newName);
133 void setVolume(qreal newVolume);
134 void setVolumeDecibel(qreal newVolumeDecibel);
135 bool setOutputDevice(const Phonon::AudioOutputDevice &newAudioOutputDevice);
136 void setMuted(bool mute);
137
138 Q_SIGNALS:
139 /**
140 * This signal is emitted whenever the volume has changed. As the
141 * volume can change without a call to setVolume this is important
142 * to keep a widget showing the current volume up to date.
143 */
144 void volumeChanged(qreal newVolume);
145
146 /**
147 * This signal is emitted when the muted property has changed. As
148 * this property can change by outside sources, a UI element showing
149 * the muted property should listen to this signal.
150 */
151 void mutedChanged(bool);
152
153 /**
154 * This signal is emitted when the (hardware) device for the output
155 * has changed.
156 *
157 * The change can happen either through setOutputDevice or if the
158 * global configuration for the used category has changed.
159 *
160 * \see outputDevice
161 */
162 void outputDeviceChanged(const Phonon::AudioOutputDevice &newAudioOutputDevice);
163
164 private:
165 Q_PRIVATE_SLOT(k_func(), void _k_volumeChanged(qreal))
166 Q_PRIVATE_SLOT(k_func(), void _k_mutedChanged(bool))
167 Q_PRIVATE_SLOT(k_func(), void _k_revertFallback())
168 Q_PRIVATE_SLOT(k_func(), void _k_audioDeviceFailed())
169 Q_PRIVATE_SLOT(k_func(), void _k_deviceListChanged())
170 Q_PRIVATE_SLOT(k_func(), void _k_deviceChanged(int device))
171 };
172} //namespace Phonon
173
174
175// vim: sw=4 ts=4 tw=80
176#endif // Phonon_AUDIOOUTPUT_H
void mutedChanged(bool)
This signal is emitted when the muted property has changed.
QString name
This is the name that appears in Mixer applications that control the volume of this output.
Definition audiooutput.h:60
AudioOutput(Phonon::Category category, QObject *parent=nullptr)
Creates a new AudioOutput that defines output to a physical device.
bool muted
This property tells whether the output is muted.
Definition audiooutput.h:96
void volumeChanged(qreal newVolume)
This signal is emitted whenever the volume has changed.
qreal volume
This is the current loudness of the output (it is using Stevens' law to calculate the change in volta...
Definition audiooutput.h:67
Phonon::Category category() const
Returns the category of this output.
void outputDeviceChanged(const Phonon::AudioOutputDevice &newAudioOutputDevice)
This signal is emitted when the (hardware) device for the output has changed.
AudioOutputDevice outputDevice
This property holds the (hardware) destination for the output.
Definition audiooutput.h:89
qreal volumeDecibel
This is the current volume of the output in decibel.
Definition audiooutput.h:77
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:49:05 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.