00001 /*************************************************************************** 00002 * Copyright (C) 2006-2010 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 SOUNDCORE_H 00021 #define SOUNDCORE_H 00022 00023 #include <QObject> 00024 #include <QString> 00025 #include "decoder.h" 00026 #include "output.h" 00027 #include "visual.h" 00028 #include "qmmp.h" 00029 #include "qmmpsettings.h" 00030 00031 class QIODevice; 00032 class VolumeControl; 00033 class AbstractEngine; 00034 class InputSource; 00035 00039 class SoundCore : public QObject 00040 { 00041 Q_OBJECT 00042 public: 00047 SoundCore(QObject *parent = 0); 00051 ~SoundCore(); 00055 qint64 totalTime() const; 00060 void setEQ(double bands[10], double preamp); 00064 void setEQEnabled(bool on); 00068 int leftVolume(); 00072 int rightVolume(); 00076 qint64 elapsed(); 00080 int bitrate(); 00084 quint32 frequency(); 00088 int precision(); 00092 int channels(); 00096 Qmmp::State state() const; 00100 QMap <Qmmp::MetaData, QString> metaData(); 00104 QString metaData(Qmmp::MetaData key); 00108 static SoundCore* instance(); 00109 00110 00111 public slots: 00117 void setVolume(int left, int right); 00123 bool play(const QString &source, bool queue = false, qint64 offset = -1); 00127 void stop(); 00131 void pause(); 00135 void seek(qint64 pos); 00139 const QString url(); 00140 00141 signals: 00146 void bufferingProgress(int progress); 00151 void elapsedChanged(qint64 time); 00156 void bitrateChanged(int bitrate); 00161 void frequencyChanged(quint32 frequency); 00166 void precisionChanged(int precision); 00171 void channelsChanged(int channels); 00175 void metaDataChanged (); 00179 void stateChanged (Qmmp::State newState); 00183 void finished(); 00189 void volumeChanged(int left, int right); 00193 void aboutToFinish(); 00194 00195 private slots: 00196 bool enqueue(InputSource *); 00197 void startPendingEngine(); 00198 void updateVolume(); 00199 00200 private: 00201 Decoder* m_decoder; 00202 QString m_url; 00203 uint m_error; 00204 bool m_paused; 00205 bool m_useEQ; 00206 bool m_update; 00207 bool m_block; 00208 double m_preamp; 00209 double m_bands[10]; 00210 Visual *m_vis; 00211 QList <Visual*> m_visuals; 00212 QWidget *m_parentWidget; 00213 static SoundCore* m_instance; 00214 StateHandler *m_handler; 00215 VolumeControl *m_volumeControl; 00216 AbstractEngine *m_engine; 00217 AbstractEngine *m_pendingEngine; 00218 QList<InputSource *> m_pendingSources; 00219 }; 00220 00221 #endif
1.5.9