File indexing completed on 2024-04-14 04:38:23

0001 /*  This file is part of the KDE project
0002     Copyright (C) 2005-2006 Matthias Kretz <kretz@kde.org>
0003 
0004     This library is free software; you can redistribute it and/or
0005     modify it under the terms of the GNU Lesser General Public
0006     License as published by the Free Software Foundation; either
0007     version 2.1 of the License, or (at your option) version 3, or any
0008     later version accepted by the membership of KDE e.V. (or its
0009     successor approved by the membership of KDE e.V.), Nokia Corporation
0010     (or its successors, if any) and the KDE Free Qt Foundation, which shall
0011     act as a proxy defined in Section 6 of version 3 of the license.
0012 
0013     This library is distributed in the hope that it will be useful,
0014     but WITHOUT ANY WARRANTY; without even the implied warranty of
0015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016     Lesser General Public License for more details.
0017 
0018     You should have received a copy of the GNU Lesser General Public
0019     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0020 
0021 */
0022 #ifndef Phonon_AUDIOOUTPUT_H
0023 #define Phonon_AUDIOOUTPUT_H
0024 
0025 #include "phonon_export.h"
0026 #include "abstractaudiooutput.h"
0027 #include "phonondefs.h"
0028 #include "phononnamespace.h"
0029 #include "objectdescription.h"
0030 
0031 
0032 class QString;
0033 
0034 class AudioOutputAdaptor;
0035 namespace Phonon
0036 {
0037     class AudioOutputPrivate;
0038 
0039     /** \class AudioOutput audiooutput.h phonon/AudioOutput
0040      * \short Class for audio output to the soundcard.
0041      *
0042      * Use this class to define the audio output.
0043      *
0044      * \ingroup Frontend
0045      * \author Matthias Kretz <kretz@kde.org>
0046      * \see Phonon::Ui::VolumeSlider
0047      */
0048     class PHONON_EXPORT AudioOutput : public AbstractAudioOutput
0049     {
0050         friend class FactoryPrivate;
0051         friend class ::AudioOutputAdaptor;
0052         Q_OBJECT
0053         P_DECLARE_PRIVATE(AudioOutput)
0054         /**
0055          * This is the name that appears in Mixer applications that control
0056          * the volume of this output.
0057          *
0058          * \see category
0059          */
0060         Q_PROPERTY(QString name READ name WRITE setName)
0061         /**
0062          * This is the current loudness of the output (it is using Stevens' law
0063          * to calculate the change in voltage internally).
0064          *
0065          * \see volumeDecibel
0066          */
0067         Q_PROPERTY(qreal volume READ volume WRITE setVolume NOTIFY volumeChanged)
0068         /**
0069          * This is the current volume of the output in decibel.
0070          *
0071          * 0 dB means no change in volume, -6dB means an attenuation of the
0072          * voltage to 50% and an attenuation of the power to 25%, -inf dB means
0073          * silence.
0074          *
0075          * \see volume
0076          */
0077         Q_PROPERTY(qreal volumeDecibel READ volumeDecibel WRITE setVolumeDecibel)
0078         /**
0079          * This property holds the (hardware) destination for the output.
0080          *
0081          * The default device is determined by the category and the global
0082          * configuration for that category of outputs. Normally you don't need
0083          * to override this setting - letting the user change the global
0084          * configuration is the right choice. You can still override the
0085          * device though, if you have good reasons to do so.
0086          *
0087          * \see outputDeviceChanged
0088          */
0089         Q_PROPERTY(AudioOutputDevice outputDevice READ outputDevice WRITE setOutputDevice)
0090 
0091         /**
0092          * This property tells whether the output is muted.
0093          *
0094          * Muting the output has the same effect as calling setVolume(0.0).
0095          */
0096         Q_PROPERTY(bool muted READ isMuted WRITE setMuted NOTIFY mutedChanged)
0097         public:
0098             /**
0099              * Creates a new AudioOutput that defines output to a physical
0100              * device.
0101              *
0102              * \param category The category can be used by mixer applications to group volume
0103              * controls of applications into categories. That makes it easier for
0104              * the user to identify the programs.
0105              * The category is also used for the default output device that is
0106              * configured centrally. As an example: often users want to have the
0107              * audio signal of a VoIP application go to their USB headset while
0108              * all other sounds should go to the internal soundcard.
0109              *
0110              * \param parent QObject parent
0111              *
0112              * \see Phonon::categoryToString
0113              * \see outputDevice
0114              */
0115             explicit AudioOutput(Phonon::Category category, QObject *parent = nullptr);
0116             explicit AudioOutput(QObject *parent = nullptr);
0117 
0118             QString name() const;
0119             qreal volume() const;
0120             qreal volumeDecibel() const;
0121 
0122             /**
0123              * Returns the category of this output.
0124              *
0125              * \see AudioOutput(Phonon::Category, QObject *)
0126              */
0127             Phonon::Category category() const;
0128             AudioOutputDevice outputDevice() const;
0129             bool isMuted() const;
0130 
0131         public Q_SLOTS:
0132             void setName(const QString &newName);
0133             void setVolume(qreal newVolume);
0134             void setVolumeDecibel(qreal newVolumeDecibel);
0135             bool setOutputDevice(const Phonon::AudioOutputDevice &newAudioOutputDevice);
0136             void setMuted(bool mute);
0137 
0138         Q_SIGNALS:
0139             /**
0140              * This signal is emitted whenever the volume has changed. As the
0141              * volume can change without a call to setVolume this is important
0142              * to keep a widget showing the current volume up to date.
0143              */
0144             void volumeChanged(qreal newVolume);
0145 
0146             /**
0147              * This signal is emitted when the muted property has changed. As
0148              * this property can change by outside sources, a UI element showing
0149              * the muted property should listen to this signal.
0150              */
0151             void mutedChanged(bool);
0152 
0153             /**
0154              * This signal is emitted when the (hardware) device for the output
0155              * has changed.
0156              *
0157              * The change can happen either through setOutputDevice or if the
0158              * global configuration for the used category has changed.
0159              *
0160              * \see outputDevice
0161              */
0162             void outputDeviceChanged(const Phonon::AudioOutputDevice &newAudioOutputDevice);
0163 
0164         private:
0165             Q_PRIVATE_SLOT(k_func(), void _k_volumeChanged(qreal))
0166             Q_PRIVATE_SLOT(k_func(), void _k_mutedChanged(bool))
0167             Q_PRIVATE_SLOT(k_func(), void _k_revertFallback())
0168             Q_PRIVATE_SLOT(k_func(), void _k_audioDeviceFailed())
0169             Q_PRIVATE_SLOT(k_func(), void _k_deviceListChanged())
0170             Q_PRIVATE_SLOT(k_func(), void _k_deviceChanged(int device))
0171     };
0172 } //namespace Phonon
0173 
0174 
0175 // vim: sw=4 ts=4 tw=80
0176 #endif // Phonon_AUDIOOUTPUT_H