summaryrefslogtreecommitdiff
path: root/audio.h
blob: f99a84ae06783c98ea0129e6574c2f02b1347a14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * audio.h: The basic audio interface
 *
 * See the main source file 'vdr.c' for copyright information and
 * how to reach the author.
 *
 * $Id: audio.h 2.1 2008/07/06 11:39:21 kls Exp $
 */

#ifndef __AUDIO_H
#define __AUDIO_H

#include "thread.h"
#include "tools.h"

class cAudio : public cListObject {
protected:
  cAudio(void);
public:
  virtual ~cAudio();
  virtual void Play(const uchar *Data, int Length, uchar Id) = 0;
       ///< Plays the given block of audio Data. Must return as soon as possible.
       ///< If the entire block of data can't be processed immediately, it must
       ///< be copied and processed in a separate thread. The Data is always a
       ///< complete PES audio packet. Id indicates the type of audio data this
       ///< packet holds.
  virtual void PlayTs(const uchar *Data, int Length) = 0;
       ///< Plays the given block of audio Data. Must return as soon as possible.
       ///< If the entire block of data can't be processed immediately, it must
       ///< be copied and processed in a separate thread. The Data is always a
       ///< complete TS audio packet.
  virtual void Mute(bool On) = 0;
       ///< Immediately sets the audio device to be silent (On==true) or to
       ///< normal replay (On==false).
  virtual void Clear(void) = 0;
       ///< Clears all data that might still be awaiting processing.
  };

class cAudios : public cList<cAudio> {
public:
  void PlayAudio(const uchar *Data, int Length, uchar Id);
  void PlayTsAudio(const uchar *Data, int Length);
  void MuteAudio(bool On);
  void ClearAudio(void);
  };

extern cAudios Audios;

class cExternalAudio : public cAudio {
private:
  char *command;
  cPipe pipe;
  bool mute;
public:
  cExternalAudio(const char *Command);
  virtual ~cExternalAudio();
  virtual void Play(const uchar *Data, int Length, uchar Id);
  virtual void PlayTs(const uchar *Data, int Length);
  virtual void Mute(bool On);
  virtual void Clear(void);
  };

#endif //__AUDIO_H