aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/qmmp/output.cpp2
-rw-r--r--src/qmmp/outputwriter.cpp2
-rw-r--r--src/qmmp/qmmp.pro10
-rw-r--r--src/qmmp/softwarevolume.cpp75
-rw-r--r--src/qmmp/softwarevolume_p.h46
-rw-r--r--src/qmmp/soundcore.cpp4
-rw-r--r--src/qmmp/soundcore.h4
-rw-r--r--src/qmmp/volumehandler.cpp (renamed from src/qmmp/volumecontrol.cpp)82
-rw-r--r--src/qmmp/volumehandler.h (renamed from src/qmmp/volumecontrol_p.h)32
9 files changed, 156 insertions, 101 deletions
diff --git a/src/qmmp/output.cpp b/src/qmmp/output.cpp
index ff5bd0495..e81f68a1e 100644
--- a/src/qmmp/output.cpp
+++ b/src/qmmp/output.cpp
@@ -9,7 +9,7 @@
#include "audioparameters.h"
#include "qmmpsettings.h"
#include "buffer.h"
-#include "volumecontrol_p.h"
+#include "volumehandler.h"
#include "qmmp.h"
#include "qmmpplugincache_p.h"
#include "output.h"
diff --git a/src/qmmp/outputwriter.cpp b/src/qmmp/outputwriter.cpp
index 47806cd95..28d91a325 100644
--- a/src/qmmp/outputwriter.cpp
+++ b/src/qmmp/outputwriter.cpp
@@ -25,7 +25,7 @@
#include "output.h"
#include "audioconverter.h"
#include "channelconverter_p.h"
-#include "volumecontrol_p.h"
+#include "volumehandler.h"
#include "outputwriter_p.h"
extern "C" {
diff --git a/src/qmmp/qmmp.pro b/src/qmmp/qmmp.pro
index 1a3c55f15..466e0a6ce 100644
--- a/src/qmmp/qmmp.pro
+++ b/src/qmmp/qmmp.pro
@@ -31,7 +31,6 @@ HEADERS += \
eqsettings.h \
qmmpevents_p.h \
volume.h \
- volumecontrol_p.h \
outputwriter_p.h \
recycler_p.h \
qmmpplugincache_p.h \
@@ -41,7 +40,9 @@ HEADERS += \
dithering_p.h \
visualbuffer_p.h \
qmmp_export.h \
- trackinfo.h
+ trackinfo.h \
+ volumehandler.h \
+ softwarevolume_p.h
SOURCES += recycler.cpp \
decoder.cpp \
output.cpp \
@@ -53,7 +54,6 @@ SOURCES += recycler.cpp \
effect.cpp \
statehandler.cpp \
qmmp.cpp \
- volumecontrol.cpp \
metadatamodel.cpp \
tagmodel.cpp \
abstractengine.cpp \
@@ -75,7 +75,9 @@ SOURCES += recycler.cpp \
volume.cpp \
dithering.cpp \
visualbuffer.cpp \
- trackinfo.cpp
+ trackinfo.cpp \
+ volumehandler.cpp \
+ softwarevolume.cpp
unix:TARGET = ../../lib/qmmp$$APP_NAME_SUFFIX
win32:TARGET = ../../../bin/qmmp
diff --git a/src/qmmp/softwarevolume.cpp b/src/qmmp/softwarevolume.cpp
new file mode 100644
index 000000000..ed4343fb4
--- /dev/null
+++ b/src/qmmp/softwarevolume.cpp
@@ -0,0 +1,75 @@
+/***************************************************************************
+ * Copyright (C) 2008-2019 by Ilya Kotov *
+ * forkotov02@ya.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <QSettings>
+#include "buffer.h"
+#include "qmmp.h"
+#include "softwarevolume_p.h"
+
+SoftwareVolume::SoftwareVolume()
+{
+ QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
+ m_left = settings.value("Volume/left", 80).toInt();
+ m_right = settings.value("Volume/right", 80).toInt();
+ m_scaleLeft = (double)m_left/100.0;
+ m_scaleRight = (double)m_right/100.0;
+}
+
+SoftwareVolume::~SoftwareVolume()
+{
+ QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
+ settings.setValue("Volume/left", m_left);
+ settings.setValue("Volume/right", m_right);
+}
+
+void SoftwareVolume::setVolume(const VolumeSettings &v)
+{
+ m_left = v.left;
+ m_right = v.right;
+ m_scaleLeft = (double)m_left/100.0;
+ m_scaleRight = (double)m_right/100.0;
+}
+
+VolumeSettings SoftwareVolume::volume() const
+{
+ VolumeSettings v;
+ v.left = m_left;
+ v.right = m_right;
+ return v;
+}
+
+void SoftwareVolume::changeVolume(Buffer *b, int chan)
+{
+ if(chan == 1)
+ {
+ for(size_t i = 0; i < b->samples; ++i)
+ {
+ b->data[i] *= qMax(m_scaleLeft, m_scaleRight);
+ }
+ }
+ else
+ {
+ for(size_t i = 0; i < b->samples; i+=2)
+ {
+ b->data[i] *= m_scaleLeft;
+ b->data[i+1] *= m_scaleRight;
+ }
+ }
+}
diff --git a/src/qmmp/softwarevolume_p.h b/src/qmmp/softwarevolume_p.h
new file mode 100644
index 000000000..e82f4317b
--- /dev/null
+++ b/src/qmmp/softwarevolume_p.h
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * Copyright (C) 2008-2019 by Ilya Kotov *
+ * forkotov02@ya.ru *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#ifndef SOFTWAREVOLUME_P_H
+#define SOFTWAREVOLUME_P_H
+
+#include "volume.h"
+#include "buffer.h"
+
+/*! @internal
+ * @brief The SoftwareVolume class provides access to the software volume control.
+ * @author Ilya Kotov <forkotov02@ya.ru>
+ */
+class SoftwareVolume : public Volume
+{
+public:
+ SoftwareVolume();
+ ~SoftwareVolume();
+
+ void setVolume(const VolumeSettings &v) override;
+ VolumeSettings volume() const override;
+ void changeVolume(Buffer *b, int chan);
+
+private:
+ int m_left, m_right;
+ double m_scaleLeft, m_scaleRight;
+};
+
+#endif // SOFTWAREVOLUME_P_H
diff --git a/src/qmmp/soundcore.cpp b/src/qmmp/soundcore.cpp
index 2f21941e7..39d2a5db7 100644
--- a/src/qmmp/soundcore.cpp
+++ b/src/qmmp/soundcore.cpp
@@ -29,7 +29,7 @@
#include "effect.h"
#include "statehandler.h"
#include "inputsource.h"
-#include "volumecontrol_p.h"
+#include "volumehandler.h"
#include "enginefactory.h"
#include "metadatamanager.h"
#include "qmmpsettings.h"
@@ -47,7 +47,7 @@ SoundCore::SoundCore(QObject *parent)
m_engine = nullptr;
m_nextState = NO_ENGINE;
m_handler = new StateHandler(this);
- m_volumeControl = new VolumeControl(this);
+ m_volumeControl = new VolumeHandler(this);
connect(m_handler, SIGNAL(elapsedChanged(qint64)), SIGNAL(elapsedChanged(qint64)));
connect(m_handler, SIGNAL(bitrateChanged(int)), SIGNAL(bitrateChanged(int)));
connect(m_handler, SIGNAL(audioParametersChanged(AudioParameters)), SIGNAL(audioParametersChanged(AudioParameters)));
diff --git a/src/qmmp/soundcore.h b/src/qmmp/soundcore.h
index b28c2124f..241f4a15d 100644
--- a/src/qmmp/soundcore.h
+++ b/src/qmmp/soundcore.h
@@ -33,7 +33,7 @@
#include "eqsettings.h"
#include "trackinfo.h"
-class VolumeControl;
+class VolumeHandler;
class AbstractEngine;
class InputSource;
class StateHandler;
@@ -270,7 +270,7 @@ private:
QString m_path;
static SoundCore* m_instance;
StateHandler *m_handler;
- VolumeControl *m_volumeControl;
+ VolumeHandler *m_volumeControl;
AbstractEngine *m_engine;
QQueue<InputSource *> m_sources;
int m_nextState;
diff --git a/src/qmmp/volumecontrol.cpp b/src/qmmp/volumehandler.cpp
index b172ed23b..8bed61ce4 100644
--- a/src/qmmp/volumecontrol.cpp
+++ b/src/qmmp/volumehandler.cpp
@@ -23,22 +23,23 @@
#include <QSettings>
#include "qmmpsettings.h"
#include "output.h"
-#include "volumecontrol_p.h"
+#include "softwarevolume_p.h"
+#include "volumehandler.h"
-VolumeControl::VolumeControl(QObject *parent) : QObject(parent)
+VolumeHandler::VolumeHandler(QObject *parent) : QObject(parent)
{
m_timer = new QTimer(this);
connect(m_timer, SIGNAL(timeout()), SLOT(checkVolume()));
reload();
}
-VolumeControl::~VolumeControl()
+VolumeHandler::~VolumeHandler()
{
if(m_volume)
delete m_volume;
}
-void VolumeControl::setVolume(int left, int right)
+void VolumeHandler::setVolume(int left, int right)
{
VolumeSettings v;
v.left = qBound(0,left,100);
@@ -47,26 +48,26 @@ void VolumeControl::setVolume(int left, int right)
checkVolume();
}
-void VolumeControl::changeVolume(int delta)
+void VolumeHandler::changeVolume(int delta)
{
setVolume(qBound(0, volume() + delta, 100));
}
-void VolumeControl::setVolume(int volume)
+void VolumeHandler::setVolume(int volume)
{
volume = qBound(0, volume, 100);
setVolume(volume-qMax(balance(),0)*volume/100,
volume+qMin(balance(),0)*volume/100);
}
-void VolumeControl::setBalance(int balance)
+void VolumeHandler::setBalance(int balance)
{
balance = qBound(-100, balance, 100);
setVolume(volume()-qMax(balance,0)*volume()/100,
volume()+qMin(balance,0)*volume()/100);
}
-void VolumeControl::setMuted(bool muted)
+void VolumeHandler::setMuted(bool muted)
{
if(m_muted != muted)
{
@@ -75,33 +76,33 @@ void VolumeControl::setMuted(bool muted)
}
}
-int VolumeControl::left() const
+int VolumeHandler::left() const
{
return m_left;
}
-int VolumeControl::right() const
+int VolumeHandler::right() const
{
return m_right;
}
-int VolumeControl::volume() const
+int VolumeHandler::volume() const
{
return qMax(m_right, m_left);
}
-int VolumeControl::balance() const
+int VolumeHandler::balance() const
{
int v = volume();
return v > 0 ? (m_right - m_left)*100/v : 0;
}
-bool VolumeControl::isMuted() const
+bool VolumeHandler::isMuted() const
{
return m_muted;
}
-void VolumeControl::checkVolume()
+void VolumeHandler::checkVolume()
{
VolumeSettings v = m_volume->volume();
int l = v.left;
@@ -133,7 +134,7 @@ void VolumeControl::checkVolume()
m_prev_block = signalsBlocked ();
}
-void VolumeControl::reload()
+void VolumeHandler::reload()
{
m_timer->stop();
bool restore = false;
@@ -174,54 +175,3 @@ void VolumeControl::reload()
QTimer::singleShot(125, this, SLOT(checkVolume()));
}
}
-
-SoftwareVolume::SoftwareVolume()
-{
- QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
- m_left = settings.value("Volume/left", 80).toInt();
- m_right = settings.value("Volume/right", 80).toInt();
- m_scaleLeft = (double)m_left/100.0;
- m_scaleRight = (double)m_right/100.0;
-}
-
-SoftwareVolume::~SoftwareVolume()
-{
- QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
- settings.setValue("Volume/left", m_left);
- settings.setValue("Volume/right", m_right);
-}
-
-void SoftwareVolume::setVolume(const VolumeSettings &v)
-{
- m_left = v.left;
- m_right = v.right;
- m_scaleLeft = (double)m_left/100.0;
- m_scaleRight = (double)m_right/100.0;
-}
-
-VolumeSettings SoftwareVolume::volume() const
-{
- VolumeSettings v;
- v.left = m_left;
- v.right = m_right;
- return v;
-}
-
-void SoftwareVolume::changeVolume(Buffer *b, int chan)
-{
- if(chan == 1)
- {
- for(size_t i = 0; i < b->samples; ++i)
- {
- b->data[i] *= qMax(m_scaleLeft, m_scaleRight);
- }
- }
- else
- {
- for(size_t i = 0; i < b->samples; i+=2)
- {
- b->data[i] *= m_scaleLeft;
- b->data[i+1] *= m_scaleRight;
- }
- }
-}
diff --git a/src/qmmp/volumecontrol_p.h b/src/qmmp/volumehandler.h
index 5b652821c..73def472a 100644
--- a/src/qmmp/volumecontrol_p.h
+++ b/src/qmmp/volumehandler.h
@@ -17,8 +17,8 @@
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
-#ifndef VOLUMECONTROL_P_H
-#define VOLUMECONTROL_P_H
+#ifndef VOLUMEHANDLER_H
+#define VOLUMEHANDLER_H
#include <QObject>
#include "qmmp.h"
@@ -28,11 +28,11 @@
class QTimer;
class SoftwareVolume;
-/*! @internal
- * @brief The VolumeControl class provides volume control access
+/*!
+ * @brief The VolumeHandler class provides volume control access
* @author Ilya Kotov <forkotov02@ya.ru>
*/
-class QMMP_EXPORT VolumeControl : public QObject
+class QMMP_EXPORT VolumeHandler : public QObject
{
Q_OBJECT
public:
@@ -40,11 +40,11 @@ public:
* Object constructor.
* @param parent Parent object.
*/
- VolumeControl(QObject *parent = nullptr);
+ VolumeHandler(QObject *parent = nullptr);
/*!
* Destructor.
*/
- ~VolumeControl();
+ ~VolumeHandler();
/*!
* Setups volume level.
* Subclass should reimplement this fucntion.
@@ -123,23 +123,5 @@ private:
QTimer *m_timer;
};
-/*! @internal
- * @brief The SoftwareVolume class provides access to the software volume control.
- * @author Ilya Kotov <forkotov02@ya.ru>
- */
-class SoftwareVolume : public Volume
-{
-public:
- SoftwareVolume();
- ~SoftwareVolume();
-
- void setVolume(const VolumeSettings &v) override;
- VolumeSettings volume() const override;
- void changeVolume(Buffer *b, int chan);
-
-private:
- int m_left, m_right;
- double m_scaleLeft, m_scaleRight;
-};
#endif