AudioDevice.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 #ifndef __AudioDevice__
00022 #define __AudioDevice__
00023 
00024 #include "AudioManager.hxx"
00025 #include "Audio.hxx"
00026 
00027 namespace CLAM{
00028 
00029 
00030 
00039 class AudioDevice
00040 {
00041         friend class AudioIn;
00042         friend class AudioOut;
00043         friend class AudioManager;
00044 public:
00048         struct TInfo
00049         {
00050                 std::string mName;
00051                 std::string mArch;
00053                 int mNReadChannels;
00055                 int mNWriteChannels;
00059                 int mNChannels;
00060                 int mSampleRate;
00061                 unsigned int mNotifySize;
00062 
00064                 TInfo() { Reset();}
00065 
00068                 void Reset()
00069                 {
00070                         mName=mArch="";
00071                         mNChannels=mNReadChannels=mNWriteChannels=mSampleRate=mNotifySize=0;
00072                 }
00073         };
00074         
00075         std::vector<AudioIn*> mInputs;
00076         std::vector<AudioOut*> mOutputs;
00077         
00078         std::string mName;
00079         bool mForceNChannels;
00080         int mNChannels;
00081         int mNReadChannels;
00082         int mNWriteChannels;
00083         
00087         AudioDevice(const std::string& name)
00088         {
00089                 mName = name;
00090                 mNChannels = mNReadChannels = mNWriteChannels = 0;
00091                 mForceNChannels=false;
00092                 mAudioManager=0;
00093         }
00094         
00096         virtual ~AudioDevice() { };
00097         
00099         virtual void Start(void) throw(Err) = 0;
00101         virtual void Stop(void) throw(Err) = 0;
00106         virtual void Read(Audio& audio,const int channelID) = 0;
00107 
00112         virtual void Write(const Audio& audio,const int channelID) = 0;
00113         
00117         virtual void GetInfo(TInfo&);
00118 
00124         virtual void SetNChannels(int channels);
00125         
00126 protected:
00127         
00128         bool Register(AudioManager* am,AudioIn& in);
00129         bool Register(AudioManager* am,AudioOut& out);
00130         void Unregister(AudioIn& in);
00131         void Unregister(AudioOut& out);
00132         
00133         int SampleRate(void);
00134         int Latency(void);
00135         void SetLatency(int latency);
00136 
00137 private:
00138         AudioManager* mAudioManager;
00139         AudioManager& _AudioManager(void);
00140         void _SetAudioManager(AudioManager* am);
00141 };
00142 
00143 };//CLAM
00144 
00145 #endif
00146 
Generated by  doxygen 1.6.3