00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef AUDIO_SOURCE_H
00030 #define AUDIO_SOURCE_H
00031
00032 #ifndef __cplusplus
00033 #error This is a C++ include file
00034 #endif
00035
00036 #ifdef HAVE_CONFIG_H
00037 #include "config.h"
00038 #endif
00039
00040
00041
00042 #include "Source.h"
00043 #include "Reporter.h"
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 #if defined( HAVE_ALSA_LIB )
00055
00056 #define SUPPORT_ALSA_DSP 1
00057 #endif
00058
00059 #if defined( HAVE_SYS_SOUNDCARD_H )
00060
00061 #define SUPPORT_OSS_DSP 1
00062 #endif
00063
00064 #if defined( HAVE_SYS_AUDIO_H ) || defined( HAVE_SYS_AUDIOIO_H )
00065
00066 #define SUPPORT_SOLARIS_DSP 1
00067 #endif
00068
00069 #if defined( HAVE_JACK_LIB )
00070
00071 #define SUPPORT_JACK_DSP 1
00072 #endif
00073
00074 #if !defined( SUPPORT_ALSA_DSP ) \
00075 && !defined( SUPPORT_OSS_DSP ) \
00076 && !defined( SUPPORT_JACK_DSP ) \
00077 && !defined( SUPPORT_SOLARIS_DSP )
00078
00079 #error No DSP audio input device found on system
00080 #endif
00081
00082
00083
00084
00091 class AudioSource : public Source, public virtual Reporter
00092 {
00093 private:
00094
00099 unsigned int channel;
00100
00104 unsigned int sampleRate;
00105
00109 unsigned int bitsPerSample;
00110
00119 inline void
00120 init ( unsigned int sampleRate,
00121 unsigned int bitsPerSample,
00122 unsigned int channel ) throw ( Exception )
00123 {
00124 this->sampleRate = sampleRate;
00125 this->bitsPerSample = bitsPerSample;
00126 this->channel = channel;
00127 }
00128
00134 inline void
00135 strip ( void ) throw ( Exception )
00136 {
00137 }
00138
00139
00140 protected:
00141
00153 inline
00154 AudioSource ( unsigned int sampleRate = 44100,
00155 unsigned int bitsPerSample = 16,
00156 unsigned int channel = 2 )
00157 throw ( Exception )
00158 {
00159 init ( sampleRate, bitsPerSample, channel);
00160 }
00161
00168 inline
00169 AudioSource ( const AudioSource & as ) throw ( Exception )
00170 : Source( as )
00171 {
00172 init ( as.sampleRate, as.bitsPerSample, as.channel);
00173 }
00174
00182 inline virtual AudioSource &
00183 operator= ( const AudioSource & as ) throw ( Exception )
00184 {
00185 if ( this != &as ) {
00186 strip();
00187 Source::operator=( as );
00188 init ( as.sampleRate, as.bitsPerSample, as.channel);
00189 }
00190
00191 return *this;
00192 }
00193
00194
00195 public:
00196
00202 virtual inline
00203 ~AudioSource ( void ) throw ( Exception )
00204 {
00205 }
00206
00212 inline unsigned int
00213 getChannel ( void ) const throw ()
00214 {
00215 return channel;
00216 }
00217
00223 virtual bool
00224 isBigEndian ( void ) const throw ()
00225 {
00226 #ifdef WORDS_BIGENDIAN
00227 return true;
00228 #else
00229 return false;
00230 #endif
00231 }
00232
00238 inline unsigned int
00239 getSampleRate ( void ) const throw ()
00240 {
00241 return sampleRate;
00242 }
00243
00244
00250 inline unsigned int
00251 getBitsPerSample ( void ) const throw ()
00252 {
00253 return bitsPerSample;
00254 }
00255
00268 static AudioSource *
00269 createDspSource( const char * deviceName,
00270 int sampleRate = 44100,
00271 int bitsPerSample = 16,
00272 int channel = 2) throw ( Exception );
00273
00274 };
00275
00276
00277
00278
00279
00280
00281
00282 #if defined( SUPPORT_ALSA_DSP )
00283 #include "AlsaDspSource.h"
00284 #endif
00285
00286 #if defined( SUPPORT_OSS_DSP )
00287 #include "OssDspSource.h"
00288 #endif
00289
00290 #if defined( SUPPORT_SOLARIS_DSP )
00291 #include "SolarisDspSource.h"
00292 #endif
00293
00294 #if defined( SUPPORT_JACK_DSP )
00295 #include "JackDspSource.h"
00296 #endif
00297
00298
00299
00300
00301
00302 #endif
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340