CLAM-Development  1.4.0
AudioDevice.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program 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  *
20  */
21 #ifndef __AudioDevice__
22 #define __AudioDevice__
23 
24 #include "AudioManager.hxx"
25 #include "Audio.hxx"
26 
27 namespace CLAM{
28 
29 
30 
40 {
41  friend class AudioIn;
42  friend class AudioOut;
43  friend class AudioManager;
44 public:
48  struct TInfo
49  {
50  std::string mName;
51  std::string mArch;
61  unsigned int mNotifySize;
62 
64  TInfo() { Reset();}
65 
68  void Reset()
69  {
70  mName=mArch="";
72  }
73  };
74 
75  std::vector<AudioIn*> mInputs;
76  std::vector<AudioOut*> mOutputs;
77 
78  std::string mName;
83 
87  AudioDevice(const std::string& name)
88  {
89  mName = name;
91  mForceNChannels=false;
92  mAudioManager=0;
93  }
94 
96  virtual ~AudioDevice() { };
97 
99  virtual void Start(void) throw(Err) = 0;
101  virtual void Stop(void) throw(Err) = 0;
106  virtual void Read(Audio& audio,const int channelID) = 0;
107 
112  virtual void Write(const Audio& audio,const int channelID) = 0;
113 
117  virtual void GetInfo(TInfo&);
118 
124  virtual void SetNChannels(int channels);
125 
126 protected:
127 
128  bool Register(AudioManager* am,AudioIn& in);
129  bool Register(AudioManager* am,AudioOut& out);
130  void Unregister(AudioIn& in);
131  void Unregister(AudioOut& out);
132 
133  int SampleRate(void);
134  int Latency(void);
135  void SetLatency(int latency);
136 
137 private:
138  AudioManager* mAudioManager;
139  AudioManager& _AudioManager(void);
140  void _SetAudioManager(AudioManager* am);
141 };
142 
143 };//CLAM
144 
145 #endif
146