decoder-snd.h
author nathan
Sat, 29 Dec 2007 14:49:09 +0100
branchtrunk
changeset 2 4c1f7b705009
parent 0 474a1293c3c0
permissions -rw-r--r--
release 0.10.1
     1 /*
     2  * MP3/MPlayer plugin to VDR (C++)
     3  *
     4  * (C) 2001-2005 Stefan Huelswitt <s.huelswitt@gmx.de>
     5  *
     6  * This code is free software; you can redistribute it and/or
     7  * modify it under the terms of the GNU General Public License
     8  * as published by the Free Software Foundation; either version 2
     9  * of the License, or (at your option) any later version.
    10  *
    11  * This code is distributed in the hope that it will be useful,
    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  * GNU General Public License for more details.
    15  *
    16  * You should have received a copy of the GNU General Public License
    17  * along with this program; if not, write to the Free Software
    18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    19  * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
    20  */
    21 
    22 #ifndef ___DECODER_SND_H
    23 #define ___DECODER_SND_H
    24 
    25 #define DEC_SND     DEC_ID('S','N','D',' ')
    26 #define DEC_SND_STR "SND"
    27 
    28 #ifdef HAVE_SNDFILE
    29 
    30 #include <time.h>
    31 #include <mad.h>
    32 #include <sndfile.h>
    33 
    34 #include <vdr/thread.h>
    35 
    36 #include "decoder.h"
    37 #include "decoder-core.h"
    38 
    39 #define CDFS_MAGIC 0xCDDA // cdfs filesystem-ID
    40 
    41 class cDiscID;
    42 
    43 // ----------------------------------------------------------------
    44 
    45 class cSndFile : public cFileInfo {
    46 private:
    47   SNDFILE *sf;
    48   //
    49   void Error(const char *action);
    50 public:
    51   SF_INFO sfi;
    52   //
    53   cSndFile(const char *Filename);
    54   ~cSndFile();
    55   bool Open(bool log=true);
    56   void Close(void);
    57   sf_count_t Seek(sf_count_t frames=0, bool relativ=false);
    58   sf_count_t Stream(int *buffer, sf_count_t frames);
    59   };
    60 
    61 // ----------------------------------------------------------------
    62 
    63 class cSndInfo : public cSongInfo {
    64 private:
    65   cSndFile *file;
    66   cDiscID *id;
    67   bool keepOpen;
    68   //
    69   bool Abort(bool result);
    70   bool CDDBLookup(const char *filename);
    71 public:
    72   cSndInfo(cSndFile *File);
    73   ~cSndInfo();
    74   bool DoScan(bool KeepOpen=false);
    75   };
    76 
    77 // ----------------------------------------------------------------
    78 
    79 class cSndDecoder : public cDecoder, public cThread {
    80 private:
    81   cSndFile file;
    82   cSndInfo info;
    83   struct Decode ds;
    84   struct mad_pcm *pcm;
    85   unsigned long long index;
    86   //
    87   cMutex buffMutex;
    88   cCondVar fgCond, bgCond;
    89   bool run, ready;
    90   int *framebuff, deferedN, softCount;
    91   //
    92   void Init(void);
    93   bool Clean(void);
    94   bool GetInfo(bool keepOpen);
    95   struct Decode *Done(eDecodeStatus status);
    96 protected:
    97   virtual void Action(void);
    98 public:
    99   cSndDecoder(const char *Filename);
   100   ~cSndDecoder();
   101   virtual bool Valid(void);
   102   virtual cFileInfo *FileInfo(void);
   103   virtual cSongInfo *SongInfo(bool get);
   104   virtual cPlayInfo *PlayInfo(void);
   105   virtual bool Start(void);
   106   virtual bool Stop(void);
   107   virtual bool Skip(int Seconds, float bsecs);
   108   virtual struct Decode *Decode(void);
   109   };
   110 
   111 // ----------------------------------------------------------------
   112 
   113 #endif //HAVE_SNDFILE
   114 #endif //___DECODER_SND_H