Version 3.0
[rtaudio.git] / RtAudio.h
1 /************************************************************************/
2 /*! \class RtAudio
3     \brief Realtime audio i/o C++ classes.
4
5     RtAudio provides a common API (Application Programming Interface)
6     for realtime audio input/output across Linux (native ALSA, Jack,
7     and OSS), SGI, Macintosh OS X (CoreAudio), and Windows
8     (DirectSound and ASIO) operating systems.
9
10     RtAudio WWW site: http://music.mcgill.ca/~gary/rtaudio/
11
12     RtAudio: a realtime audio i/o C++ class
13     Copyright (c) 2001-2004 Gary P. Scavone
14
15     Permission is hereby granted, free of charge, to any person
16     obtaining a copy of this software and associated documentation files
17     (the "Software"), to deal in the Software without restriction,
18     including without limitation the rights to use, copy, modify, merge,
19     publish, distribute, sublicense, and/or sell copies of the Software,
20     and to permit persons to whom the Software is furnished to do so,
21     subject to the following conditions:
22
23     The above copyright notice and this permission notice shall be
24     included in all copies or substantial portions of the Software.
25
26     Any person wishing to distribute modifications to the Software is
27     requested to send the modifications to the original developer so that
28     they can be incorporated into the canonical version.
29
30     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
33     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
34     ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
35     CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36     WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 */
38 /************************************************************************/
39
40 // RtAudio: Version 3.0, 11 March 2004
41
42 #ifndef __RTAUDIO_H
43 #define __RTAUDIO_H
44
45 #include "RtError.h"
46 #include <string>
47 #include <vector>
48
49 // Operating system dependent thread functionality.
50 #if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)
51   #include <windows.h>
52   #include <process.h>
53
54   typedef unsigned long ThreadHandle;
55   typedef CRITICAL_SECTION StreamMutex;
56
57 #else // Various unix flavors with pthread support.
58   #include <pthread.h>
59
60   typedef pthread_t ThreadHandle;
61   typedef pthread_mutex_t StreamMutex;
62
63 #endif
64
65 // This global structure type is used to pass callback information
66 // between the private RtAudio stream structure and global callback
67 // handling functions.
68 struct CallbackInfo {
69   void *object;    // Used as a "this" pointer.
70   ThreadHandle thread;
71   bool usingCallback;
72   void *callback;
73   void *userData;
74   void *apiInfo;   // void pointer for API specific callback information
75
76   // Default constructor.
77   CallbackInfo()
78     :object(0), usingCallback(false), callback(0),
79      userData(0), apiInfo(0) {}
80 };
81
82 // Support for signed integers and floats.  Audio data fed to/from
83 // the tickStream() routine is assumed to ALWAYS be in host
84 // byte order.  The internal routines will automatically take care of
85 // any necessary byte-swapping between the host format and the
86 // soundcard.  Thus, endian-ness is not a concern in the following
87 // format definitions.
88 typedef unsigned long RtAudioFormat;
89 static const RtAudioFormat RTAUDIO_SINT8 = 0x1;    /*!< 8-bit signed integer. */
90 static const RtAudioFormat RTAUDIO_SINT16 = 0x2;   /*!< 16-bit signed integer. */
91 static const RtAudioFormat RTAUDIO_SINT24 = 0x4;   /*!< Upper 3 bytes of 32-bit signed integer. */
92 static const RtAudioFormat RTAUDIO_SINT32 = 0x8;   /*!< 32-bit signed integer. */
93 static const RtAudioFormat RTAUDIO_FLOAT32 = 0x10; /*!< Normalized between plus/minus 1.0. */
94 static const RtAudioFormat RTAUDIO_FLOAT64 = 0x20; /*!< Normalized between plus/minus 1.0. */
95
96 typedef int (*RtAudioCallback)(char *buffer, int bufferSize, void *userData);
97
98 //! The public device information structure for returning queried values.
99 struct RtAudioDeviceInfo {
100   std::string name;      /*!< Character string device identifier. */
101   bool probed;          /*!< true if the device capabilities were successfully probed. */
102   int outputChannels;   /*!< Maximum output channels supported by device. */
103   int inputChannels;    /*!< Maximum input channels supported by device. */
104   int duplexChannels;   /*!< Maximum simultaneous input/output channels supported by device. */
105   bool isDefault;       /*!< true if this is the default output or input device. */
106   std::vector<int> sampleRates; /*!< Supported sample rates (queried from list of standard rates). */
107   RtAudioFormat nativeFormats;  /*!< Bit mask of supported data formats. */
108
109   // Default constructor.
110   RtAudioDeviceInfo()
111     :probed(false), outputChannels(0), inputChannels(0),
112        duplexChannels(0), isDefault(false), nativeFormats(0) {}
113 };
114
115 // **************************************************************** //
116 //
117 // RtApi class declaration.
118 //
119 // Note that RtApi is an abstract base class and cannot be
120 // explicitly instantiated.  The class RtAudio will create an
121 // instance of an RtApi subclass (RtApiOss, RtApiAlsa,
122 // RtApiJack, RtApiCore, RtApiAl, RtApiDs, or RtApiAsio).
123 //
124 // **************************************************************** //
125
126 class RtApi
127 {
128 public:
129
130   RtApi();
131   virtual ~RtApi();
132   void openStream( int outputDevice, int outputChannels,
133                    int inputDevice, int inputChannels,
134                    RtAudioFormat format, int sampleRate,
135                    int *bufferSize, int numberOfBuffers );
136   virtual void setStreamCallback( RtAudioCallback callback, void *userData ) = 0;
137   virtual void cancelStreamCallback() = 0;
138   int getDeviceCount(void);
139   RtAudioDeviceInfo getDeviceInfo( int device );
140   char * const getStreamBuffer();
141   virtual void tickStream() = 0;
142   virtual void closeStream();
143   virtual void startStream() = 0;
144   virtual void stopStream() = 0;
145   virtual void abortStream() = 0;
146
147 protected:
148
149   static const unsigned int MAX_SAMPLE_RATES;
150   static const unsigned int SAMPLE_RATES[];
151
152   enum { FAILURE, SUCCESS };
153
154   enum StreamMode {
155     OUTPUT,
156     INPUT,
157     DUPLEX,
158     UNINITIALIZED = -75
159   };
160
161   enum StreamState {
162     STREAM_STOPPED,
163     STREAM_RUNNING
164   };
165
166   // A protected structure for audio streams.
167   struct RtApiStream {
168     int device[2];          // Playback and record, respectively.
169     void *apiHandle;        // void pointer for API specific stream handle information
170     StreamMode mode;         // OUTPUT, INPUT, or DUPLEX.
171     StreamState state;       // STOPPED or RUNNING
172     char *userBuffer;
173     char *deviceBuffer;
174     bool doConvertBuffer[2]; // Playback and record, respectively.
175     bool deInterleave[2];    // Playback and record, respectively.
176     bool doByteSwap[2];      // Playback and record, respectively.
177     int sampleRate;
178     int bufferSize;
179     int nBuffers;
180     int nUserChannels[2];    // Playback and record, respectively.
181     int nDeviceChannels[2];  // Playback and record channels, respectively.
182     RtAudioFormat userFormat;
183     RtAudioFormat deviceFormat[2]; // Playback and record, respectively.
184     StreamMutex mutex;
185     CallbackInfo callbackInfo;
186
187     RtApiStream()
188       :apiHandle(0), userBuffer(0), deviceBuffer(0) {}
189     //      :apiHandle(0), mode(UNINITIALIZED), state(STREAM_STOPPED),
190     //       userBuffer(0), deviceBuffer(0) {}
191   };
192
193   // A protected device structure for audio devices.
194   struct RtApiDevice {
195     std::string name;      /*!< Character string device identifier. */
196     bool probed;           /*!< true if the device capabilities were successfully probed. */
197     void *apiDeviceId;     // void pointer for API specific device information
198     int maxOutputChannels; /*!< Maximum output channels supported by device. */
199     int maxInputChannels;  /*!< Maximum input channels supported by device. */
200     int maxDuplexChannels; /*!< Maximum simultaneous input/output channels supported by device. */
201     int minOutputChannels; /*!< Minimum output channels supported by device. */
202     int minInputChannels;  /*!< Minimum input channels supported by device. */
203     int minDuplexChannels; /*!< Minimum simultaneous input/output channels supported by device. */
204     bool hasDuplexSupport; /*!< true if device supports duplex mode. */
205     bool isDefault;        /*!< true if this is the default output or input device. */
206     std::vector<int> sampleRates; /*!< Supported sample rates. */
207     RtAudioFormat nativeFormats;  /*!< Bit mask of supported data formats. */
208
209     // Default constructor.
210     RtApiDevice()
211       :probed(false), apiDeviceId(0), maxOutputChannels(0), maxInputChannels(0),
212        maxDuplexChannels(0), minOutputChannels(0), minInputChannels(0),
213        minDuplexChannels(0), isDefault(false), nativeFormats(0) {}
214   };
215
216   typedef signed short Int16;
217   typedef signed int Int32;
218   typedef float Float32;
219   typedef double Float64;
220
221   char message_[256];
222   int nDevices_;
223   std::vector<RtApiDevice> devices_;
224   RtApiStream stream_;
225
226   /*!
227     Protected, api-specific method to count and identify the system
228     audio devices.  This function MUST be implemented by all subclasses.
229   */
230   virtual void initialize(void) = 0;
231
232   /*!
233     Protected, api-specific method which attempts to fill an
234     RtAudioDevice structure for a given device.  This function MUST be
235     implemented by all subclasses.  If an error is encountered during
236     the probe, a "warning" message is reported and the value of
237     "probed" remains false (no exception is thrown).  A successful
238     probe is indicated by probed = true.
239   */
240   virtual void probeDeviceInfo( RtApiDevice *info );
241
242   /*!
243     Protected, api-specific method which attempts to open a device
244     with the given parameters.  This function MUST be implemented by
245     all subclasses.  If an error is encountered during the probe, a
246     "warning" message is reported and FAILURE is returned (no
247     exception is thrown). A successful probe is indicated by a return
248     value of SUCCESS.
249   */
250   virtual bool probeDeviceOpen( int device, StreamMode mode, int channels, 
251                                 int sampleRate, RtAudioFormat format,
252                                 int *bufferSize, int numberOfBuffers );
253
254   /*!
255     Protected method which returns the index in the devices array to
256     the default input device.
257   */
258   virtual int getDefaultInputDevice(void);
259
260   /*!
261     Protected method which returns the index in the devices array to
262     the default output device.
263   */
264   virtual int getDefaultOutputDevice(void);
265
266   //! Protected common method to clear an RtApiDevice structure.
267   void clearDeviceInfo( RtApiDevice *info );
268
269   //! Protected common method to clear an RtApiStream structure.
270   void clearStreamInfo();
271
272   //! Protected common error method to allow global control over error handling.
273   void error( RtError::Type type );
274
275   /*!
276     Protected common method used to check whether a stream is open.
277     If not, an "invalid identifier" exception is thrown.
278   */
279   void verifyStream();
280
281   /*!
282     Protected method used to perform format, channel number, and/or interleaving
283     conversions between the user and device buffers.
284   */
285   void convertStreamBuffer( StreamMode mode );
286
287   //! Protected common method used to perform byte-swapping on buffers.
288   void byteSwapBuffer( char *buffer, int samples, RtAudioFormat format );
289
290   //! Protected common method which returns the number of bytes for a given format.
291   int formatBytes( RtAudioFormat format );
292 };
293
294
295 // **************************************************************** //
296 //
297 // RtAudio class declaration.
298 //
299 // RtAudio is a "controller" used to select an available audio i/o
300 // interface.  It presents a common API for the user to call but all
301 // functionality is implemented by the class RtAudioApi and its
302 // subclasses.  RtAudio creates an instance of an RtAudioApi subclass
303 // based on the user's API choice.  If no choice is made, RtAudio
304 // attempts to make a "logical" API selection.
305 //
306 // **************************************************************** //
307
308 class RtAudio
309 {
310 public:
311
312   //! Audio API specifier arguments.
313   enum RtAudioApi {
314     UNSPECIFIED,    /*!< Search for a working compiled API. */
315     LINUX_ALSA,     /*!< The Advanced Linux Sound Architecture API. */
316     LINUX_OSS,      /*!< The Linux Open Sound System API. */
317     LINUX_JACK,     /*!< The Linux Jack Low-Latency Audio Server API. */
318     MACOSX_CORE,    /*!< Macintosh OS-X Core Audio API. */
319     IRIX_AL,        /*!< The Irix Audio Library API. */
320     WINDOWS_ASIO,   /*!< The Steinberg Audio Stream I/O API. */
321     WINDOWS_DS      /*!< The Microsoft Direct Sound API. */
322   };
323
324   //! The default class constructor.
325   /*!
326     Probes the system to make sure at least one audio input/output
327     device is available and determines the api-specific identifier for
328     each device found.  An RtError error can be thrown if no devices
329     are found or if a memory allocation error occurs.
330
331     If no API argument is specified and multiple API support has been
332     compiled, the default order of use is JACK, ALSA, OSS (Linux
333     systems) and ASIO, DS (Windows systems).
334   */
335   RtAudio( RtAudioApi api=UNSPECIFIED );
336
337   //! A constructor which can be used to open a stream during instantiation.
338   /*!
339     The specified output and/or input device identifiers correspond
340     to those enumerated via the getDeviceInfo() method.  If device =
341     0, the default or first available devices meeting the given
342     parameters is selected.  If an output or input channel value is
343     zero, the corresponding device value is ignored.  When a stream is
344     successfully opened, its identifier is returned via the "streamId"
345     pointer.  An RtError can be thrown if no devices are found
346     for the given parameters, if a memory allocation error occurs, or
347     if a driver error occurs. \sa openStream()
348   */
349   RtAudio( int outputDevice, int outputChannels,
350            int inputDevice, int inputChannels,
351            RtAudioFormat format, int sampleRate,
352            int *bufferSize, int numberOfBuffers, RtAudioApi api=UNSPECIFIED );
353
354   //! The destructor.
355   /*!
356     Stops and closes an open stream and devices and deallocates
357     buffer and structure memory.
358   */
359   ~RtAudio();
360
361   //! A public method for opening a stream with the specified parameters.
362   /*!
363     An RtError is thrown if a stream cannot be opened.
364
365     \param outputDevice: If equal to 0, the default or first device
366            found meeting the given parameters is opened.  Otherwise, the
367            device number should correspond to one of those enumerated via
368            the getDeviceInfo() method.
369     \param outputChannels: The desired number of output channels.  If
370            equal to zero, the outputDevice identifier is ignored.
371     \param inputDevice: If equal to 0, the default or first device
372            found meeting the given parameters is opened.  Otherwise, the
373            device number should correspond to one of those enumerated via
374            the getDeviceInfo() method.
375     \param inputChannels: The desired number of input channels.  If
376            equal to zero, the inputDevice identifier is ignored.
377     \param format: An RtAudioFormat specifying the desired sample data format.
378     \param sampleRate: The desired sample rate (sample frames per second).
379     \param *bufferSize: A pointer value indicating the desired internal buffer
380            size in sample frames.  The actual value used by the device is
381            returned via the same pointer.  A value of zero can be specified,
382            in which case the lowest allowable value is determined.
383     \param numberOfBuffers: A value which can be used to help control device
384            latency.  More buffers typically result in more robust performance,
385            though at a cost of greater latency.  A value of zero can be
386            specified, in which case the lowest allowable value is used.
387   */
388   void openStream( int outputDevice, int outputChannels,
389                    int inputDevice, int inputChannels,
390                    RtAudioFormat format, int sampleRate,
391                    int *bufferSize, int numberOfBuffers );
392
393   //! A public method which sets a user-defined callback function for a given stream.
394   /*!
395     This method assigns a callback function to a previously opened
396     stream for non-blocking stream functionality.  A separate process
397     is initiated, though the user function is called only when the
398     stream is "running" (between calls to the startStream() and
399     stopStream() methods, respectively).  The callback process remains
400     active for the duration of the stream and is automatically
401     shutdown when the stream is closed (via the closeStream() method
402     or by object destruction).  The callback process can also be
403     shutdown and the user function de-referenced through an explicit
404     call to the cancelStreamCallback() method.  Note that the stream
405     can use only blocking or callback functionality at a particular
406     time, though it is possible to alternate modes on the same stream
407     through the use of the setStreamCallback() and
408     cancelStreamCallback() methods (the blocking tickStream() method
409     can be used before a callback is set and/or after a callback is
410     cancelled).  An RtError will be thrown if called when no stream is
411     open or a thread errors occurs.
412   */
413   void setStreamCallback(RtAudioCallback callback, void *userData) { rtapi_->setStreamCallback( callback, userData ); };
414
415   //! A public method which cancels a callback process and function for the stream.
416   /*!
417     This method shuts down a callback process and de-references the
418     user function for the stream.  Callback functionality can
419     subsequently be restarted on the stream via the
420     setStreamCallback() method.  An RtError will be thrown if called
421     when no stream is open.
422    */
423   void cancelStreamCallback() { rtapi_->cancelStreamCallback(); };
424
425   //! A public method which returns the number of audio devices found.
426   int getDeviceCount(void) { return rtapi_->getDeviceCount(); };
427
428   //! Return an RtAudioDeviceInfo structure for a specified device number.
429   /*!
430     Any device integer between 1 and getDeviceCount() is valid.  If
431     a device is busy or otherwise unavailable, the structure member
432     "probed" will have a value of "false" and all other members are
433     undefined.  If the specified device is the current default input
434     or output device, the "isDefault" member will have a value of
435     "true".  An RtError will be thrown for an invalid device argument.
436   */
437   RtAudioDeviceInfo getDeviceInfo(int device) { return rtapi_->getDeviceInfo( device ); };
438
439   //! A public method which returns a pointer to the buffer for an open stream.
440   /*!
441     The user should fill and/or read the buffer data in interleaved format
442     and then call the tickStream() method.  An RtError will be
443     thrown if called when no stream is open.
444   */
445   char * const getStreamBuffer() { return rtapi_->getStreamBuffer(); };
446
447   //! Public method used to trigger processing of input/output data for a stream.
448   /*!
449     This method blocks until all buffer data is read/written.  An
450     RtError will be thrown if a driver error occurs or if called when
451     no stream is open.
452   */
453   void tickStream() { rtapi_->tickStream(); };
454
455   //! Public method which closes a stream and frees any associated buffers.
456   /*!
457     If a stream is not open, this method issues a warning and
458     returns (an RtError is not thrown).
459   */
460   void closeStream()  { rtapi_->closeStream(); };
461
462   //! Public method which starts a stream.
463   /*!
464     An RtError will be thrown if a driver error occurs or if called
465     when no stream is open.
466   */
467   void startStream() { rtapi_->startStream(); };
468
469   //! Stop a stream, allowing any samples remaining in the queue to be played out and/or read in.
470   /*!
471     An RtError will be thrown if a driver error occurs or if called
472     when no stream is open.
473   */
474   void stopStream() { rtapi_->stopStream(); };
475
476   //! Stop a stream, discarding any samples remaining in the input/output queue.
477   /*!
478     An RtError will be thrown if a driver error occurs or if called
479     when no stream is open.
480   */
481   void abortStream() { rtapi_->abortStream(); };
482
483
484  protected:
485
486   void initialize( RtAudioApi api );
487
488   RtApi *rtapi_;
489 };
490
491
492 // RtApi Subclass prototypes.
493
494 #if defined(__LINUX_ALSA__)
495
496 class RtApiAlsa: public RtApi
497 {
498 public:
499
500   RtApiAlsa();
501   ~RtApiAlsa();
502   void tickStream();
503   void closeStream();
504   void startStream();
505   void stopStream();
506   void abortStream();
507   int streamWillBlock();
508   void setStreamCallback( RtAudioCallback callback, void *userData );
509   void cancelStreamCallback();
510
511   private:
512
513   void initialize(void);
514   void probeDeviceInfo( RtApiDevice *info );
515   bool probeDeviceOpen( int device, StreamMode mode, int channels, 
516                         int sampleRate, RtAudioFormat format,
517                         int *bufferSize, int numberOfBuffers );
518 };
519
520 #endif
521
522 #if defined(__LINUX_JACK__)
523
524 class RtApiJack: public RtApi
525 {
526 public:
527
528   RtApiJack();
529   ~RtApiJack();
530   void tickStream();
531   void closeStream();
532   void startStream();
533   void stopStream();
534   void abortStream();
535   void setStreamCallback( RtAudioCallback callback, void *userData );
536   void cancelStreamCallback();
537   // This function is intended for internal use only.  It must be
538   // public because it is called by the internal callback handler,
539   // which is not a member of RtAudio.  External use of this function
540   // will most likely produce highly undesireable results!
541   void callbackEvent( unsigned long nframes );
542
543   private:
544
545   void initialize(void);
546   void probeDeviceInfo( RtApiDevice *info );
547   bool probeDeviceOpen( int device, StreamMode mode, int channels, 
548                         int sampleRate, RtAudioFormat format,
549                         int *bufferSize, int numberOfBuffers );
550 };
551
552 #endif
553
554 #if defined(__LINUX_OSS__)
555
556 class RtApiOss: public RtApi
557 {
558 public:
559
560   RtApiOss();
561   ~RtApiOss();
562   void tickStream();
563   void closeStream();
564   void startStream();
565   void stopStream();
566   void abortStream();
567   int streamWillBlock();
568   void setStreamCallback( RtAudioCallback callback, void *userData );
569   void cancelStreamCallback();
570
571   private:
572
573   void initialize(void);
574   void probeDeviceInfo( RtApiDevice *info );
575   bool probeDeviceOpen( int device, StreamMode mode, int channels, 
576                         int sampleRate, RtAudioFormat format,
577                         int *bufferSize, int numberOfBuffers );
578 };
579
580 #endif
581
582 #if defined(__MACOSX_CORE__)
583
584 #include <CoreAudio/AudioHardware.h>
585
586 class RtApiCore: public RtApi
587 {
588 public:
589
590   RtApiCore();
591   ~RtApiCore();
592   int getDefaultOutputDevice(void);
593   int getDefaultInputDevice(void);
594   void tickStream();
595   void closeStream();
596   void startStream();
597   void stopStream();
598   void abortStream();
599   void setStreamCallback( RtAudioCallback callback, void *userData );
600   void cancelStreamCallback();
601
602   // This function is intended for internal use only.  It must be
603   // public because it is called by the internal callback handler,
604   // which is not a member of RtAudio.  External use of this function
605   // will most likely produce highly undesireable results!
606   void callbackEvent( AudioDeviceID deviceId, void *inData, void *outData );
607
608   private:
609
610   void initialize(void);
611   void probeDeviceInfo( RtApiDevice *info );
612   bool probeDeviceOpen( int device, StreamMode mode, int channels, 
613                         int sampleRate, RtAudioFormat format,
614                         int *bufferSize, int numberOfBuffers );
615 };
616
617 #endif
618
619 #if defined(__WINDOWS_DS__)
620
621 class RtApiDs: public RtApi
622 {
623 public:
624
625   RtApiDs();
626   ~RtApiDs();
627   int getDefaultOutputDevice(void);
628   int getDefaultInputDevice(void);
629   void tickStream();
630   void closeStream();
631   void startStream();
632   void stopStream();
633   void abortStream();
634   int streamWillBlock();
635   void setStreamCallback( RtAudioCallback callback, void *userData );
636   void cancelStreamCallback();
637
638   private:
639
640   void initialize(void);
641   void probeDeviceInfo( RtApiDevice *info );
642   bool probeDeviceOpen( int device, StreamMode mode, int channels, 
643                         int sampleRate, RtAudioFormat format,
644                         int *bufferSize, int numberOfBuffers );
645 };
646
647 #endif
648
649 #if defined(__WINDOWS_ASIO__)
650
651 class RtApiAsio: public RtApi
652 {
653 public:
654
655   RtApiAsio();
656   ~RtApiAsio();
657   void tickStream();
658   void closeStream();
659   void startStream();
660   void stopStream();
661   void abortStream();
662   void setStreamCallback( RtAudioCallback callback, void *userData );
663   void cancelStreamCallback();
664
665   // This function is intended for internal use only.  It must be
666   // public because it is called by the internal callback handler,
667   // which is not a member of RtAudio.  External use of this function
668   // will most likely produce highly undesireable results!
669   void callbackEvent( long bufferIndex );
670
671   private:
672
673   void initialize(void);
674   void probeDeviceInfo( RtApiDevice *info );
675   bool probeDeviceOpen( int device, StreamMode mode, int channels, 
676                         int sampleRate, RtAudioFormat format,
677                         int *bufferSize, int numberOfBuffers );
678 };
679
680 #endif
681
682 #if defined(__IRIX_AL__)
683
684 class RtApiAl: public RtApi
685 {
686 public:
687
688   RtApiAl();
689   ~RtApiAl();
690   int getDefaultOutputDevice(void);
691   int getDefaultInputDevice(void);
692   void tickStream();
693   void closeStream();
694   void startStream();
695   void stopStream();
696   void abortStream();
697   int streamWillBlock();
698   void setStreamCallback( RtAudioCallback callback, void *userData );
699   void cancelStreamCallback();
700
701   private:
702
703   void initialize(void);
704   void probeDeviceInfo( RtApiDevice *info );
705   bool probeDeviceOpen( int device, StreamMode mode, int channels, 
706                         int sampleRate, RtAudioFormat format,
707                         int *bufferSize, int numberOfBuffers );
708 };
709
710 #endif
711
712 // Define the following flag to have extra information spewed to stderr.
713 //#define __RTAUDIO_DEBUG__
714
715 #endif