nathan@0: /* nathan@0: * MP3/MPlayer plugin to VDR (C++) nathan@0: * nathan@0: * (C) 2001-2005 Stefan Huelswitt nathan@0: * nathan@0: * This code is free software; you can redistribute it and/or nathan@0: * modify it under the terms of the GNU General Public License nathan@0: * as published by the Free Software Foundation; either version 2 nathan@0: * of the License, or (at your option) any later version. nathan@0: * nathan@0: * This code is distributed in the hope that it will be useful, nathan@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of nathan@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the nathan@0: * GNU General Public License for more details. nathan@0: * nathan@0: * You should have received a copy of the GNU General Public License nathan@0: * along with this program; if not, write to the Free Software nathan@0: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. nathan@0: * Or, point your browser to http://www.gnu.org/copyleft/gpl.html nathan@0: */ nathan@0: nathan@0: #ifndef ___DECODER_SND_H nathan@0: #define ___DECODER_SND_H nathan@0: nathan@0: #define DEC_SND DEC_ID('S','N','D',' ') nathan@0: #define DEC_SND_STR "SND" nathan@0: nathan@0: #ifdef HAVE_SNDFILE nathan@0: nathan@0: #include nathan@0: #include nathan@0: #include nathan@0: nathan@0: #include nathan@0: nathan@0: #include "decoder.h" nathan@0: #include "decoder-core.h" nathan@0: nathan@0: #define CDFS_MAGIC 0xCDDA // cdfs filesystem-ID nathan@0: nathan@0: class cDiscID; nathan@0: nathan@0: // ---------------------------------------------------------------- nathan@0: nathan@0: class cSndFile : public cFileInfo { nathan@0: private: nathan@0: SNDFILE *sf; nathan@0: // nathan@0: void Error(const char *action); nathan@0: public: nathan@0: SF_INFO sfi; nathan@0: // nathan@0: cSndFile(const char *Filename); nathan@0: ~cSndFile(); nathan@0: bool Open(bool log=true); nathan@0: void Close(void); nathan@0: sf_count_t Seek(sf_count_t frames=0, bool relativ=false); nathan@0: sf_count_t Stream(int *buffer, sf_count_t frames); nathan@0: }; nathan@0: nathan@0: // ---------------------------------------------------------------- nathan@0: nathan@0: class cSndInfo : public cSongInfo { nathan@0: private: nathan@0: cSndFile *file; nathan@0: cDiscID *id; nathan@0: bool keepOpen; nathan@0: // nathan@0: bool Abort(bool result); nathan@0: bool CDDBLookup(const char *filename); nathan@0: public: nathan@0: cSndInfo(cSndFile *File); nathan@0: ~cSndInfo(); nathan@0: bool DoScan(bool KeepOpen=false); nathan@0: }; nathan@0: nathan@0: // ---------------------------------------------------------------- nathan@0: nathan@0: class cSndDecoder : public cDecoder, public cThread { nathan@0: private: nathan@0: cSndFile file; nathan@0: cSndInfo info; nathan@0: struct Decode ds; nathan@0: struct mad_pcm *pcm; nathan@0: unsigned long long index; nathan@0: // nathan@0: cMutex buffMutex; nathan@0: cCondVar fgCond, bgCond; nathan@0: bool run, ready; nathan@0: int *framebuff, deferedN, softCount; nathan@0: // nathan@0: void Init(void); nathan@0: bool Clean(void); nathan@0: bool GetInfo(bool keepOpen); nathan@0: struct Decode *Done(eDecodeStatus status); nathan@0: protected: nathan@0: virtual void Action(void); nathan@0: public: nathan@0: cSndDecoder(const char *Filename); nathan@0: ~cSndDecoder(); nathan@0: virtual bool Valid(void); nathan@0: virtual cFileInfo *FileInfo(void); nathan@0: virtual cSongInfo *SongInfo(bool get); nathan@0: virtual cPlayInfo *PlayInfo(void); nathan@0: virtual bool Start(void); nathan@0: virtual bool Stop(void); nathan@0: virtual bool Skip(int Seconds, float bsecs); nathan@0: virtual struct Decode *Decode(void); nathan@0: }; nathan@0: nathan@0: // ---------------------------------------------------------------- nathan@0: nathan@0: #endif //HAVE_SNDFILE nathan@0: #endif //___DECODER_SND_H