Qmmp
Loading...
Searching...
No Matches
volumehandler.h
1/***************************************************************************
2 * Copyright (C) 2008-2022 by Ilya Kotov *
3 * forkotov02@ya.ru *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
20#ifndef VOLUMEHANDLER_H
21#define VOLUMEHANDLER_H
22
23#include <QObject>
24#include <QMutex>
25#include <atomic>
26#include "qmmp.h"
27#include "volume.h"
28#include "buffer.h"
29
30class QTimer;
31class SoftwareVolume;
32
37class QMMP_EXPORT VolumeHandler : public QObject
38{
39 Q_OBJECT
40public:
45 VolumeHandler(QObject *parent = nullptr);
56 void setVolume(int left, int right);
60 void changeVolume(int delta);
65 void setVolume(int volume);
70 void setBalance(int balance);
74 void setMuted(bool muted);
78 int left() const;
82 int right() const;
86 int volume() const;
90 int balance() const;
94 bool isMuted() const;
100 void apply(Buffer *b, int chan);
105
106signals:
112 void volumeChanged(int left, int right);
117 void volumeChanged(int volume);
122 void balanceChanged(int balance);
127 void mutedChanged(bool muted);
128
129public slots:
137 void reload();
138
139private:
140 VolumeSettings m_settings;
141 bool m_prev_block = false;
142 std::atomic_bool m_muted = ATOMIC_VAR_INIT(false);
143 std::atomic_bool m_apply = ATOMIC_VAR_INIT(false);
144 QMutex m_mutex;
145 double m_scaleLeft = 0, m_scaleRight = 0;
146 Volume *m_volume = nullptr;
147 QTimer *m_timer;
148 static VolumeHandler *m_instance;
149
150};
151
152#endif
Audio buffer class.
Definition buffer.h:21
The VolumeHandler class provides volume control access.
Definition volumehandler.h:38
void volumeChanged(int left, int right)
bool isMuted() const
void mutedChanged(bool muted)
int right() const
void setMuted(bool muted)
void changeVolume(int delta)
void balanceChanged(int balance)
void volumeChanged(int volume)
void setVolume(int volume)
int volume() const
void apply(Buffer *b, int chan)
int balance() const
static VolumeHandler * instance()
void checkVolume()
int left() const
void setBalance(int balance)
void setVolume(int left, int right)
VolumeHandler(QObject *parent=nullptr)
The Volume class provides asbtract volume interface.
Definition volume.h:52
The VolumeSettings structure stores volume levels.
Definition volume.h:32