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 "trackinfo.h"
29 #include "audioparameters.h"
30 
31 class QIODevice;
32 class OutputWriter;
33 class Effect;
34 class DecoderFactory;
35 class StateHandler;
36 class Decoder;
37 class InputSource;
38 class EffectFactory;
39 class ReplayGain;
40 class QmmpSettings;
41 class AudioConverter;
42 class Dithering;
43 
47 class QmmpAudioEngine : public AbstractEngine
48 {
49 Q_OBJECT
50 public:
51  QmmpAudioEngine(QObject *parent);
52  ~QmmpAudioEngine();
53 
54  bool play();
55  bool enqueue(InputSource *source);
56  void seek(qint64 time);
57  void stop();
58  void pause();
59  void setMuted(bool muted);
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();
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;
83  QList <Effect*> m_effects;
84  QList <Effect*> m_blockedEffects;
85  OutputWriter *m_output;
86 
87  bool m_done, m_finish, m_user_stop;
88  uint m_bks, m_sample_size;
89  qint64 m_seekTime;
90  quint64 m_output_at, m_output_size;
91  int m_bitrate;
92  unsigned char *m_output_buf;
93  Decoder *m_decoder;
94  QQueue <Decoder*> m_decoders;
95  QHash <Decoder*, InputSource*> m_inputs;
96  AudioParameters m_ap;
97  bool m_next;
98  bool m_muted;
99  QSharedPointer<TrackInfo> m_trackInfo;
100  static QmmpAudioEngine *m_instance;
101  ReplayGain *m_replayGain;
102  QmmpSettings *m_settings;
103  AudioConverter *m_converter;
104  Dithering *m_dithering;
105 };
106 
107 #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:64
The Decoder class provides the base interface class of audio decoders.
Definition: decoder.h:25
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:39
virtual bool enqueue(InputSource *source)=0
virtual bool play()=0
virtual void stop()=0