![]() |
Mixxx
|
00001 /*************************************************************************** 00002 soundsourcemp3.h - description 00003 ------------------- 00004 begin : Wed Feb 20 2002 00005 copyright : (C) 2002 by Tue and Ken Haste Andersen 00006 email : 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef SOUNDSOURCEMP3_H 00019 #define SOUNDSOURCEMP3_H 00020 00021 #include <qobject.h> 00022 #include "defs.h" 00023 #include <stdio.h> 00024 #include <stdlib.h> 00025 00026 #ifdef WIN64 00027 #define FPM_64BIT // So mad.h doesn't try to use inline assembly which MSVC-x64 doesn't support 00028 #endif 00029 #include "mad.h" 00030 00031 #include "errno.h" 00032 #include "soundsource.h" 00033 #include <sys/types.h> 00034 #include <qfile.h> 00035 //#include <sys/stat.h> 00036 //#include <unistd.h> 00037 #include <id3tag.h> 00038 00039 #define READLENGTH 5000 00040 00042 typedef struct MadSeekFrameType { 00043 unsigned char *m_pStreamPos; 00044 long int pos; 00045 } MadSeekFrameType; 00046 00047 00052 class SoundSourceMp3 : public Mixxx::SoundSource { 00053 public: 00054 SoundSourceMp3(QString qFilename); 00055 ~SoundSourceMp3(); 00056 int open(); 00057 long seek(long); 00058 unsigned read(unsigned long size, const SAMPLE*); 00059 unsigned long discard(unsigned long size); 00061 inline long unsigned length(); 00062 int parseHeader(); 00063 static QList<QString> supportedFileExtensions(); 00064 00065 private: 00068 int findFrame(int pos); 00070 inline signed int madScale (mad_fixed_t sample); 00071 MadSeekFrameType* getSeekFrame(long frameIndex) const; 00072 00073 // Returns true if the loaded file is valid and usable to read audio. 00074 bool isValid() const; 00075 00076 QFile m_file; 00077 int bitrate; 00078 int framecount; 00079 int currentframe; 00081 mad_timer_t pos; 00082 mad_timer_t filelength; 00083 mad_stream *Stream; 00084 mad_frame *Frame; 00085 mad_synth *Synth; 00086 unsigned inputbuf_len; 00087 unsigned char *inputbuf; 00088 00090 int rest; 00092 int m_iChannels; 00093 00099 QList<MadSeekFrameType*> m_qSeekList; 00101 long m_currentSeekFrameIndex; 00103 int m_iAvgFrameSize; 00104 }; 00105 00106 00107 #endif