File indexing completed on 2024-05-12 04:44:37

0001 /*  This file is part of the KDE project.
0002  *
0003  *    Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
0004  *    Copyright (C) 2013 Martin Sandsmark <martin.sandsmark@kde.org>
0005  *
0006  *    This library is free software: you can redistribute it and/or modify
0007  *    it under the terms of the GNU Lesser General Public License as published by
0008  *    the Free Software Foundation, either version 2.1 or 3 of the License.
0009  *
0010  *    This library is distributed in the hope that it will be useful,
0011  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  *    GNU Lesser General Public License for more details.
0014  *
0015  *    You should have received a copy of the GNU Lesser General Public License
0016  *    along with this library.  If not, see <http://www.gnu.org/licenses/>.
0017  */
0018 
0019 #ifndef PHONON_VLC_VOLUMEFADEREFFECT_H
0020 #define PHONON_VLC_VOLUMEFADEREFFECT_H
0021 
0022 #include <phonon/volumefaderinterface.h>
0023 
0024 #include <QtCore/QTime>
0025 #include <QtCore/QPointer>
0026 
0027 #include "sinknode.h"
0028 
0029 class QTimeLine;
0030 
0031 namespace Phonon {
0032 
0033 class MediaObject;
0034 
0035 namespace VLC {
0036 
0037 class VolumeFaderEffect : public QObject, public SinkNode, public VolumeFaderInterface
0038 {
0039     Q_OBJECT
0040     Q_INTERFACES(Phonon::VolumeFaderInterface)
0041 
0042 public:
0043     explicit VolumeFaderEffect(QObject *parent = nullptr);
0044     ~VolumeFaderEffect() override;
0045 
0046     // VolumeFaderInterface:
0047     float volume() const override;
0048     Phonon::VolumeFaderEffect::FadeCurve fadeCurve() const override;
0049     void setFadeCurve(Phonon::VolumeFaderEffect::FadeCurve fadeCurve) override;
0050     void fadeTo(float volume, int fadeTime) override;
0051     void setVolume(float v) override;
0052     QPointer<MediaObject> mediaObject() { return m_mediaObject; }
0053 
0054 private Q_SLOTS:
0055     void slotSetVolume(qreal v);
0056 
0057 private:
0058     void abortFade();
0059     inline void setVolumeInternal(float v);
0060 
0061     Phonon::VolumeFaderEffect::FadeCurve m_fadeCurve;
0062     float m_fadeFromVolume;
0063     float m_fadeToVolume;
0064     QTimeLine *m_fadeTimeline;
0065 
0066 };
0067 
0068 } // namespace VLC
0069 } // namespace Phonon
0070 
0071 #endif // PHONON_VLC_VOLUMEFADEREFFECT_H