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