00001 /*************************************************************************** 00002 * Copyright (C) 2008-2011 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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 #ifndef STATEHANDLER_H 00021 #define STATEHANDLER_H 00022 00023 #include <QObject> 00024 #include <QMap> 00025 #include <QMutex> 00026 #include "abstractengine.h" 00027 #include "qmmp.h" 00028 00032 class StateHandler : public QObject 00033 { 00034 Q_OBJECT 00035 public: 00040 StateHandler(QObject *parent = 0); 00044 ~StateHandler(); 00053 virtual void dispatch(qint64 elapsed, 00054 int bitrate, 00055 quint32 frequency, 00056 int precision, 00057 int channels); 00061 virtual void dispatch(const QMap<Qmmp::MetaData, QString> &metaData); 00065 virtual void dispatch(Qmmp::State state); 00070 virtual void dispatchBuffer(int percent); 00074 qint64 elapsed(); 00078 int bitrate(); 00082 int frequency(); 00086 int sampleSize(); 00090 int channels(); 00094 Qmmp::State state() const; 00098 void sendNextTrackRequest(); 00099 void sendFinished(); 00103 static StateHandler* instance(); 00104 00105 signals: 00110 void elapsedChanged(qint64 time); 00115 void bitrateChanged(int bitrate); 00120 void frequencyChanged(quint32 frequency); 00125 void sampleSizeChanged(int size); 00130 void channelsChanged(int channels); 00135 void bufferingProgress(int progress); 00136 00137 00138 private: 00139 qint64 m_elapsed; 00140 quint32 m_frequency; 00141 bool m_sendAboutToFinish; 00142 int m_bitrate, m_precision, m_channels; 00143 static StateHandler* m_instance; 00144 QMap <Qmmp::MetaData, QString> m_metaData; 00145 Qmmp::State m_state; 00146 QMutex m_mutex; 00147 }; 00148 00149 #endif