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 JACK_DSP_SOURCE_H
00030 #define JACK_DSP_SOURCE_H
00031
00032 #ifndef __cplusplus
00033 #error This is a C++ include file
00034 #endif
00035
00036
00037
00038
00039
00040 #include "Reporter.h"
00041 #include "AudioSource.h"
00042
00043 #if defined( HAVE_JACK_LIB )
00044 #include <jack/jack.h>
00045 #include <jack/ringbuffer.h>
00046 #else
00047 #error configure for JACK
00048 #endif
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00065 class JackDspSource : public AudioSource, public virtual Reporter
00066 {
00067 private:
00068
00072 jack_port_t * ports[2];
00073
00077 jack_ringbuffer_t * rb[2];
00078
00082 jack_client_t * client;
00083
00087 jack_default_audio_sample_t * tmp_buffer;
00088
00092 bool auto_connect;
00093
00094 protected:
00095
00101 inline
00102 JackDspSource ( void ) throw ( Exception )
00103 {
00104 throw Exception( __FILE__, __LINE__);
00105 }
00106
00112 void
00113 init ( const char* name ) throw ( Exception );
00114
00120 void
00121 strip ( void ) throw ( Exception );
00122
00123
00127 void
00128 do_auto_connect( ) throw ( Exception );
00129
00133 static int
00134 process_callback( jack_nframes_t nframes, void *arg );
00135
00136
00140 static void
00141 shutdown_callback( void *arg );
00142
00143 public:
00144
00155 inline
00156 JackDspSource ( const char * name,
00157 int sampleRate = 44100,
00158 int bitsPerSample = 16,
00159 int channels = 2 )
00160 throw ( Exception )
00161
00162 : AudioSource( sampleRate, bitsPerSample, channels )
00163 {
00164 init( name );
00165 }
00166
00173 inline
00174 JackDspSource ( const JackDspSource & jds ) throw ( Exception )
00175 : AudioSource( jds )
00176 {
00177 throw Exception( __FILE__, __LINE__, "JackDspSource doesn't copy");
00178 }
00179
00185 inline virtual
00186 ~JackDspSource ( void ) throw ( Exception )
00187 {
00188 strip();
00189 }
00190
00198 inline virtual JackDspSource &
00199 operator= ( const JackDspSource & ds ) throw ( Exception )
00200 {
00201 throw Exception( __FILE__, __LINE__, "JackDspSource doesn't assign");
00202 }
00203
00215 virtual bool
00216 open ( void ) throw ( Exception );
00217
00223 inline virtual bool
00224 isOpen ( void ) const throw ()
00225 {
00226 return client != NULL;
00227 }
00228
00240 virtual bool
00241 canRead ( unsigned int sec,
00242 unsigned int usec ) throw ( Exception );
00243
00253 virtual unsigned int
00254 read ( void * buf,
00255 unsigned int len ) throw ( Exception );
00256
00262 virtual void
00263 close ( void ) throw ( Exception );
00264
00265 };
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275 #endif
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292