AudioIn.cxx

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 
00022 #include "AudioIn.hxx"
00023 #include "AudioManager.hxx"
00024 #include "ProcessingFactory.hxx"
00025 
00026 
00027 namespace CLAM
00028 {
00029 
00030 namespace Hidden
00031 {
00032         static const char * metadata[] = {
00033                 "key", "AudioIn",
00034 //              "category", "Audio I/O",
00035 //              "description", "AudioIn",
00036                 0
00037         };
00038         static FactoryRegistrator<ProcessingFactory, AudioIn> reg = metadata;
00039 }
00040 
00041 
00042 bool AudioIn::ConcreteConfigure(const ProcessingConfig& c)
00043 {
00044         CopyAsConcreteConfig(mConfig, c);
00045 
00046         if (mpDevice)
00047                 mpDevice->Unregister(*this);
00048 
00049         AudioManager *m;
00050 
00051         try {
00052                 m = &(AudioManager::Current());
00053         }
00054         catch (Err &e) {
00055                 ErrProcessingObj ne("AudioIn::ConcreteConfigure(): No AudioManager found.",this);
00056                 ne.Embed(e);
00057                 throw(ne);
00058         }
00059 
00060         bool res;
00061         try {
00062                 res = m->Register(*this);
00063         }
00064         catch (Err &e) {
00065                 AddConfigErrorMessage( e.what() );
00066                 res = false;
00067         }
00068 
00069         if (res == false)
00070                 AddConfigErrorMessage("AudioIn::ConcreteConfigure(): Failed to register in AudioManager.");
00071 
00072         mOutput.SetSize(mConfig.GetFrameSize());
00073 
00074         return res;
00075 }
00076 
00077 bool AudioIn::ConcreteStart(void) 
00078 {
00079         if (!mpDevice)
00080                 throw(Err("AudioIn::ConcreteStart(): No Device found!"));
00081         mpDevice->Start();
00082         return true;
00083 }
00084 
00085 void AudioIn::GetDeviceInfo(AudioDevice::TInfo &info) const
00086 {
00087         if (mpDevice)
00088                 mpDevice->GetInfo(info);
00089         else
00090                 info.Reset();
00091 }
00092 
00093 bool AudioIn::Do()
00094 {
00095         bool res = Do(mOutput.GetAudio());
00096         mOutput.Produce();
00097         return res;
00098 }
00099 
00100 }
00101 
Generated by  doxygen 1.6.3