Qmmp
outputwriter_p.h
1 /***************************************************************************
2  * Copyright (C) 2012-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 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  quint32 sampleRate();
98  int channels();
102  Qmmp::AudioFormat format() const;
103  const ChannelMap channelMap() const;
107  int sampleSize() const;
108  void updateEqSettings();
109 
110 private:
111  void run(); //thread run function
112  void status();
113  void dispatch(qint64 elapsed, int bitrate);
114  void dispatch(const Qmmp::State &state);
115  void dispatch(const AudioParameters &p);
116  void dispatchVisual(Buffer *buffer);
117  bool prepareConverters();
118  void startVisualization();
119  void stopVisualization();
120 
121  bool m_skip;
122  QMutex m_mutex;
123  Recycler m_recycler;
124  StateHandler *m_handler;
125  quint32 m_frequency;
126  int m_channels, m_kbps;
127  ChannelMap m_chan_map;
128  Qmmp::AudioFormat m_format;
129  qint64 m_bytesPerMillisecond;
130  bool m_user_stop, m_pause;
131  bool m_prev_pause;
132  bool m_finish;
133  bool m_useEq;
134  qint64 m_totalWritten, m_currentMilliseconds;
135  QmmpSettings *m_settings;
136  Output *m_output;
137  bool m_muted;
138  AudioParameters m_in_params;
139  AudioConverter *m_format_converter;
140  ChannelConverter *m_channel_converter;
141  unsigned char *m_output_buf;
142  size_t m_output_size; //samples
143 };
144 
145 #endif // OUTPUTWRITER_P_H
The AbstractEngine class provides the internal audio converter.
Definition: audioconverter.h:30
State
Definition: qmmp.h:51
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:26
Audio buffer class.
Definition: buffer.h:20
AudioFormat
Definition: qmmp.h:91