00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GLUON_AUDIO_MUSIC_H
00020 #define GLUON_AUDIO_MUSIC_H
00021
00022 #include <QtCore/QThread>
00023 #include <cstring>
00024 #include <cstdio>
00025
00026 #include <al.h>
00027 #include <vorbis/vorbisfile.h>
00028
00029 #include "gluon_audio_export.h"
00030
00031
00032 namespace GluonAudio
00033 {
00034 class GLUON_AUDIO_EXPORT Music : public QThread
00035 {
00036 Q_OBJECT
00037
00038 public:
00039 Music( QString fileName = QString() );
00040 void run();
00041 bool isPlaying() const;
00042
00043 public Q_SLOTS:
00044 void play()
00045 {
00046 run();
00047 }
00048
00049 private Q_SLOTS:
00050 void playThread()
00051 {
00052 start();
00053 }
00054
00055 protected:
00056 void open( std::string path );
00057 void release();
00058 void display();
00059 bool playback();
00060 bool update();
00061
00062 void setFileName( QString f )
00063 {
00064 m_fileName = f;
00065 }
00066
00067 bool stream( ALuint buffer );
00068 void empty();
00069 void check();
00070 std::string errorString( int code );
00071
00072 private:
00073 FILE* oggFile;
00074 OggVorbis_File oggStream;
00075 vorbis_info* vorbisInfo;
00076 vorbis_comment* vorbisComment;
00077
00078 ALuint buffers[2];
00079 ALuint source;
00080 ALenum format;
00081
00082 QString m_fileName;
00083 };
00084 }
00085
00086 #endif // GLUON_AUDIO_MUSIC_H