Qmmp
Loading...
Searching...
No Matches
outputwriter_p.h
1/***************************************************************************
2 * Copyright (C) 2012-2022 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
31class QTimer;
32class QmmpSettings;
33class StateHandler;
34class Output;
35class Effect;
36class AudioConverter;
37class ChannelConverter;
38
43class OutputWriter : public QThread
44{
45 Q_OBJECT
46public:
47 explicit OutputWriter(QObject *parent = nullptr);
48
49 virtual ~OutputWriter();
56 bool initialize(quint32 freq, ChannelMap map);
60 void pause();
64 void stop();
68 void finish();
74 void seek(qint64 pos, bool reset = false);
78 Recycler *recycler();
82 const AudioParameters &inputAudioParameters() const;
86 AudioParameters outputAudioParameters() const;
90 int sampleSize() const;
91 void updateEqSettings();
92
93private:
94 void run() override; //thread run function
95 void status();
96 void dispatch(qint64 elapsed, int bitrate);
97 void dispatch(const Qmmp::State &state);
98 void dispatch(const AudioParameters &p);
99 void dispatchVisual(Buffer *buffer);
100 bool prepareConverters();
101 void startVisualization();
102 void stopVisualization();
103
104 bool m_skip = false;
105 QMutex m_mutex;
106 Recycler m_recycler;
107 StateHandler *m_handler;
108 quint32 m_frequency = 0;
109 int m_channels = 0, m_kbps = 0;
110 ChannelMap m_chan_map;
112 qint64 m_bytesPerMillisecond = 0;
113 std::atomic_bool m_user_stop = ATOMIC_VAR_INIT(false);
114 std::atomic_bool m_pause = ATOMIC_VAR_INIT(false);
115 std::atomic_bool m_muted = ATOMIC_VAR_INIT(false);
116 std::atomic_bool m_finish = ATOMIC_VAR_INIT(false);
117 bool m_paused = false;
118 bool m_useEq = false;
119 bool m_abr = false;
120 qint64 m_totalWritten = 0, m_currentMilliseconds = -1;
121 QmmpSettings *m_settings;
122 Output *m_output = nullptr;
123 AudioParameters m_in_params;
124 AudioConverter *m_format_converter = nullptr;
125 ChannelConverter *m_channel_converter = nullptr;
126 unsigned char *m_output_buf = nullptr;
127 size_t m_output_size = 0; //samples
128};
129
130#endif // OUTPUTWRITER_P_H
The AbstractEngine class provides the internal audio converter.
Definition audioconverter.h:31
The AudioParameters class keeps information about audio settings.
Definition audioparameters.h:32
Audio buffer class.
Definition buffer.h:21
This class represents audio channel mapping.
Definition channelmap.h:31
The Effect class provides the base interface class of audio effects.
Definition effect.h:36
The Output class provides the base interface class of audio outputs.
Definition output.h:28
State
Definition qmmp.h:62
AudioFormat
Definition qmmp.h:115
@ PCM_UNKNOWN
Definition qmmp.h:116
The QmmpSettings class provides access to global settings.
Definition qmmpsettings.h:36
The StateHandler class allows one to track information about playback progress.
Definition statehandler.h:35