00001 /*------------------------------------------------------------------------------ 00002 00003 Copyright (c) 2004 Tyrell Corporation. All rights reserved. 00004 00005 Tyrell DarkIce 00006 00007 File : AudioSource.cpp 00008 Version : $Revision: 1.3 $ 00009 Author : $Author: darkeye $ 00010 Location : $Source: /cvsroot/darkice/darkice/src/AudioSource.cpp,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 00030 /* ============================================================ include files */ 00031 00032 #ifdef HAVE_CONFIG_H 00033 #include "config.h" 00034 #endif 00035 00036 #include "AudioSource.h" 00037 #include "Util.h" 00038 #include "Exception.h" 00039 00040 00041 /* =================================================== local data structures */ 00042 00043 00044 /* ================================================ local constants & macros */ 00045 00046 /*------------------------------------------------------------------------------ 00047 * File identity 00048 *----------------------------------------------------------------------------*/ 00049 static const char fileid[] = "$Id: AudioSource.cpp,v 1.3 2005/04/04 08:36:16 darkeye Exp $"; 00050 00051 00052 /* =============================================== local function prototypes */ 00053 00054 00055 /* ============================================================= module code */ 00056 00057 /*------------------------------------------------------------------------------ 00058 * Return an audio source based on the compiled DSP supports and the 00059 * supplied device name parameter. 00060 *----------------------------------------------------------------------------*/ 00061 AudioSource * 00062 AudioSource :: createDspSource( const char * deviceName, 00063 int sampleRate, 00064 int bitsPerSample, 00065 int channel) 00066 throw ( Exception ) 00067 { 00068 00069 if ( Util::strEq( deviceName, "/dev", 4) ) { 00070 #if defined( SUPPORT_OSS_DSP ) 00071 Reporter::reportEvent( 1, "Using OSS DSP input device:", deviceName); 00072 return new OssDspSource( deviceName, 00073 sampleRate, 00074 bitsPerSample, 00075 channel); 00076 #elif defined( SUPPORT_SOLARIS_DSP ) 00077 Reporter::reportEvent( 1, "Using Solaris DSP input device:",deviceName); 00078 return new SolarisDspSource( deviceName, 00079 sampleRate, 00080 bitsPerSample, 00081 channel); 00082 #else 00083 throw Exception( __FILE__, __LINE__, 00084 "trying to open OSS or Solaris DSP device " 00085 "without support compiled", deviceName); 00086 #endif 00087 } else if ( Util::strEq( deviceName, "jack", 4) ) { 00088 #if defined( SUPPORT_JACK_DSP ) 00089 Reporter::reportEvent( 1, "Using JACK audio server as input device."); 00090 return new JackDspSource( deviceName, 00091 sampleRate, 00092 bitsPerSample, 00093 channel); 00094 #else 00095 throw Exception( __FILE__, __LINE__, 00096 "trying to open JACK device without " 00097 "support compiled", deviceName); 00098 #endif 00099 } else { 00100 #if defined( SUPPORT_ALSA_DSP ) 00101 Reporter::reportEvent( 1, "Using ALSA DSP input device:", deviceName); 00102 return new AlsaDspSource( deviceName, 00103 sampleRate, 00104 bitsPerSample, 00105 channel); 00106 #else 00107 throw Exception( __FILE__, __LINE__, 00108 "trying to open ALSA DSP device without " 00109 "support compiled", deviceName); 00110 #endif 00111 } 00112 } 00113 00114 00115 /*------------------------------------------------------------------------------ 00116 00117 $Source: /cvsroot/darkice/darkice/src/AudioSource.cpp,v $ 00118 00119 $Log: AudioSource.cpp,v $ 00120 Revision 1.3 2005/04/04 08:36:16 darkeye 00121 commited changes to enable Jack support 00122 thanks to Nicholas J. Humfrey, njh@ecs.soton.ac.uk 00123 00124 Revision 1.2 2004/02/15 22:26:16 darkeye 00125 fixed typo, minimal cosmetic change 00126 00127 Revision 1.1 2004/02/15 12:06:29 darkeye 00128 added ALSA support, thanks to Christian Forster 00129 00130 00131 ------------------------------------------------------------------------------*/ 00132