CLAM-Development  1.4.0
AudioIn.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 
22 
23 
24 #ifndef __AudioIn__
25 #define __AudioIn__
26 
27 #include "AudioIO.hxx"
28 #include "Processing.hxx"
29 #include "Audio.hxx"
30 #include "AudioOutPort.hxx"
31 #include "AudioDevice.hxx"
32 
33 
34 namespace CLAM{
35 
39 class AudioIn: public Processing
40 {
41 friend class AudioManager;
42 friend class AudioDevice;
43 private:
44  AudioIOConfig mConfig;
45  AudioDevice* mpDevice;
46 public:
48 
54  bool ConcreteConfigure(const ProcessingConfig& c);
55 
59  const ProcessingConfig &GetConfig() const { return mConfig;}
60 
63  AudioIn() :mOutput( "Audio Output",this ) { mpDevice = 0; Configure(AudioIOConfig()); }
64 
68  AudioIn(const AudioIOConfig &c) : mOutput( "Audio Output",this ) { mpDevice = 0; Configure(c); }
70  ~AudioIn() { if (mpDevice) mpDevice->Unregister(*this); }
71 
72  const char * GetClassName() const {return "AudioIn";}
73 
76  bool Do(void);
77 
82  bool Do(Audio& data)
83  {
84  if (!AbleToExecute()) return true; // object was disabled
85 
86  mpDevice->Read(data,mConfig.GetChannelID());
87  return true;
88  }
89 
93  void GetDeviceInfo(AudioDevice::TInfo &) const;
94 
95  int GetChannelID() const {return mConfig.GetChannelID();}
96 
99  bool IsSyncSource() const { return true; }
100 
101 protected:
102  bool ConcreteStart(void);
103 };
104 
105 
106 };//CLAM
107 #endif // __AudioIn__
108