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

AudioSource.h

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002 
00003    Copyright (c) 2000 Tyrell Corporation. All rights reserved.
00004 
00005    Tyrell DarkIce
00006 
00007    File     : AudioSource.h
00008    Version  : $Revision: 1.9 $
00009    Author   : $Author: darkeye $
00010    Location : $Source: /cvsroot/darkice/darkice/src/AudioSource.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 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 /* ============================================================ include files */
00041 
00042 #include "Source.h"
00043 #include "Reporter.h"
00044 
00045 
00046 /* ================================================================ constants */
00047 
00048 
00049 /* =================================================================== macros */
00050 
00051 /*------------------------------------------------------------------------------
00052  *  Determine the kind of audio device based on the system
00053  *----------------------------------------------------------------------------*/
00054 #if defined( HAVE_ALSA_LIB )
00055 // we have an ALSA sound system available
00056 #define SUPPORT_ALSA_DSP 1
00057 #endif
00058 
00059 #if defined( HAVE_SYS_SOUNDCARD_H )
00060 // we have an OSS DSP sound source device available
00061 #define SUPPORT_OSS_DSP 1
00062 #endif
00063 
00064 #if defined( HAVE_SYS_AUDIO_H ) || defined( HAVE_SYS_AUDIOIO_H )
00065 // we have a Solaris DSP sound device available (same for OpenBSD)
00066 #define SUPPORT_SOLARIS_DSP 1
00067 #endif
00068 
00069 #if defined( HAVE_JACK_LIB )
00070 // we have JACK audio server
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 // there was no DSP audio system found
00079 #error No DSP audio input device found on system
00080 #endif
00081 
00082 
00083 /* =============================================================== data types */
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 /* ================================================= external data structures */
00278 
00279 /*------------------------------------------------------------------------------
00280  *  Determine the kind of audio device based on the system
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 /* ====================================================== function prototypes */
00299 
00300 
00301 
00302 #endif  /* AUDIO_SOURCE_H */
00303 
00304 
00305 /*------------------------------------------------------------------------------
00306  
00307   $Source: /cvsroot/darkice/darkice/src/AudioSource.h,v $
00308 
00309   $Log: AudioSource.h,v $
00310   Revision 1.9  2005/04/14 11:53:17  darkeye
00311   fixed API documentation issues
00312 
00313   Revision 1.8  2005/04/04 08:36:16  darkeye
00314   commited changes to enable Jack support
00315   thanks to Nicholas J. Humfrey, njh@ecs.soton.ac.uk
00316 
00317   Revision 1.7  2004/02/18 21:08:11  darkeye
00318   ported to OpenBSD (real-time scheduling not yet supported)
00319 
00320   Revision 1.6  2004/02/15 12:06:29  darkeye
00321   added ALSA support, thanks to Christian Forster
00322 
00323   Revision 1.5  2001/09/18 14:57:19  darkeye
00324   finalized Solaris port
00325 
00326   Revision 1.4  2001/09/11 15:05:21  darkeye
00327   added Solaris support
00328 
00329   Revision 1.3  2000/11/12 13:31:40  darkeye
00330   added kdoc-style documentation comments
00331 
00332   Revision 1.2  2000/11/05 17:37:24  darkeye
00333   removed clone() functions
00334 
00335   Revision 1.1.1.1  2000/11/05 10:05:47  darkeye
00336   initial version
00337 
00338   
00339 ------------------------------------------------------------------------------*/
00340 

Generated on Fri May 19 15:36:48 2006 for DarkIce by  doxygen 1.4.4