TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
qmmpaudioengine_p.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2009-2024 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 
49 {
50  Q_OBJECT
51 public:
52  explicit QmmpAudioEngine(QObject *parent);
53  virtual ~QmmpAudioEngine();
54 
55  virtual bool play() override final;
56  virtual bool enqueue(InputSource *source) override final;
57  virtual void seek(qint64 time) override final;
58  virtual void stop() override final;
59  virtual void pause() override final;
60 
61  void addEffect(EffectFactory *factory);
62  void removeEffect(EffectFactory *factory);
63 
64  static QmmpAudioEngine *instance();
65 
66 private slots:
67  void finish();
68  void updateReplayGainSettings();
69  void updateAudioSettings();
70  void updateEqSettings();
71 
72 private:
73  virtual void run() override final;
74  void reset();
75  void clearDecoders();
76  void flush(bool = false);
77  void addOffset();
78  qint64 produceSound(unsigned char *data, qint64 size, quint32 brate);
79  void attachMetaData(Decoder *decoder, DecoderFactory *factory, InputSource *source);
80  OutputWriter *createOutput();
81  void prepareEffects(Decoder *d);
82 
83  DecoderFactory *m_factory = nullptr;
84  QList<Effect*> m_effects;
85  QList<Effect*> m_blockedEffects;
86  OutputWriter *m_output = nullptr;
87 
88  std::atomic_bool m_done, m_finish, m_user_stop;
89  uint m_bks = 0, m_sample_size = 0;
90  qint64 m_seekTime = -1;
91  quint64 m_output_at = 0, m_output_size = 0;
92  int m_bitrate = 0;
93  unsigned char *m_output_buf = nullptr;
94  Decoder *m_decoder = nullptr;
95  QQueue <Decoder*> m_decoders;
96  QHash<Decoder*, InputSource*> m_inputs;
98  bool m_next = false;
99  QSharedPointer<TrackInfo> m_trackInfo;
101  ReplayGain *m_replayGain = nullptr;
102  QmmpSettings *m_settings = nullptr;
103  AudioConverter *m_converter = nullptr;
104  Dithering *m_dithering = nullptr;
105 
106 };
107 
108 #endif
virtual void stop()=0
The AbstractEngine class provides the internal audio converter.
The QmmpSettings class provides access to global settings.
Definition: qmmpsettings.h:35
virtual void seek(qint64 time)=0
voidpf void uLong size
Definition: ioapi.h:136
The Effect class provides the base interface class of audio effects.
Definition: effect.h:36
The AudioParameters class keeps information about audio settings.
The StateHandler class allows one to track information about playback progress.
Definition: statehandler.h:32
Effect plugin interface (effect factory).
Definition: effectfactory.h:54
The InputSource class provides the base interface class of transports.
Definition: inputsource.h:35
QHash< Decoder *, InputSource * > m_inputs
Input plugin interface (decoder factory).
QList< Effect * > m_blockedEffects
The Decoder class provides the base interface class of audio decoders.
Definition: decoder.h:38
QList< Effect * > m_effects
static QmmpAudioEngine * m_instance
virtual bool play()=0
The AbstractEngine class provides the base interface class of audio audio engines.
#define QMMP_EXPORT
Definition: qmmp_export.h:29
virtual void pause()=0
QQueue< Decoder * > m_decoders
std::atomic_bool m_user_stop
AudioParameters m_ap
virtual bool enqueue(InputSource *source)=0
QSharedPointer< TrackInfo > m_trackInfo