From 830706e4368bb27d4c7d8138fbce4e393cedcd2f Mon Sep 17 00:00:00 2001
From: Gary Scavone
+
-
-RtAudio.h
00001 /************************************************************************/
-00038 /************************************************************************/
+
+
RtAudio.h
00001 /************************************************************************/
+00038 /************************************************************************/
00039
-00040 #if !defined(__RTAUDIO_H)
-00041 #define __RTAUDIO_H
-00042
-00043 #include <map>
-00044
-00045 #if defined(__LINUX_ALSA__)
-00046 #include <alsa/asoundlib.h>
-00047 #include <pthread.h>
-00048 #include <unistd.h>
-00049
-00050 typedef snd_pcm_t *AUDIO_HANDLE;
-00051 typedef int DEVICE_ID;
-00052 typedef pthread_t THREAD_HANDLE;
-00053 typedef pthread_mutex_t MUTEX;
-00054
-00055 #elif defined(__LINUX_OSS__)
-00056 #include <pthread.h>
-00057 #include <unistd.h>
-00058
-00059 typedef int AUDIO_HANDLE;
-00060 typedef int DEVICE_ID;
-00061 typedef pthread_t THREAD_HANDLE;
-00062 typedef pthread_mutex_t MUTEX;
-00063
-00064 #elif defined(__WINDOWS_DS__)
-00065 #include <windows.h>
-00066 #include <process.h>
-00067
-00068 // The following struct is used to hold the extra variables
-00069 // specific to the DirectSound implementation.
-00070 typedef struct {
-00071 void * object;
-00072 void * buffer;
-00073 UINT bufferPointer;
-00074 } AUDIO_HANDLE;
+00040 // RtAudio: Version 3.0, 11 March 2004
+00041
+00042 #ifndef __RTAUDIO_H
+00043 #define __RTAUDIO_H
+00044
+00045 #include "RtError.h"
+00046 #include <string>
+00047 #include <vector>
+00048
+00049 // Operating system dependent thread functionality.
+00050 #if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)
+00051 #include <windows.h>
+00052 #include <process.h>
+00053
+00054 typedef unsigned long ThreadHandle;
+00055 typedef CRITICAL_SECTION StreamMutex;
+00056
+00057 #else // Various unix flavors with pthread support.
+00058 #include <pthread.h>
+00059
+00060 typedef pthread_t ThreadHandle;
+00061 typedef pthread_mutex_t StreamMutex;
+00062
+00063 #endif
+00064
+00065 // This global structure type is used to pass callback information
+00066 // between the private RtAudio stream structure and global callback
+00067 // handling functions.
+00068 struct CallbackInfo {
+00069 void *object; // Used as a "this" pointer.
+00070 ThreadHandle thread;
+00071 bool usingCallback;
+00072 void *callback;
+00073 void *userData;
+00074 void *apiInfo; // void pointer for API specific callback information
00075
-00076 typedef LPGUID DEVICE_ID;
-00077 typedef unsigned long THREAD_HANDLE;
-00078 typedef CRITICAL_SECTION MUTEX;
-00079
-00080 #elif defined(__WINDOWS_ASIO__)
-00081 #include <windows.h>
-00082 #include <process.h>
-00083
-00084 typedef int AUDIO_HANDLE;
-00085 typedef int DEVICE_ID;
-00086 typedef unsigned long THREAD_HANDLE;
-00087 typedef CRITICAL_SECTION MUTEX;
-00088
-00089 #elif defined(__IRIX_AL__)
-00090 #include <dmedia/audio.h>
-00091 #include <pthread.h>
-00092 #include <unistd.h>
-00093
-00094 typedef ALport AUDIO_HANDLE;
-00095 typedef long DEVICE_ID;
-00096 typedef pthread_t THREAD_HANDLE;
-00097 typedef pthread_mutex_t MUTEX;
-00098
-00099 #elif defined(__MACOSX_CORE__)
-00100
-00101 #include <CoreAudio/AudioHardware.h>
-00102 #include <pthread.h>
-00103
-00104 typedef unsigned int AUDIO_HANDLE;
-00105 typedef AudioDeviceID DEVICE_ID;
-00106 typedef pthread_t THREAD_HANDLE;
-00107 typedef pthread_mutex_t MUTEX;
-00108
-00109 #endif
-00110
-00111
-00112 /************************************************************************/
-00125 /************************************************************************/
-00126
-00127 class RtError
-00128 {
-00129 public:
-00131 enum TYPE {
-00132 WARNING,
-00133 DEBUG_WARNING,
-00134 UNSPECIFIED,
-00135 NO_DEVICES_FOUND,
-00136 INVALID_DEVICE,
-00137 INVALID_STREAM,
-00138 MEMORY_ERROR,
-00139 INVALID_PARAMETER,
-00140 DRIVER_ERROR,
-00141 SYSTEM_ERROR,
-00142 THREAD_ERROR
-00143 };
-00144
-00145 protected:
-00146 char error_message[256];
-00147 TYPE type;
+00076 // Default constructor.
+00077 CallbackInfo()
+00078 :object(0), usingCallback(false), callback(0),
+00079 userData(0), apiInfo(0) {}
+00080 };
+00081
+00082 // Support for signed integers and floats. Audio data fed to/from
+00083 // the tickStream() routine is assumed to ALWAYS be in host
+00084 // byte order. The internal routines will automatically take care of
+00085 // any necessary byte-swapping between the host format and the
+00086 // soundcard. Thus, endian-ness is not a concern in the following
+00087 // format definitions.
+00088 typedef unsigned long RtAudioFormat;
+00089 static const RtAudioFormat RTAUDIO_SINT8 = 0x1;
+00090 static const RtAudioFormat RTAUDIO_SINT16 = 0x2;
+00091 static const RtAudioFormat RTAUDIO_SINT24 = 0x4;
+00092 static const RtAudioFormat RTAUDIO_SINT32 = 0x8;
+00093 static const RtAudioFormat RTAUDIO_FLOAT32 = 0x10;
+00094 static const RtAudioFormat RTAUDIO_FLOAT64 = 0x20;
+00096 typedef int (*RtAudioCallback)(char *buffer, int bufferSize, void *userData);
+00097
+00099 struct RtAudioDeviceInfo {
+00100 std::string name;
+00101 bool probed;
+00102 int outputChannels;
+00103 int inputChannels;
+00104 int duplexChannels;
+00105 bool isDefault;
+00106 std::vector<int> sampleRates;
+00107 RtAudioFormat nativeFormats;
+00109 // Default constructor.
+00110 RtAudioDeviceInfo()
+00111 :probed(false), outputChannels(0), inputChannels(0),
+00112 duplexChannels(0), isDefault(false), nativeFormats(0) {}
+00113 };
+00114
+00115 // **************************************************************** //
+00116 //
+00117 // RtApi class declaration.
+00118 //
+00119 // Note that RtApi is an abstract base class and cannot be
+00120 // explicitly instantiated. The class RtAudio will create an
+00121 // instance of an RtApi subclass (RtApiOss, RtApiAlsa,
+00122 // RtApiJack, RtApiCore, RtApiAl, RtApiDs, or RtApiAsio).
+00123 //
+00124 // **************************************************************** //
+00125
+00126 class RtApi
+00127 {
+00128 public:
+00129
+00130 RtApi();
+00131 virtual ~RtApi();
+00132 void openStream( int outputDevice, int outputChannels,
+00133 int inputDevice, int inputChannels,
+00134 RtAudioFormat format, int sampleRate,
+00135 int *bufferSize, int numberOfBuffers );
+00136 virtual void setStreamCallback( RtAudioCallback callback, void *userData ) = 0;
+00137 virtual void cancelStreamCallback() = 0;
+00138 int getDeviceCount(void);
+00139 RtAudioDeviceInfo getDeviceInfo( int device );
+00140 char * const getStreamBuffer();
+00141 virtual void tickStream() = 0;
+00142 virtual void closeStream();
+00143 virtual void startStream() = 0;
+00144 virtual void stopStream() = 0;
+00145 virtual void abortStream() = 0;
+00146
+00147 protected:
00148
-00149 public:
-00151 RtError(const char *p, TYPE tipe = RtError::UNSPECIFIED);
-00152
-00154 virtual ~RtError(void);
-00155
-00157 virtual void printMessage(void);
-00158
-00160 virtual const TYPE& getType(void) { return type; }
-00161
-00163 virtual const char *getMessage(void) { return error_message; }
-00164 };
+00149 static const unsigned int MAX_SAMPLE_RATES;
+00150 static const unsigned int SAMPLE_RATES[];
+00151
+00152 enum { FAILURE, SUCCESS };
+00153
+00154 enum StreamMode {
+00155 OUTPUT,
+00156 INPUT,
+00157 DUPLEX,
+00158 UNINITIALIZED = -75
+00159 };
+00160
+00161 enum StreamState {
+00162 STREAM_STOPPED,
+00163 STREAM_RUNNING
+00164 };
00165
-00166
-00167 // This public structure type is used to pass callback information
-00168 // between the private RtAudio stream structure and global callback
-00169 // handling functions.
-00170 typedef struct {
-00171 void *object; // Used as a "this" pointer.
-00172 int streamId;
-00173 DEVICE_ID device[2];
-00174 THREAD_HANDLE thread;
-00175 void *callback;
-00176 void *buffers;
-00177 unsigned long waitTime;
-00178 bool blockTick;
-00179 bool stopStream;
-00180 bool usingCallback;
-00181 void *userData;
-00182 } CALLBACK_INFO;
-00183
-00184
-00185 // *************************************************** //
-00186 //
-00187 // RtAudio class declaration.
-00188 //
-00189 // *************************************************** //
-00190
-00191 class RtAudio
-00192 {
-00193 public:
-00194
-00195 // Support for signed integers and floats. Audio data fed to/from
-00196 // the tickStream() routine is assumed to ALWAYS be in host
-00197 // byte order. The internal routines will automatically take care of
-00198 // any necessary byte-swapping between the host format and the
-00199 // soundcard. Thus, endian-ness is not a concern in the following
-00200 // format definitions.
-00201 typedef unsigned long RTAUDIO_FORMAT;
-00202 static const RTAUDIO_FORMAT RTAUDIO_SINT8;
-00203 static const RTAUDIO_FORMAT RTAUDIO_SINT16;
-00204 static const RTAUDIO_FORMAT RTAUDIO_SINT24;
-00205 static const RTAUDIO_FORMAT RTAUDIO_SINT32;
-00206 static const RTAUDIO_FORMAT RTAUDIO_FLOAT32;
-00207 static const RTAUDIO_FORMAT RTAUDIO_FLOAT64;
-00209 //static const int MAX_SAMPLE_RATES = 14;
-00210 enum { MAX_SAMPLE_RATES = 14 };
-00211
-00212 typedef int (*RTAUDIO_CALLBACK)(char *buffer, int bufferSize, void *userData);
-00213
-00215 typedef struct {
-00216 char name[128];
-00217 DEVICE_ID id[2]; /* No value reported by getDeviceInfo(). */
-00218 bool probed;
-00219 int maxOutputChannels;
-00220 int maxInputChannels;
-00221 int maxDuplexChannels;
-00222 int minOutputChannels;
-00223 int minInputChannels;
-00224 int minDuplexChannels;
-00225 bool hasDuplexSupport;
-00226 bool isDefault;
-00227 int nSampleRates;
-00228 int sampleRates[MAX_SAMPLE_RATES];
-00229 RTAUDIO_FORMAT nativeFormats;
-00230 } RTAUDIO_DEVICE;
+00166 // A protected structure for audio streams.
+00167 struct RtApiStream {
+00168 int device[2]; // Playback and record, respectively.
+00169 void *apiHandle; // void pointer for API specific stream handle information
+00170 StreamMode mode; // OUTPUT, INPUT, or DUPLEX.
+00171 StreamState state; // STOPPED or RUNNING
+00172 char *userBuffer;
+00173 char *deviceBuffer;
+00174 bool doConvertBuffer[2]; // Playback and record, respectively.
+00175 bool deInterleave[2]; // Playback and record, respectively.
+00176 bool doByteSwap[2]; // Playback and record, respectively.
+00177 int sampleRate;
+00178 int bufferSize;
+00179 int nBuffers;
+00180 int nUserChannels[2]; // Playback and record, respectively.
+00181 int nDeviceChannels[2]; // Playback and record channels, respectively.
+00182 RtAudioFormat userFormat;
+00183 RtAudioFormat deviceFormat[2]; // Playback and record, respectively.
+00184 StreamMutex mutex;
+00185 CallbackInfo callbackInfo;
+00186
+00187 RtApiStream()
+00188 :apiHandle(0), userBuffer(0), deviceBuffer(0) {}
+00189 // :apiHandle(0), mode(UNINITIALIZED), state(STREAM_STOPPED),
+00190 // userBuffer(0), deviceBuffer(0) {}
+00191 };
+00192
+00193 // A protected device structure for audio devices.
+00194 struct RtApiDevice {
+00195 std::string name;
+00196 bool probed;
+00197 void *apiDeviceId; // void pointer for API specific device information
+00198 int maxOutputChannels;
+00199 int maxInputChannels;
+00200 int maxDuplexChannels;
+00201 int minOutputChannels;
+00202 int minInputChannels;
+00203 int minDuplexChannels;
+00204 bool hasDuplexSupport;
+00205 bool isDefault;
+00206 std::vector<int> sampleRates;
+00207 RtAudioFormat nativeFormats;
+00209 // Default constructor.
+00210 RtApiDevice()
+00211 :probed(false), apiDeviceId(0), maxOutputChannels(0), maxInputChannels(0),
+00212 maxDuplexChannels(0), minOutputChannels(0), minInputChannels(0),
+00213 minDuplexChannels(0), isDefault(false), nativeFormats(0) {}
+00214 };
+00215
+00216 typedef signed short Int16;
+00217 typedef signed int Int32;
+00218 typedef float Float32;
+00219 typedef double Float64;
+00220
+00221 char message_[256];
+00222 int nDevices_;
+00223 std::vector<RtApiDevice> devices_;
+00224 RtApiStream stream_;
+00225
+00230 virtual void initialize(void) = 0;
00231
-00233
-00239 RtAudio();
-00240
-00242
-00253 RtAudio(int *streamId,
-00254 int outputDevice, int outputChannels,
-00255 int inputDevice, int inputChannels,
-00256 RTAUDIO_FORMAT format, int sampleRate,
-00257 int *bufferSize, int numberOfBuffers);
-00258
-00260
-00264 ~RtAudio();
+00240 virtual void probeDeviceInfo( RtApiDevice *info );
+00241
+00250 virtual bool probeDeviceOpen( int device, StreamMode mode, int channels,
+00251 int sampleRate, RtAudioFormat format,
+00252 int *bufferSize, int numberOfBuffers );
+00253
+00258 virtual int getDefaultInputDevice(void);
+00259
+00264 virtual int getDefaultOutputDevice(void);
00265
-00267
-00294 int openStream(int outputDevice, int outputChannels,
-00295 int inputDevice, int inputChannels,
-00296 RTAUDIO_FORMAT format, int sampleRate,
-00297 int *bufferSize, int numberOfBuffers);
-00298
-00300
-00319 void setStreamCallback(int streamId, RTAUDIO_CALLBACK callback, void *userData);
-00320
-00322
-00329 void cancelStreamCallback(int streamId);
-00330
-00332 int getDeviceCount(void);
-00333
-00335
-00343 void getDeviceInfo(int device, RTAUDIO_DEVICE *info);
-00344
-00346
-00351 char * const getStreamBuffer(int streamId);
-00352
-00354
-00359 void tickStream(int streamId);
+00267 void clearDeviceInfo( RtApiDevice *info );
+00268
+00270 void clearStreamInfo();
+00271
+00273 void error( RtError::Type type );
+00274
+00279 void verifyStream();
+00280
+00285 void convertStreamBuffer( StreamMode mode );
+00286
+00288 void byteSwapBuffer( char *buffer, int samples, RtAudioFormat format );
+00289
+00291 int formatBytes( RtAudioFormat format );
+00292 };
+00293
+00294
+00295 // **************************************************************** //
+00296 //
+00297 // RtAudio class declaration.
+00298 //
+00299 // RtAudio is a "controller" used to select an available audio i/o
+00300 // interface. It presents a common API for the user to call but all
+00301 // functionality is implemented by the class RtAudioApi and its
+00302 // subclasses. RtAudio creates an instance of an RtAudioApi subclass
+00303 // based on the user's API choice. If no choice is made, RtAudio
+00304 // attempts to make a "logical" API selection.
+00305 //
+00306 // **************************************************************** //
+00307
+00308 class RtAudio
+00309 {
+00310 public:
+00311
+00313 enum RtAudioApi {
+00314 UNSPECIFIED,
+00315 LINUX_ALSA,
+00316 LINUX_OSS,
+00317 LINUX_JACK,
+00318 MACOSX_CORE,
+00319 IRIX_AL,
+00320 WINDOWS_ASIO,
+00321 WINDOWS_DS
+00322 };
+00323
+00325
+00335 RtAudio( RtAudioApi api=UNSPECIFIED );
+00336
+00338
+00349 RtAudio( int outputDevice, int outputChannels,
+00350 int inputDevice, int inputChannels,
+00351 RtAudioFormat format, int sampleRate,
+00352 int *bufferSize, int numberOfBuffers, RtAudioApi api=UNSPECIFIED );
+00353
+00355
+00359 ~RtAudio();
00360
00362
-00366 void closeStream(int streamId);
-00367
-00369
-00373 void startStream(int streamId);
-00374
-00376
-00380 void stopStream(int streamId);
-00381
-00383
-00387 void abortStream(int streamId);
-00388
-00390
-00395 int streamWillBlock(int streamId);
-00396
-00397 #if (defined(__MACOSX_CORE__) || defined(__WINDOWS_ASIO__))
-00398 // This function is intended for internal use only. It must be
-00399 // public because it is called by the internal callback handler,
-00400 // which is not a member of RtAudio. External use of this function
-00401 // will most likely produce highly undesireable results!
-00402 void callbackEvent(int streamId, DEVICE_ID deviceId, void *inData, void *outData);
-00403 #endif
-00404
-00405 protected:
-00406
-00407 private:
-00408
-00409 static const unsigned int SAMPLE_RATES[MAX_SAMPLE_RATES];
-00410
-00411 enum { FAILURE, SUCCESS };
-00412
-00413 enum STREAM_MODE {
-00414 OUTPUT,
-00415 INPUT,
-00416 DUPLEX,
-00417 UNINITIALIZED = -75
-00418 };
-00419
-00420 enum STREAM_STATE {
-00421 STREAM_STOPPED,
-00422 STREAM_RUNNING
-00423 };
+00388 void openStream( int outputDevice, int outputChannels,
+00389 int inputDevice, int inputChannels,
+00390 RtAudioFormat format, int sampleRate,
+00391 int *bufferSize, int numberOfBuffers );
+00392
+00394
+00413 void setStreamCallback(RtAudioCallback callback, void *userData) { rtapi_->setStreamCallback( callback, userData ); };
+00414
+00416
+00423 void cancelStreamCallback() { rtapi_->cancelStreamCallback(); };
00424
-00425 typedef struct {
-00426 int device[2]; // Playback and record, respectively.
-00427 STREAM_MODE mode; // OUTPUT, INPUT, or DUPLEX.
-00428 AUDIO_HANDLE handle[2]; // Playback and record handles, respectively.
-00429 STREAM_STATE state; // STOPPED or RUNNING
-00430 char *userBuffer;
-00431 char *deviceBuffer;
-00432 bool doConvertBuffer[2]; // Playback and record, respectively.
-00433 bool deInterleave[2]; // Playback and record, respectively.
-00434 bool doByteSwap[2]; // Playback and record, respectively.
-00435 int sampleRate;
-00436 int bufferSize;
-00437 int nBuffers;
-00438 int nUserChannels[2]; // Playback and record, respectively.
-00439 int nDeviceChannels[2]; // Playback and record channels, respectively.
-00440 RTAUDIO_FORMAT userFormat;
-00441 RTAUDIO_FORMAT deviceFormat[2]; // Playback and record, respectively.
-00442 MUTEX mutex;
-00443 CALLBACK_INFO callbackInfo;
-00444 } RTAUDIO_STREAM;
-00445
-00446 typedef signed short INT16;
-00447 typedef signed int INT32;
-00448 typedef float FLOAT32;
-00449 typedef double FLOAT64;
-00450
-00451 char message[256];
-00452 int nDevices;
-00453 RTAUDIO_DEVICE *devices;
+00426 int getDeviceCount(void) { return rtapi_->getDeviceCount(); };
+00427
+00429
+00437 RtAudioDeviceInfo getDeviceInfo(int device) { return rtapi_->getDeviceInfo( device ); };
+00438
+00440
+00445 char * const getStreamBuffer() { return rtapi_->getStreamBuffer(); };
+00446
+00448
+00453 void tickStream() { rtapi_->tickStream(); };
00454
-00455 std::map<int, void *> streams;
00456
-00458 void error(RtError::TYPE type);
-00459
-00464 void initialize(void);
-00465
-00470 int getDefaultInputDevice(void);
-00471
-00476 int getDefaultOutputDevice(void);
+00460 void closeStream() { rtapi_->closeStream(); };
+00461
+00463
+00467 void startStream() { rtapi_->startStream(); };
+00468
+00470
+00474 void stopStream() { rtapi_->stopStream(); };
+00475
00477
-00479 void clearDeviceInfo(RTAUDIO_DEVICE *info);
-00480
-00488 void probeDeviceInfo(RTAUDIO_DEVICE *info);
-00489
-00496 bool probeDeviceOpen(int device, RTAUDIO_STREAM *stream,
-00497 STREAM_MODE mode, int channels,
-00498 int sampleRate, RTAUDIO_FORMAT format,
-00499 int *bufferSize, int numberOfBuffers);
-00500
-00507 void *verifyStream(int streamId);
-00508
-00513 void convertStreamBuffer(RTAUDIO_STREAM *stream, STREAM_MODE mode);
-00514
-00516 void byteSwapBuffer(char *buffer, int samples, RTAUDIO_FORMAT format);
-00517
-00519 int formatBytes(RTAUDIO_FORMAT format);
-00520 };
-00521
-00522 // Define the following flag to have extra information spewed to stderr.
-00523 //#define __RTAUDIO_DEBUG__
-00524
-00525 #endif
-
+00481 void abortStream() { rtapi_->abortStream(); };
+00482
+00483
+00484 protected:
+00485
+00486 void initialize( RtAudioApi api );
+00487
+00488 RtApi *rtapi_;
+00489 };
+00490
+00491
+00492 // RtApi Subclass prototypes.
+00493
+00494 #if defined(__LINUX_ALSA__)
+00495
+00496 class RtApiAlsa: public RtApi
+00497 {
+00498 public:
+00499
+00500 RtApiAlsa();
+00501 ~RtApiAlsa();
+00502 void tickStream();
+00503 void closeStream();
+00504 void startStream();
+00505 void stopStream();
+00506 void abortStream();
+00507 int streamWillBlock();
+00508 void setStreamCallback( RtAudioCallback callback, void *userData );
+00509 void cancelStreamCallback();
+00510
+00511 private:
+00512
+00513 void initialize(void);
+00514 void probeDeviceInfo( RtApiDevice *info );
+00515 bool probeDeviceOpen( int device, StreamMode mode, int channels,
+00516 int sampleRate, RtAudioFormat format,
+00517 int *bufferSize, int numberOfBuffers );
+00518 };
+00519
+00520 #endif
+00521
+00522 #if defined(__LINUX_JACK__)
+00523
+00524 class RtApiJack: public RtApi
+00525 {
+00526 public:
+00527
+00528 RtApiJack();
+00529 ~RtApiJack();
+00530 void tickStream();
+00531 void closeStream();
+00532 void startStream();
+00533 void stopStream();
+00534 void abortStream();
+00535 void setStreamCallback( RtAudioCallback callback, void *userData );
+00536 void cancelStreamCallback();
+00537 // This function is intended for internal use only. It must be
+00538 // public because it is called by the internal callback handler,
+00539 // which is not a member of RtAudio. External use of this function
+00540 // will most likely produce highly undesireable results!
+00541 void callbackEvent( unsigned long nframes );
+00542
+00543 private:
+00544
+00545 void initialize(void);
+00546 void probeDeviceInfo( RtApiDevice *info );
+00547 bool probeDeviceOpen( int device, StreamMode mode, int channels,
+00548 int sampleRate, RtAudioFormat format,
+00549 int *bufferSize, int numberOfBuffers );
+00550 };
+00551
+00552 #endif
+00553
+00554 #if defined(__LINUX_OSS__)
+00555
+00556 class RtApiOss: public RtApi
+00557 {
+00558 public:
+00559
+00560 RtApiOss();
+00561 ~RtApiOss();
+00562 void tickStream();
+00563 void closeStream();
+00564 void startStream();
+00565 void stopStream();
+00566 void abortStream();
+00567 int streamWillBlock();
+00568 void setStreamCallback( RtAudioCallback callback, void *userData );
+00569 void cancelStreamCallback();
+00570
+00571 private:
+00572
+00573 void initialize(void);
+00574 void probeDeviceInfo( RtApiDevice *info );
+00575 bool probeDeviceOpen( int device, StreamMode mode, int channels,
+00576 int sampleRate, RtAudioFormat format,
+00577 int *bufferSize, int numberOfBuffers );
+00578 };
+00579
+00580 #endif
+00581
+00582 #if defined(__MACOSX_CORE__)
+00583
+00584 #include <CoreAudio/AudioHardware.h>
+00585
+00586 class RtApiCore: public RtApi
+00587 {
+00588 public:
+00589
+00590 RtApiCore();
+00591 ~RtApiCore();
+00592 int getDefaultOutputDevice(void);
+00593 int getDefaultInputDevice(void);
+00594 void tickStream();
+00595 void closeStream();
+00596 void startStream();
+00597 void stopStream();
+00598 void abortStream();
+00599 void setStreamCallback( RtAudioCallback callback, void *userData );
+00600 void cancelStreamCallback();
+00601
+00602 // This function is intended for internal use only. It must be
+00603 // public because it is called by the internal callback handler,
+00604 // which is not a member of RtAudio. External use of this function
+00605 // will most likely produce highly undesireable results!
+00606 void callbackEvent( AudioDeviceID deviceId, void *inData, void *outData );
+00607
+00608 private:
+00609
+00610 void initialize(void);
+00611 void probeDeviceInfo( RtApiDevice *info );
+00612 bool probeDeviceOpen( int device, StreamMode mode, int channels,
+00613 int sampleRate, RtAudioFormat format,
+00614 int *bufferSize, int numberOfBuffers );
+00615 };
+00616
+00617 #endif
+00618
+00619 #if defined(__WINDOWS_DS__)
+00620
+00621 class RtApiDs: public RtApi
+00622 {
+00623 public:
+00624
+00625 RtApiDs();
+00626 ~RtApiDs();
+00627 int getDefaultOutputDevice(void);
+00628 int getDefaultInputDevice(void);
+00629 void tickStream();
+00630 void closeStream();
+00631 void startStream();
+00632 void stopStream();
+00633 void abortStream();
+00634 int streamWillBlock();
+00635 void setStreamCallback( RtAudioCallback callback, void *userData );
+00636 void cancelStreamCallback();
+00637
+00638 private:
+00639
+00640 void initialize(void);
+00641 void probeDeviceInfo( RtApiDevice *info );
+00642 bool probeDeviceOpen( int device, StreamMode mode, int channels,
+00643 int sampleRate, RtAudioFormat format,
+00644 int *bufferSize, int numberOfBuffers );
+00645 };
+00646
+00647 #endif
+00648
+00649 #if defined(__WINDOWS_ASIO__)
+00650
+00651 class RtApiAsio: public RtApi
+00652 {
+00653 public:
+00654
+00655 RtApiAsio();
+00656 ~RtApiAsio();
+00657 void tickStream();
+00658 void closeStream();
+00659 void startStream();
+00660 void stopStream();
+00661 void abortStream();
+00662 void setStreamCallback( RtAudioCallback callback, void *userData );
+00663 void cancelStreamCallback();
+00664
+00665 // This function is intended for internal use only. It must be
+00666 // public because it is called by the internal callback handler,
+00667 // which is not a member of RtAudio. External use of this function
+00668 // will most likely produce highly undesireable results!
+00669 void callbackEvent( long bufferIndex );
+00670
+00671 private:
+00672
+00673 void initialize(void);
+00674 void probeDeviceInfo( RtApiDevice *info );
+00675 bool probeDeviceOpen( int device, StreamMode mode, int channels,
+00676 int sampleRate, RtAudioFormat format,
+00677 int *bufferSize, int numberOfBuffers );
+00678 };
+00679
+00680 #endif
+00681
+00682 #if defined(__IRIX_AL__)
+00683
+00684 class RtApiAl: public RtApi
+00685 {
+00686 public:
+00687
+00688 RtApiAl();
+00689 ~RtApiAl();
+00690 int getDefaultOutputDevice(void);
+00691 int getDefaultInputDevice(void);
+00692 void tickStream();
+00693 void closeStream();
+00694 void startStream();
+00695 void stopStream();
+00696 void abortStream();
+00697 int streamWillBlock();
+00698 void setStreamCallback( RtAudioCallback callback, void *userData );
+00699 void cancelStreamCallback();
+00700
+00701 private:
+00702
+00703 void initialize(void);
+00704 void probeDeviceInfo( RtApiDevice *info );
+00705 bool probeDeviceOpen( int device, StreamMode mode, int channels,
+00706 int sampleRate, RtAudioFormat format,
+00707 int *bufferSize, int numberOfBuffers );
+00708 };
+00709
+00710 #endif
+00711
+00712 // Define the following flag to have extra information spewed to stderr.
+00713 //#define __RTAUDIO_DEBUG__
+00714
+00715 #endif
+
-
- ©2001-2002 Gary P. Scavone, CCRMA, Stanford University. All Rights Reserved.
- Maintained by Gary P. Scavone, gary@ccrma.stanford.edu
+ 
©2001-2004 Gary P. Scavone, McGill University. All Rights Reserved.
+ Maintained by Gary P. Scavone, gary@music.mcgill.ca
00001 /************************************************************************/ +00010 /************************************************************************/ +00011 +00012 #ifndef RTERROR_H +00013 #define RTERROR_H +00014 +00015 #include <iostream> +00016 #include <string> +00017 +00018 class RtError +00019 { +00020 public: +00022 enum Type { +00023 WARNING, +00024 DEBUG_WARNING, +00025 UNSPECIFIED, +00026 NO_DEVICES_FOUND, +00027 INVALID_DEVICE, +00028 INVALID_STREAM, +00029 MEMORY_ERROR, +00030 INVALID_PARAMETER, +00031 DRIVER_ERROR, +00032 SYSTEM_ERROR, +00033 THREAD_ERROR +00034 }; +00035 +00036 protected: +00037 std::string message_; +00038 Type type_; +00039 +00040 public: +00042 RtError(const std::string& message, Type type = RtError::UNSPECIFIED) : message_(message), type_(type){} +00043 +00045 virtual ~RtError(void) {}; +00046 +00048 virtual void printMessage(void) { std::cerr << '\n' << message_ << "\n\n"; } +00049 +00051 virtual const Type& getType(void) { return type_; } +00052 +00054 virtual const std::string& getMessage(void) { return message_; } +00055 +00057 virtual const char *getMessageString(void) { return message_.c_str(); } +00058 }; +00059 +00060 #endif +
![]() |
+ ©2001-2004 Gary P. Scavone, McGill University. All Rights Reserved. + Maintained by Gary P. Scavone, gary@music.mcgill.ca |
diff --git a/doc/html/RtError_8h-source.html b/doc/html/RtError_8h-source.html new file mode 100644 index 0000000..d216750 --- /dev/null +++ b/doc/html/RtError_8h-source.html @@ -0,0 +1,64 @@ + +
+
+ + +
+