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