Qmmp
qmmpaudioengine_p.h
1 /***************************************************************************
2  * Copyright (C) 2009-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 
21 #ifndef QMMPAUDIOENGINE_P_H
22 #define QMMPAUDIOENGINE_P_H
23 
24 #include <QQueue>
25 #include <QHash>
26 #include <atomic>
27 #include <QSharedPointer>
28 #include "abstractengine.h"
29 #include "trackinfo.h"
30 #include "audioparameters.h"
31 
32 class QIODevice;
33 class OutputWriter;
34 class Effect;
35 class DecoderFactory;
36 class StateHandler;
37 class Decoder;
38 class InputSource;
39 class EffectFactory;
40 class ReplayGain;
41 class QmmpSettings;
42 class AudioConverter;
43 class Dithering;
44 
48 class QmmpAudioEngine : public AbstractEngine
49 {
50 Q_OBJECT
51 public:
52  QmmpAudioEngine(QObject *parent);
53  ~QmmpAudioEngine();
54 
55  bool play() override;
56  bool enqueue(InputSource *source) override;
57  void seek(qint64 time) override;
58  void stop() override;
59  void pause() override;
60  void addEffect(EffectFactory *factory);
61  void removeEffect(EffectFactory *factory);
62 
63  static QmmpAudioEngine *instance();
64 
65 private slots:
66  void finish();
67  void updateReplayGainSettings();
68  void updateAudioSettings();
69  void updateEqSettings();
70 
71 private:
72  void run() override;
73  void reset();
74  void clearDecoders();
75  void flush(bool = false);
76  void addOffset();
77  qint64 produceSound(unsigned char *data, qint64 size, quint32 brate);
78  void attachMetaData(Decoder *decoder, DecoderFactory *factory, InputSource *source);
79  OutputWriter *createOutput();
80  void prepareEffects(Decoder *d);
81 
82  DecoderFactory *m_factory = nullptr;
83  QList<Effect*> m_effects;
84  QList<Effect*> m_blockedEffects;
85  OutputWriter *m_output = nullptr;
86 
87  std::atomic_bool m_done, m_finish, m_user_stop;
88  uint m_bks = 0, m_sample_size = 0;
89  qint64 m_seekTime;
90  quint64 m_output_at, m_output_size = 0;
91  int m_bitrate;
92  unsigned char *m_output_buf = nullptr;
93  Decoder *m_decoder = nullptr;
94  QQueue <Decoder*> m_decoders;
95  QHash <Decoder*, InputSource*> m_inputs;
96  AudioParameters m_ap;
97  bool m_next;
98  QSharedPointer<TrackInfo> m_trackInfo;
99  static QmmpAudioEngine *m_instance;
100  ReplayGain *m_replayGain = nullptr;
101  QmmpSettings *m_settings;
102  AudioConverter *m_converter;
103  Dithering *m_dithering = nullptr;
104 };
105 
106 #endif // QMMPAUDIOENGINE_P_H
The AbstractEngine class provides the base interface class of audio audio engines.
Definition: abstractengine.h:40
virtual void stop()=0
virtual void pause()=0
virtual bool play()=0
virtual void seek(qint64 time)=0
virtual bool enqueue(InputSource *source)=0
The AbstractEngine class provides the internal audio converter.
Definition: audioconverter.h:31
The AudioParameters class keeps information about audio settings.
Definition: audioparameters.h:32
Input plugin interface (decoder factory).
Definition: decoderfactory.h:54
The Decoder class provides the base interface class of audio decoders.
Definition: decoder.h:26
Effect plugin interface (effect factory).
Definition: effectfactory.h:56
The Effect class provides the base interface class of audio effects.
Definition: effect.h:36
The InputSource class provides the base interface class of transports.
Definition: inputsource.h:39
The QmmpSettings class provides access to global settings.
Definition: qmmpsettings.h:36
The StateHandler class allows one to track information about playback progress.
Definition: statehandler.h:35