00001 /* 00002 * Copyright: (C) 1999-2001 Bruce W. Forsberg 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Bruce Forsberg forsberg@tns.net 00019 * 00020 */ 00021 00022 #ifndef _AFLIBAUDIO_H 00023 #define _AFLIBAUDIO_H 00024 00025 #include "aflib.h" 00026 #include "aflibChain.h" 00027 #include "aflibMemCache.h" 00028 #include "aflibConfig.h" 00029 00030 #include <list> 00031 00032 00070 class aflibData; 00071 class aflibAudioSampleRateCvt; 00072 class aflibAudioMixer; 00073 00074 00075 class aflibAudio : public aflibChain, public aflibMemCache { 00076 00077 public: 00078 00079 virtual 00080 ~aflibAudio(); 00081 00082 void 00083 enable(bool enable); 00084 00085 bool 00086 getEnable() const; 00087 00088 void 00089 enableDataSizeConversion(bool enable); 00090 00091 void 00092 enableEndianConversion(bool enable); 00093 00094 void 00095 enableSampleRateConversion(bool enable); 00096 00097 void 00098 enableChannelsConversion(bool enable); 00099 00100 virtual void 00101 setInputConfig(const aflibConfig& cfg); 00102 00103 virtual const aflibConfig& 00104 getInputConfig() const; 00105 00106 virtual void 00107 setOutputConfig(const aflibConfig& cfg); 00108 00109 virtual const aflibConfig& 00110 getOutputConfig() const; 00111 00113 virtual const char * 00114 getName() const = 0 ; 00115 00117 virtual aflibStatus 00118 compute_segment( 00119 list<aflibData *>& data, 00120 long long position = -1) = 0; 00121 00122 virtual aflibData * 00123 process( 00124 aflibStatus& ret_status, 00125 long long position, 00126 int& num_samples, 00127 bool free_memory = TRUE); 00128 00129 protected: 00130 00131 aflibAudio(); 00132 aflibAudio(aflibAudio& audio); 00133 00134 void 00135 convertSampleRate(aflibAudio& parent); 00136 00137 void 00138 convertChannels(aflibAudio& parent); 00139 00140 void 00141 convertData(aflibData& data); 00142 00143 void 00144 examineChain(); 00145 00146 bool 00147 checkChain(const aflibAudio * audio) const; 00148 00149 void 00150 preprocessChain( 00151 aflibAudio * audio, 00152 aflibAudio * child); 00153 00154 // "is" functions that indicate what formats an object supports 00155 virtual bool 00156 isDataSizeSupported(aflib_data_size size); 00157 00158 virtual bool 00159 isEndianSupported(aflib_data_endian end); 00160 00161 virtual bool 00162 isSampleRateSupported(int& rate); 00163 00164 virtual bool 00165 isChannelsSupported(int& channels); 00166 00167 inline void 00168 incrementLevel() {_level++;}; 00169 00170 inline void 00171 decrementLevel() {_level--;}; 00172 00173 private: 00174 00175 bool _enable; 00176 bool _enable_data_size; 00177 bool _enable_endian; 00178 bool _enable_sample_rate; 00179 bool _enable_channels; 00180 aflibConfig _cfg_input; 00181 aflibConfig _cfg_output; 00182 aflibAudioSampleRateCvt * _cvt; 00183 aflibAudioMixer * _mix; 00184 static int _level; 00185 00186 }; 00187 00188 00189 #endif