Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

JackDspSource.h

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002 
00003    Copyright (c) 2005 Nicholas Humfrey. All rights reserved.
00004 
00005    Tyrell DarkIce
00006 
00007    File     : JackDspSource.h
00008    Version  : $Revision: 1.2 $
00009    Author   : $Author: darkeye $
00010    Location : $Source: /cvsroot/darkice/darkice/src/JackDspSource.h,v $
00011    
00012    Copyright notice:
00013 
00014     This program is free software; you can redistribute it and/or
00015     modify it under the terms of the GNU General Public License  
00016     as published by the Free Software Foundation; either version 2
00017     of the License, or (at your option) any later version.
00018    
00019     This program is distributed in the hope that it will be useful,
00020     but WITHOUT ANY WARRANTY; without even the implied warranty of 
00021     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
00022     GNU General Public License for more details.
00023    
00024     You should have received a copy of the GNU General Public License
00025     along with this program; if not, write to the Free Software
00026     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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 /* ============================================================ include files */
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 /* ================================================================ constants */
00052 
00053 
00054 /* =================================================================== macros */
00055 
00056 
00057 /* =============================================================== data types */
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 /* ================================================= external data structures */
00269 
00270 
00271 /* ====================================================== function prototypes */
00272 
00273 
00274 
00275 #endif  /* JACK_DSP_SOURCE_H */
00276 
00277 
00278 /*------------------------------------------------------------------------------
00279  
00280   $Source: /cvsroot/darkice/darkice/src/JackDspSource.h,v $
00281 
00282   $Log: JackDspSource.h,v $
00283   Revision 1.2  2005/04/14 11:53:17  darkeye
00284   fixed API documentation issues
00285 
00286   Revision 1.1  2005/04/04 08:36:17  darkeye
00287   commited changes to enable Jack support
00288   thanks to Nicholas J. Humfrey, njh@ecs.soton.ac.uk
00289 
00290   
00291 ------------------------------------------------------------------------------*/
00292 

Generated on Thu Apr 14 13:59:12 2005 for DarkIce by  doxygen 1.4.1