Qmmp
|
00001 /*************************************************************************** 00002 * Copyright (C) 2012-2017 by Ilya Kotov * 00003 * forkotov02@hotmail.ru * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 00019 ***************************************************************************/ 00020 00021 #ifndef OUTPUTWRITER_P_H 00022 #define OUTPUTWRITER_P_H 00023 00024 #include <QThread> 00025 #include <QMutex> 00026 #include "recycler_p.h" 00027 #include "audioparameters.h" 00028 #include "channelmap.h" 00029 00030 class QTimer; 00031 class QmmpSettings; 00032 class StateHandler; 00033 class Output; 00034 class Effect; 00035 class AudioConverter; 00036 class ChannelConverter; 00037 00042 class OutputWriter : public QThread 00043 { 00044 Q_OBJECT 00045 public: 00046 explicit OutputWriter(QObject *parent = 0); 00047 00048 virtual ~OutputWriter(); 00055 bool initialize(quint32 freq, ChannelMap map); 00059 void pause(); 00063 void stop(); 00068 void setMuted(bool muted); 00072 void finish(); 00078 void seek(qint64 pos, bool reset = false); 00082 Recycler *recycler(); 00086 QMutex *mutex(); 00090 AudioParameters audioParameters() const; 00094 quint32 sampleRate(); 00098 int channels(); 00102 Qmmp::AudioFormat format() const; 00103 const ChannelMap channelMap() const; 00107 int sampleSize() const; 00108 void updateEqSettings(); 00109 00110 private: 00111 void run(); //thread run function 00112 void status(); 00113 void dispatch(qint64 elapsed, 00114 int bitrate, 00115 int frequency, 00116 int bits, 00117 int channels); 00118 void dispatch(const Qmmp::State &state); 00119 void dispatchVisual(Buffer *buffer); 00120 bool prepareConverters(); 00121 void startVisualization(); 00122 void stopVisualization(); 00123 00124 bool m_skip; 00125 QMutex m_mutex; 00126 Recycler m_recycler; 00127 StateHandler *m_handler; 00128 quint32 m_frequency; 00129 int m_channels, m_kbps; 00130 ChannelMap m_chan_map; 00131 Qmmp::AudioFormat m_format; 00132 qint64 m_bytesPerMillisecond; 00133 bool m_user_stop, m_pause; 00134 bool m_prev_pause; 00135 bool m_finish; 00136 bool m_useEq; 00137 qint64 m_totalWritten, m_currentMilliseconds; 00138 QmmpSettings *m_settings; 00139 Output *m_output; 00140 bool m_muted; 00141 AudioParameters m_in_params; 00142 AudioConverter *m_format_converter; 00143 ChannelConverter *m_channel_converter; 00144 unsigned char *m_output_buf; 00145 size_t m_output_size; //samples 00146 }; 00147 00148 #endif // OUTPUTWRITER_P_H