Qmmp
outputwriter_p.h
1 /***************************************************************************
2  * Copyright (C) 2012-2019 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 OUTPUTWRITER_P_H
22 #define OUTPUTWRITER_P_H
23 
24 #include <QThread>
25 #include <QMutex>
26 #include "recycler_p.h"
27 #include "audioparameters.h"
28 #include "channelmap.h"
29 
30 class QTimer;
31 class QmmpSettings;
32 class StateHandler;
33 class Output;
34 class Effect;
35 class AudioConverter;
36 class ChannelConverter;
37 
42 class OutputWriter : public QThread
43 {
44  Q_OBJECT
45 public:
46  explicit OutputWriter(QObject *parent = 0);
47 
48  virtual ~OutputWriter();
55  bool initialize(quint32 freq, ChannelMap map);
59  void pause();
63  void stop();
68  void setMuted(bool muted);
72  void finish();
78  void seek(qint64 pos, bool reset = false);
82  Recycler *recycler();
86  QMutex *mutex();
90  AudioParameters audioParameters() const;
94  int sampleSize() const;
95  void updateEqSettings();
96 
97 private:
98  void run(); //thread run function
99  void status();
100  void dispatch(qint64 elapsed, int bitrate);
101  void dispatch(const Qmmp::State &state);
102  void dispatch(const AudioParameters &p);
103  void dispatchVisual(Buffer *buffer);
104  bool prepareConverters();
105  void startVisualization();
106  void stopVisualization();
107 
108  bool m_skip;
109  QMutex m_mutex;
110  Recycler m_recycler;
111  StateHandler *m_handler;
112  quint32 m_frequency;
113  int m_channels, m_kbps;
114  ChannelMap m_chan_map;
115  Qmmp::AudioFormat m_format;
116  qint64 m_bytesPerMillisecond;
117  bool m_user_stop, m_pause;
118  bool m_paused;
119  bool m_finish;
120  bool m_useEq;
121  qint64 m_totalWritten, m_currentMilliseconds;
122  QmmpSettings *m_settings;
123  Output *m_output;
124  bool m_muted;
125  AudioParameters m_in_params;
126  AudioConverter *m_format_converter;
127  ChannelConverter *m_channel_converter;
128  unsigned char *m_output_buf;
129  size_t m_output_size; //samples
130 };
131 
132 #endif // OUTPUTWRITER_P_H
The AbstractEngine class provides the internal audio converter.
Definition: audioconverter.h:30
State
Definition: qmmp.h:52
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
The StateHandler class allows one to track information about playback progress.
Definition: statehandler.h:34
The Output class provides the base interface class of audio outputs.
Definition: output.h:27
Audio buffer class.
Definition: buffer.h:20
AudioFormat
Definition: qmmp.h:105