Qmmp
/usr/src/RPM/BUILD/qmmp-0.8-svn/src/qmmp/outputwriter_p.h
00001 /***************************************************************************
00002  *   Copyright (C) 2012 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 
00029 class QTimer;
00030 class QmmpSettings;
00031 class StateHandler;
00032 class Output;
00033 
00038 class OutputWriter : public QThread
00039 {
00040     Q_OBJECT
00041 public:
00042     explicit OutputWriter(QObject *parent = 0);
00043 
00044     virtual ~OutputWriter();
00052     bool initialize(quint32 freq, int chan, Qmmp::AudioFormat format);
00056     void pause();
00060     void stop();
00065     void setMuted(bool muted);
00069     void finish();
00075     void seek(qint64 pos, bool reset = false);
00079     Recycler *recycler();
00083     QMutex *mutex();
00087     AudioParameters audioParameters() const;
00091     quint32 sampleRate();
00095     int channels();
00099     Qmmp::AudioFormat format() const;
00103     int sampleSize() const;
00104 
00105 private slots:
00106     void updateEqSettings();
00107 
00108 private:
00109     void run(); //thread run function
00110     void status();
00111     void dispatch(qint64 elapsed,
00112                   int bitrate,
00113                   int frequency,
00114                   int bits,
00115                   int channels);
00116     void dispatch(const Qmmp::State &state);
00117     void dispatchVisual(Buffer *buffer);
00118     void clearVisuals();
00119     bool m_skip;
00120     QMutex m_mutex;
00121     Recycler m_recycler;
00122     StateHandler *m_handler;
00123     quint32 m_frequency;
00124     int m_channels, m_kbps;
00125     Qmmp::AudioFormat m_format;
00126     qint64 m_bytesPerMillisecond;
00127     bool m_userStop, m_pause;
00128     bool m_prev_pause;
00129     bool m_finish;
00130     bool m_useEq, m_eqEnabled;
00131     qint64 m_totalWritten, m_currentMilliseconds;
00132     unsigned char *m_visBuffer;
00133     qint64 m_visBufferSize;
00134     QmmpSettings *m_settings;
00135     Output *m_output;
00136     bool m_muted;
00137 
00138 };
00139 
00140 #endif // OUTPUTWRITER_P_H
 All Classes Functions Variables Enumerations Enumerator