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  const AudioParameters &inputAudioParameters() const;
94  AudioParameters outputAudioParameters() const;
98  int sampleSize() const;
99  void updateEqSettings();
100 
101 private:
102  void run(); //thread run function
103  void status();
104  void dispatch(qint64 elapsed, int bitrate);
105  void dispatch(const Qmmp::State &state);
106  void dispatch(const AudioParameters &p);
107  void dispatchVisual(Buffer *buffer);
108  bool prepareConverters();
109  void startVisualization();
110  void stopVisualization();
111 
112  bool m_skip;
113  QMutex m_mutex;
114  Recycler m_recycler;
115  StateHandler *m_handler;
116  quint32 m_frequency;
117  int m_channels, m_kbps;
118  ChannelMap m_chan_map;
119  Qmmp::AudioFormat m_format;
120  qint64 m_bytesPerMillisecond;
121  bool m_user_stop, m_pause;
122  bool m_paused;
123  bool m_finish;
124  bool m_useEq;
125  qint64 m_totalWritten, m_currentMilliseconds;
126  QmmpSettings *m_settings;
127  Output *m_output;
128  bool m_muted;
129  AudioParameters m_in_params;
130  AudioConverter *m_format_converter;
131  ChannelConverter *m_channel_converter;
132  unsigned char *m_output_buf;
133  size_t m_output_size; //samples
134 };
135 
136 #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
This class represents audio channel mapping.
Definition: channelmap.h:30
Audio buffer class.
Definition: buffer.h:20
AudioFormat
Definition: qmmp.h:105