Qmmp
/usr/src/RPM/BUILD/qmmp-0.11-svn/src/qmmp/outputwriter_p.h
00001 /***************************************************************************
00002  *   Copyright (C) 2012-2015 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     void clearVisuals();
00121     bool prepareConverters();
00122 
00123     bool m_skip;
00124     QMutex m_mutex;
00125     Recycler m_recycler;
00126     StateHandler *m_handler;
00127     quint32 m_frequency;
00128     int m_channels, m_kbps;
00129     ChannelMap m_chan_map;
00130     Qmmp::AudioFormat m_format;
00131     qint64 m_bytesPerMillisecond;
00132     bool m_user_stop, m_pause;
00133     bool m_prev_pause;
00134     bool m_finish;
00135     bool m_useEq;
00136     qint64 m_totalWritten, m_currentMilliseconds;
00137     QmmpSettings *m_settings;
00138     Output *m_output;
00139     bool m_muted;
00140     AudioParameters m_in_params;
00141     AudioConverter *m_format_converter;
00142     ChannelConverter *m_channel_converter;
00143     unsigned char *m_output_buf;
00144     size_t m_output_at;
00145 };
00146 
00147 #endif // OUTPUTWRITER_P_H
 All Classes Functions Variables Enumerations Enumerator