Qmmp
Loading...
Searching...
No Matches
volumehandler.h
1/***************************************************************************
2 * Copyright (C) 2008-2025 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);
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:
121 void mutedChanged(bool muted);
122
123public slots:
131 void reload();
132
133private:
134 VolumeSettings m_settings;
135 bool m_prev_block = false;
136 std::atomic_bool m_muted = ATOMIC_VAR_INIT(false);
137 std::atomic_bool m_apply = ATOMIC_VAR_INIT(false);
138 QMutex m_mutex;
139 double m_scaleLeft = 0, m_scaleRight = 0;
140 Volume *m_volume = nullptr;
141 QTimer *m_timer;
142 static VolumeHandler *m_instance;
143
144};
145
146#endif
Audio buffer class.
Definition buffer.h:21
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