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 OSS_DSP_SOURCE_H
00030 #define OSS_DSP_SOURCE_H
00031
00032 #ifndef __cplusplus
00033 #error This is a C++ include file
00034 #endif
00035
00036
00037
00038
00039 #include "Reporter.h"
00040 #include "AudioSource.h"
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00057 class OssDspSource : public AudioSource, public virtual Reporter
00058 {
00059 private:
00060
00064 char * fileName;
00065
00069 int fileDescriptor;
00070
00075 bool running;
00076
00077
00078 protected:
00079
00085 inline
00086 OssDspSource ( void ) throw ( Exception )
00087 {
00088 throw Exception( __FILE__, __LINE__);
00089 }
00090
00097 void
00098 init ( const char * name ) throw ( Exception );
00099
00105 void
00106 strip ( void ) throw ( Exception );
00107
00108
00109 public:
00110
00122 inline
00123 OssDspSource ( const char * name,
00124 int sampleRate = 44100,
00125 int bitsPerSample = 16,
00126 int channel = 2 )
00127 throw ( Exception )
00128
00129 : AudioSource( sampleRate, bitsPerSample, channel)
00130 {
00131 init( name);
00132 }
00133
00140 inline
00141 OssDspSource ( const OssDspSource & ods ) throw ( Exception )
00142 : AudioSource( ods )
00143 {
00144 init( ods.fileName);
00145 }
00146
00152 inline virtual
00153 ~OssDspSource ( void ) throw ( Exception )
00154 {
00155 strip();
00156 }
00157
00165 inline virtual OssDspSource &
00166 operator= ( const OssDspSource & ds ) throw ( Exception )
00167 {
00168 if ( this != &ds ) {
00169 strip();
00170 AudioSource::operator=( ds);
00171 init( ds.fileName);
00172 }
00173 return *this;
00174 }
00175
00181 virtual bool
00182 isBigEndian ( void ) const throw ();
00183
00195 virtual bool
00196 open ( void ) throw ( Exception );
00197
00203 inline virtual bool
00204 isOpen ( void ) const throw ()
00205 {
00206 return fileDescriptor != 0;
00207 }
00208
00220 virtual bool
00221 canRead ( unsigned int sec,
00222 unsigned int usec ) throw ( Exception );
00223
00233 virtual unsigned int
00234 read ( void * buf,
00235 unsigned int len ) throw ( Exception );
00236
00242 virtual void
00243 close ( void ) throw ( Exception );
00244 };
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254 #endif
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286