TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
outputwriter_p.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2012-2024 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 <atomic>
27 #include "recycler_p.h"
28 #include "audioparameters.h"
29 #include "channelmap.h"
30 
31 class QTimer;
32 class QmmpSettings;
33 class StateHandler;
34 class Output;
35 class Effect;
36 class AudioConverter;
37 class ChannelConverter;
38 
43 class QMMP_EXPORT OutputWriter : public QThread
44 {
45  Q_OBJECT
46 public:
47  explicit OutputWriter(QObject *parent = nullptr);
48 
49  virtual ~OutputWriter();
50 
57  bool initialize(quint32 freq, ChannelMap map);
61  void pause();
65  void stop();
69  void finish();
75  void seek(qint64 time, bool reset = false);
79  Recycler *recycler();
83  const AudioParameters &inputAudioParameters() const;
87  AudioParameters outputAudioParameters() const;
91  int sampleSize() const;
95  void updateEqSettings();
96 
97 private:
98  virtual void run() override final; //thread run function
99 
100  void status();
101  void dispatch(qint64 elapsed, int bitrate);
102  void dispatch(const Qmmp::State &state);
103  void dispatch(const AudioParameters &p);
104  void dispatchVisual(Buffer *buffer);
105  bool prepareConverters();
106  void startVisualization();
107  void stopVisualization();
108 
109  bool m_skip = false;
110  QMutex m_mutex;
113  quint32 m_frequency = 0;
114  int m_channels = 0, m_kbps = 0;
117  qint64 m_bytesPerMillisecond = 0;
118  std::atomic_bool m_user_stop = ATOMIC_VAR_INIT(false);
119  std::atomic_bool m_pause = ATOMIC_VAR_INIT(false);
120  std::atomic_bool m_muted = ATOMIC_VAR_INIT(false);
121  std::atomic_bool m_finish = ATOMIC_VAR_INIT(false);
122  bool m_paused = false;
123  bool m_useEq = false;
124  bool m_abr = false;
125  qint64 m_totalWritten = 0, m_currentMilliseconds = -1;
126  QmmpSettings *m_settings = nullptr;
127  Output *m_output = nullptr;
129  AudioConverter *m_format_converter = nullptr;
130  ChannelConverter *m_channel_converter = nullptr;
131  unsigned char *m_output_buf = nullptr;
132  size_t m_output_size = 0; //samples
133 
134 };
135 
136 #endif
The AbstractEngine class provides the internal audio converter.
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:36
The AudioParameters class keeps information about audio settings.
The StateHandler class allows one to track information about playback progress.
Definition: statehandler.h:32
Recycler m_recycler
The Output class provides the base interface class of audio outputs.
Definition: output.h:39
This class represents audio channel mapping.
Definition: channelmap.h:30
StateHandler * m_handler
State
Definition: qmmp.h:76
ChannelMap m_chan_map
#define QMMP_EXPORT
Definition: qmmp_export.h:29
Audio buffer class.
Definition: buffer.h:33
AudioParameters m_in_params
AudioFormat
Definition: qmmp.h:129
state
Definition: http_parser.c:279