No exception updates for Jack API.
[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), Macintosh OS X (CoreAudio and Jack), and Windows
8     (DirectSound, ASIO and WASAPI) operating systems.
9
10     RtAudio GitHub site: https://github.com/thestk/rtaudio
11     RtAudio WWW site: http://www.music.mcgill.ca/~gary/rtaudio/
12
13     RtAudio: realtime audio i/o C++ classes
14     Copyright (c) 2001-2019 Gary P. Scavone
15
16     Permission is hereby granted, free of charge, to any person
17     obtaining a copy of this software and associated documentation files
18     (the "Software"), to deal in the Software without restriction,
19     including without limitation the rights to use, copy, modify, merge,
20     publish, distribute, sublicense, and/or sell copies of the Software,
21     and to permit persons to whom the Software is furnished to do so,
22     subject to the following conditions:
23
24     The above copyright notice and this permission notice shall be
25     included in all copies or substantial portions of the Software.
26
27     Any person wishing to distribute modifications to the Software is
28     asked to send the modifications to the original developer so that
29     they can be incorporated into the canonical version.  This is,
30     however, not a binding provision of this license.
31
32     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
33     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
34     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
35     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
36     ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
37     CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
38     WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39 */
40 /************************************************************************/
41
42 /*!
43   \file RtAudio.h
44  */
45
46 #ifndef __RTAUDIO_H
47 #define __RTAUDIO_H
48
49 #define RTAUDIO_VERSION "6.0.0beta1"
50
51 #if defined _WIN32 || defined __CYGWIN__
52   #if defined(RTAUDIO_EXPORT)
53     #define RTAUDIO_DLL_PUBLIC __declspec(dllexport)
54   #else
55     #define RTAUDIO_DLL_PUBLIC
56   #endif
57 #else
58   #if __GNUC__ >= 4
59     #define RTAUDIO_DLL_PUBLIC __attribute__( (visibility( "default" )) )
60   #else
61     #define RTAUDIO_DLL_PUBLIC
62   #endif
63 #endif
64
65 #include <string>
66 #include <vector>
67 #include <iostream>
68
69 /*! \typedef typedef unsigned long RtAudioFormat;
70     \brief RtAudio data format type.
71
72     Support for signed integers and floats.  Audio data fed to/from an
73     RtAudio stream is assumed to ALWAYS be in host byte order.  The
74     internal routines will automatically take care of any necessary
75     byte-swapping between the host format and the soundcard.  Thus,
76     endian-ness is not a concern in the following format definitions.
77
78     - \e RTAUDIO_SINT8:   8-bit signed integer.
79     - \e RTAUDIO_SINT16:  16-bit signed integer.
80     - \e RTAUDIO_SINT24:  24-bit signed integer.
81     - \e RTAUDIO_SINT32:  32-bit signed integer.
82     - \e RTAUDIO_FLOAT32: Normalized between plus/minus 1.0.
83     - \e RTAUDIO_FLOAT64: Normalized between plus/minus 1.0.
84 */
85 typedef unsigned long RtAudioFormat;
86 static const RtAudioFormat RTAUDIO_SINT8 = 0x1;    // 8-bit signed integer.
87 static const RtAudioFormat RTAUDIO_SINT16 = 0x2;   // 16-bit signed integer.
88 static const RtAudioFormat RTAUDIO_SINT24 = 0x4;   // 24-bit signed integer.
89 static const RtAudioFormat RTAUDIO_SINT32 = 0x8;   // 32-bit signed integer.
90 static const RtAudioFormat RTAUDIO_FLOAT32 = 0x10; // Normalized between plus/minus 1.0.
91 static const RtAudioFormat RTAUDIO_FLOAT64 = 0x20; // Normalized between plus/minus 1.0.
92
93 /*! \typedef typedef unsigned long RtAudioStreamFlags;
94     \brief RtAudio stream option flags.
95
96     The following flags can be OR'ed together to allow a client to
97     make changes to the default stream behavior:
98
99     - \e RTAUDIO_NONINTERLEAVED:   Use non-interleaved buffers (default = interleaved).
100     - \e RTAUDIO_MINIMIZE_LATENCY: Attempt to set stream parameters for lowest possible latency.
101     - \e RTAUDIO_HOG_DEVICE:       Attempt grab device for exclusive use.
102     - \e RTAUDIO_ALSA_USE_DEFAULT: Use the "default" PCM device (ALSA only).
103     - \e RTAUDIO_JACK_DONT_CONNECT: Do not automatically connect ports (JACK only).
104
105     By default, RtAudio streams pass and receive audio data from the
106     client in an interleaved format.  By passing the
107     RTAUDIO_NONINTERLEAVED flag to the openStream() function, audio
108     data will instead be presented in non-interleaved buffers.  In
109     this case, each buffer argument in the RtAudioCallback function
110     will point to a single array of data, with \c nFrames samples for
111     each channel concatenated back-to-back.  For example, the first
112     sample of data for the second channel would be located at index \c
113     nFrames (assuming the \c buffer pointer was recast to the correct
114     data type for the stream).
115
116     Certain audio APIs offer a number of parameters that influence the
117     I/O latency of a stream.  By default, RtAudio will attempt to set
118     these parameters internally for robust (glitch-free) performance
119     (though some APIs, like Windows DirectSound, make this difficult).
120     By passing the RTAUDIO_MINIMIZE_LATENCY flag to the openStream()
121     function, internal stream settings will be influenced in an attempt
122     to minimize stream latency, though possibly at the expense of stream
123     performance.
124
125     If the RTAUDIO_HOG_DEVICE flag is set, RtAudio will attempt to
126     open the input and/or output stream device(s) for exclusive use.
127     Note that this is not possible with all supported audio APIs.
128
129     If the RTAUDIO_SCHEDULE_REALTIME flag is set, RtAudio will attempt 
130     to select realtime scheduling (round-robin) for the callback thread.
131
132     If the RTAUDIO_ALSA_USE_DEFAULT flag is set, RtAudio will attempt to
133     open the "default" PCM device when using the ALSA API. Note that this
134     will override any specified input or output device id.
135
136     If the RTAUDIO_JACK_DONT_CONNECT flag is set, RtAudio will not attempt
137     to automatically connect the ports of the client to the audio device.
138 */
139 typedef unsigned int RtAudioStreamFlags;
140 static const RtAudioStreamFlags RTAUDIO_NONINTERLEAVED = 0x1;    // Use non-interleaved buffers (default = interleaved).
141 static const RtAudioStreamFlags RTAUDIO_MINIMIZE_LATENCY = 0x2;  // Attempt to set stream parameters for lowest possible latency.
142 static const RtAudioStreamFlags RTAUDIO_HOG_DEVICE = 0x4;        // Attempt grab device and prevent use by others.
143 static const RtAudioStreamFlags RTAUDIO_SCHEDULE_REALTIME = 0x8; // Try to select realtime scheduling for callback thread.
144 static const RtAudioStreamFlags RTAUDIO_ALSA_USE_DEFAULT = 0x10; // Use the "default" PCM device (ALSA only).
145 static const RtAudioStreamFlags RTAUDIO_JACK_DONT_CONNECT = 0x20; // Do not automatically connect ports (JACK only).
146
147 /*! \typedef typedef unsigned long RtAudioStreamStatus;
148     \brief RtAudio stream status (over- or underflow) flags.
149
150     Notification of a stream over- or underflow is indicated by a
151     non-zero stream \c status argument in the RtAudioCallback function.
152     The stream status can be one of the following two options,
153     depending on whether the stream is open for output and/or input:
154
155     - \e RTAUDIO_INPUT_OVERFLOW:   Input data was discarded because of an overflow condition at the driver.
156     - \e RTAUDIO_OUTPUT_UNDERFLOW: The output buffer ran low, likely producing a break in the output sound.
157 */
158 typedef unsigned int RtAudioStreamStatus;
159 static const RtAudioStreamStatus RTAUDIO_INPUT_OVERFLOW = 0x1;    // Input data was discarded because of an overflow condition at the driver.
160 static const RtAudioStreamStatus RTAUDIO_OUTPUT_UNDERFLOW = 0x2;  // The output buffer ran low, likely causing a gap in the output sound.
161
162 //! RtAudio callback function prototype.
163 /*!
164    All RtAudio clients must create a function of type RtAudioCallback
165    to read and/or write data from/to the audio stream.  When the
166    underlying audio system is ready for new input or output data, this
167    function will be invoked.
168
169    \param outputBuffer For output (or duplex) streams, the client
170           should write \c nFrames of audio sample frames into this
171           buffer.  This argument should be recast to the datatype
172           specified when the stream was opened.  For input-only
173           streams, this argument will be NULL.
174
175    \param inputBuffer For input (or duplex) streams, this buffer will
176           hold \c nFrames of input audio sample frames.  This
177           argument should be recast to the datatype specified when the
178           stream was opened.  For output-only streams, this argument
179           will be NULL.
180
181    \param nFrames The number of sample frames of input or output
182           data in the buffers.  The actual buffer size in bytes is
183           dependent on the data type and number of channels in use.
184
185    \param streamTime The number of seconds that have elapsed since the
186           stream was started.
187
188    \param status If non-zero, this argument indicates a data overflow
189           or underflow condition for the stream.  The particular
190           condition can be determined by comparison with the
191           RtAudioStreamStatus flags.
192
193    \param userData A pointer to optional data provided by the client
194           when opening the stream (default = NULL).
195
196    \return
197    To continue normal stream operation, the RtAudioCallback function
198    should return a value of zero.  To stop the stream and drain the
199    output buffer, the function should return a value of one.  To abort
200    the stream immediately, the client should return a value of two.
201  */
202 typedef int (*RtAudioCallback)( void *outputBuffer, void *inputBuffer,
203                                 unsigned int nFrames,
204                                 double streamTime,
205                                 RtAudioStreamStatus status,
206                                 void *userData );
207
208 enum RtAudioErrorType {
209   RTAUDIO_NO_ERROR,          /*!< No error. */
210   RTAUDIO_WARNING,           /*!< A non-critical error. */
211   RTAUDIO_UNKNOWN_ERROR,     /*!< An unspecified error type. */
212   RTAUDIO_NO_DEVICES_FOUND,  /*!< No devices found on system. */
213   RTAUDIO_INVALID_DEVICE,    /*!< An invalid device ID was specified. */
214   RTAUDIO_DEVICE_DISCONNECT, /*!< A device in use was disconnected. */
215   RTAUDIO_MEMORY_ERROR,      /*!< An error occured during memory allocation. */
216   RTAUDIO_INVALID_PARAMETER, /*!< An invalid parameter was specified to a function. */
217   RTAUDIO_INVALID_USE,       /*!< The function was called incorrectly. */
218   RTAUDIO_DRIVER_ERROR,      /*!< A system driver error occurred. */
219   RTAUDIO_SYSTEM_ERROR,      /*!< A system error occurred. */
220   RTAUDIO_THREAD_ERROR       /*!< A thread error occurred. */
221 };
222
223 //! RtAudio error callback function prototype.
224 /*!
225     \param type Type of error.
226     \param errorText Error description.
227  */
228 typedef void (*RtAudioErrorCallback)( RtAudioErrorType type, const std::string &errorText );
229
230 // **************************************************************** //
231 //
232 // RtAudio class declaration.
233 //
234 // RtAudio is a "controller" used to select an available audio i/o
235 // interface.  It presents a common API for the user to call but all
236 // functionality is implemented by the class RtApi and its
237 // subclasses.  RtAudio creates an instance of an RtApi subclass
238 // based on the user's API choice.  If no choice is made, RtAudio
239 // attempts to make a "logical" API selection.
240 //
241 // **************************************************************** //
242
243 class RtApi;
244
245 class RTAUDIO_DLL_PUBLIC RtAudio
246 {
247  public:
248
249   //! Audio API specifier arguments.
250   enum Api {
251     UNSPECIFIED,    /*!< Search for a working compiled API. */
252     LINUX_ALSA,     /*!< The Advanced Linux Sound Architecture API. */
253     LINUX_PULSE,    /*!< The Linux PulseAudio API. */
254     LINUX_OSS,      /*!< The Linux Open Sound System API. */
255     UNIX_JACK,      /*!< The Jack Low-Latency Audio Server API. */
256     MACOSX_CORE,    /*!< Macintosh OS-X Core Audio API. */
257     WINDOWS_WASAPI, /*!< The Microsoft WASAPI API. */
258     WINDOWS_ASIO,   /*!< The Steinberg Audio Stream I/O API. */
259     WINDOWS_DS,     /*!< The Microsoft DirectSound API. */
260     RTAUDIO_DUMMY,  /*!< A compilable but non-functional API. */
261     NUM_APIS        /*!< Number of values in this enum. */
262   };
263
264   //! The public device information structure for returning queried values.
265   struct DeviceInfo {
266     bool probed;                  /*!< true if the device capabilities were successfully probed. */
267     std::string name;             /*!< Character string device identifier. */
268     unsigned int outputChannels;  /*!< Maximum output channels supported by device. */
269     unsigned int inputChannels;   /*!< Maximum input channels supported by device. */
270     unsigned int duplexChannels;  /*!< Maximum simultaneous input/output channels supported by device. */
271     bool isDefaultOutput;         /*!< true if this is the default output device. */
272     bool isDefaultInput;          /*!< true if this is the default input device. */
273     std::vector<unsigned int> sampleRates; /*!< Supported sample rates (queried from list of standard rates). */
274     unsigned int currentSampleRate;   /*!< Current sample rate, system sample rate as currently configured. */
275     unsigned int preferredSampleRate; /*!< Preferred sample rate, e.g. for WASAPI the system sample rate. */
276     RtAudioFormat nativeFormats;  /*!< Bit mask of supported data formats. */
277
278     // Default constructor.
279     DeviceInfo()
280       :probed(false), outputChannels(0), inputChannels(0), duplexChannels(0),
281       isDefaultOutput(false), isDefaultInput(false), currentSampleRate(0), preferredSampleRate(0), nativeFormats(0) {}
282   };
283
284   //! The structure for specifying input or ouput stream parameters.
285   struct StreamParameters {
286     unsigned int deviceId;     /*!< Device index (0 to getDeviceCount() - 1). */
287     unsigned int nChannels;    /*!< Number of channels. */
288     unsigned int firstChannel; /*!< First channel index on device (default = 0). */
289
290     // Default constructor.
291     StreamParameters()
292       : deviceId(0), nChannels(0), firstChannel(0) {}
293   };
294
295   //! The structure for specifying stream options.
296   /*!
297     The following flags can be OR'ed together to allow a client to
298     make changes to the default stream behavior:
299
300     - \e RTAUDIO_NONINTERLEAVED:    Use non-interleaved buffers (default = interleaved).
301     - \e RTAUDIO_MINIMIZE_LATENCY:  Attempt to set stream parameters for lowest possible latency.
302     - \e RTAUDIO_HOG_DEVICE:        Attempt grab device for exclusive use.
303     - \e RTAUDIO_SCHEDULE_REALTIME: Attempt to select realtime scheduling for callback thread.
304     - \e RTAUDIO_ALSA_USE_DEFAULT:  Use the "default" PCM device (ALSA only).
305
306     By default, RtAudio streams pass and receive audio data from the
307     client in an interleaved format.  By passing the
308     RTAUDIO_NONINTERLEAVED flag to the openStream() function, audio
309     data will instead be presented in non-interleaved buffers.  In
310     this case, each buffer argument in the RtAudioCallback function
311     will point to a single array of data, with \c nFrames samples for
312     each channel concatenated back-to-back.  For example, the first
313     sample of data for the second channel would be located at index \c
314     nFrames (assuming the \c buffer pointer was recast to the correct
315     data type for the stream).
316
317     Certain audio APIs offer a number of parameters that influence the
318     I/O latency of a stream.  By default, RtAudio will attempt to set
319     these parameters internally for robust (glitch-free) performance
320     (though some APIs, like Windows DirectSound, make this difficult).
321     By passing the RTAUDIO_MINIMIZE_LATENCY flag to the openStream()
322     function, internal stream settings will be influenced in an attempt
323     to minimize stream latency, though possibly at the expense of stream
324     performance.
325
326     If the RTAUDIO_HOG_DEVICE flag is set, RtAudio will attempt to
327     open the input and/or output stream device(s) for exclusive use.
328     Note that this is not possible with all supported audio APIs.
329
330     If the RTAUDIO_SCHEDULE_REALTIME flag is set, RtAudio will attempt 
331     to select realtime scheduling (round-robin) for the callback thread.
332     The \c priority parameter will only be used if the RTAUDIO_SCHEDULE_REALTIME
333     flag is set. It defines the thread's realtime priority.
334
335     If the RTAUDIO_ALSA_USE_DEFAULT flag is set, RtAudio will attempt to
336     open the "default" PCM device when using the ALSA API. Note that this
337     will override any specified input or output device id.
338
339     The \c numberOfBuffers parameter can be used to control stream
340     latency in the Windows DirectSound, Linux OSS, and Linux Alsa APIs
341     only.  A value of two is usually the smallest allowed.  Larger
342     numbers can potentially result in more robust stream performance,
343     though likely at the cost of stream latency.  The value set by the
344     user is replaced during execution of the RtAudio::openStream()
345     function by the value actually used by the system.
346
347     The \c streamName parameter can be used to set the client name
348     when using the Jack API.  By default, the client name is set to
349     RtApiJack.  However, if you wish to create multiple instances of
350     RtAudio with Jack, each instance must have a unique client name.
351   */
352   struct StreamOptions {
353     RtAudioStreamFlags flags;      /*!< A bit-mask of stream flags (RTAUDIO_NONINTERLEAVED, RTAUDIO_MINIMIZE_LATENCY, RTAUDIO_HOG_DEVICE, RTAUDIO_ALSA_USE_DEFAULT). */
354     unsigned int numberOfBuffers;  /*!< Number of stream buffers. */
355     std::string streamName;        /*!< A stream name (currently used only in Jack). */
356     int priority;                  /*!< Scheduling priority of callback thread (only used with flag RTAUDIO_SCHEDULE_REALTIME). */
357
358     // Default constructor.
359     StreamOptions()
360     : flags(0), numberOfBuffers(0), priority(0) {}
361   };
362
363   //! A static function to determine the current RtAudio version.
364   static std::string getVersion( void );
365
366   //! A static function to determine the available compiled audio APIs.
367   /*!
368     The values returned in the std::vector can be compared against
369     the enumerated list values.  Note that there can be more than one
370     API compiled for certain operating systems.
371   */
372   static void getCompiledApi( std::vector<RtAudio::Api> &apis );
373
374   //! Return the name of a specified compiled audio API.
375   /*!
376     This obtains a short lower-case name used for identification purposes.
377     This value is guaranteed to remain identical across library versions.
378     If the API is unknown, this function will return the empty string.
379   */
380   static std::string getApiName( RtAudio::Api api );
381
382   //! Return the display name of a specified compiled audio API.
383   /*!
384     This obtains a long name used for display purposes.
385     If the API is unknown, this function will return the empty string.
386   */
387   static std::string getApiDisplayName( RtAudio::Api api );
388
389   //! Return the compiled audio API having the given name.
390   /*!
391     A case insensitive comparison will check the specified name
392     against the list of compiled APIs, and return the one which
393     matches. On failure, the function returns UNSPECIFIED.
394   */
395   static RtAudio::Api getCompiledApiByName( const std::string &name );
396
397   //! The class constructor.
398   /*!
399     The constructor attempts to create an RtApi instance.
400
401     If an API argument is specified but that API has not been
402     compiled, a warning is issued and an instance of an available API
403     is created. If no compiled API is found, the routine will abort
404     (though this should be impossible because RtDummy is the default
405     if no API-specific preprocessor definition is provided to the
406     compiler). If no API argument is specified and multiple API
407     support has been compiled, the default order of use is JACK, ALSA,
408     OSS (Linux systems) and ASIO, DS (Windows systems).
409
410     An optional errorCallback function can be specified to
411     subsequently receive warning and error messages.
412   */
413   RtAudio( RtAudio::Api api=UNSPECIFIED, RtAudioErrorCallback errorCallback=0 );
414
415   //! The destructor.
416   /*!
417     If a stream is running or open, it will be stopped and closed
418     automatically.
419   */
420   ~RtAudio();
421
422   //! Returns the audio API specifier for the current instance of RtAudio.
423   RtAudio::Api getCurrentApi( void );
424
425   //! A public function that queries for the number of audio devices available.
426   /*!
427     This function performs a system query of available devices each time it
428     is called, thus supporting devices connected \e after instantiation. If
429     a system error occurs during processing, a warning will be issued. 
430   */
431   unsigned int getDeviceCount( void );
432
433   //! Return an RtAudio::DeviceInfo structure for a specified device number.
434   /*!
435     Any device integer between 0 and getDeviceCount() - 1 is valid.
436     If an invalid argument is provided, an RTAUDIO_INVALID_USE
437     will be passed to the user-provided errorCallback function (or
438     otherwise printed to stderr), the structure member "probed" will
439     have a value of "false" and all other members will be undefined.
440     If a device is busy or otherwise unavailable, the structure member
441     "probed" will have a value of "false" and all other members will
442     be undefined.  If the specified device is the current default
443     input or output device, the corresponding "isDefault" member will
444     have a value of "true".
445   */
446   RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
447
448   //! A function that returns the index of the default output device.
449   /*!
450     If the underlying audio API does not provide a "default
451     device", or if no devices are available, the return value will be
452     0.  Note that this is a valid device identifier and it is the
453     client's responsibility to verify that a device is available
454     before attempting to open a stream.
455   */
456   unsigned int getDefaultOutputDevice( void );
457
458   //! A function that returns the index of the default input device.
459   /*!
460     If the underlying audio API does not provide a "default
461     device", or if no devices are available, the return value will be
462     0.  Note that this is a valid device identifier and it is the
463     client's responsibility to verify that a device is available
464     before attempting to open a stream.
465   */
466   unsigned int getDefaultInputDevice( void );
467
468   //! A public function for opening a stream with the specified parameters.
469   /*!
470     An RTAUDIO_SYSTEM_ERROR is returned if a stream cannot be
471     opened with the specified parameters or an error occurs during
472     processing.  An RTAUDIO_INVALID_USE is returned if a stream
473     is already open or any invalid stream parameters are specified.
474
475     \param outputParameters Specifies output stream parameters to use
476            when opening a stream, including a device ID, number of channels,
477            and starting channel number.  For input-only streams, this
478            argument should be NULL.  The device ID is an index value between
479            0 and getDeviceCount() - 1.
480     \param inputParameters Specifies input stream parameters to use
481            when opening a stream, including a device ID, number of channels,
482            and starting channel number.  For output-only streams, this
483            argument should be NULL.  The device ID is an index value between
484            0 and getDeviceCount() - 1.
485     \param format An RtAudioFormat specifying the desired sample data format.
486     \param sampleRate The desired sample rate (sample frames per second).
487     \param bufferFrames A pointer to a value indicating the desired
488            internal buffer size in sample frames.  The actual value
489            used by the device is returned via the same pointer.  A
490            value of zero can be specified, in which case the lowest
491            allowable value is determined.
492     \param callback A client-defined function that will be invoked
493            when input data is available and/or output data is needed.
494     \param userData An optional pointer to data that can be accessed
495            from within the callback function.
496     \param options An optional pointer to a structure containing various
497            global stream options, including a list of OR'ed RtAudioStreamFlags
498            and a suggested number of stream buffers that can be used to 
499            control stream latency.  More buffers typically result in more
500            robust performance, though at a cost of greater latency.  If a
501            value of zero is specified, a system-specific median value is
502            chosen.  If the RTAUDIO_MINIMIZE_LATENCY flag bit is set, the
503            lowest allowable value is used.  The actual value used is
504            returned via the structure argument.  The parameter is API dependent.
505   */
506   RtAudioErrorType openStream( RtAudio::StreamParameters *outputParameters,
507                                RtAudio::StreamParameters *inputParameters,
508                                RtAudioFormat format, unsigned int sampleRate,
509                                unsigned int *bufferFrames, RtAudioCallback callback,
510                                void *userData = NULL, RtAudio::StreamOptions *options = NULL );
511
512   //! A function that closes a stream and frees any associated stream memory.
513   /*!
514     If a stream is not open, an RTAUDIO_WARNING will be passed to the
515     user-provided errorCallback function (or otherwise printed to
516     stderr).
517   */
518   void closeStream( void );
519
520   //! A function that starts a stream.
521   /*!
522     An RTAUDIO_SYSTEM_ERROR is returned if an error occurs during
523     processing. An RTAUDIO_WARNING is returned if a stream is not open
524     or is already running.
525   */
526   RtAudioErrorType startStream( void );
527
528   //! Stop a stream, allowing any samples remaining in the output queue to be played.
529   /*!
530     An RTAUDIO_SYSTEM_ERROR is returned if an error occurs during
531     processing.  An RTAUDIO_WARNING is returned if a stream is not
532     open or is already stopped.
533   */
534   RtAudioErrorType stopStream( void );
535
536   //! Stop a stream, discarding any samples remaining in the input/output queue.
537   /*!
538     An RTAUDIO_SYSTEM_ERROR is returned if an error occurs during
539     processing.  An RTAUDIO_WARNING is returned if a stream is not
540     open or is already stopped.
541   */
542   RtAudioErrorType abortStream( void );
543
544   //! Returns true if a stream is open and false if not.
545   bool isStreamOpen( void ) const;
546
547   //! Returns true if the stream is running and false if it is stopped or not open.
548   bool isStreamRunning( void ) const;
549
550   //! Returns the number of seconds of processed data since the stream was started.
551   /*!
552     The stream time is calculated from the number of sample frames
553     processed by the underlying audio system, which will increment by
554     units of the audio buffer size. It is not an absolute running
555     time. If a stream is not open, the returned value may not be
556     valid.
557   */
558   double getStreamTime( void );
559
560   //! Set the stream time to a time in seconds greater than or equal to 0.0.
561   void setStreamTime( double time );
562
563   //! Returns the internal stream latency in sample frames.
564   /*!
565     The stream latency refers to delay in audio input and/or output
566     caused by internal buffering by the audio system and/or hardware.
567     For duplex streams, the returned value will represent the sum of
568     the input and output latencies.  If a stream is not open, the
569     returned value will be invalid.  If the API does not report
570     latency, the return value will be zero.
571   */
572   long getStreamLatency( void );
573
574   //! Returns actual sample rate in use by the (open) stream.
575   /*!
576     On some systems, the sample rate used may be slightly different
577     than that specified in the stream parameters.  If a stream is not
578     open, a value of zero is returned.
579   */
580   unsigned int getStreamSampleRate( void );
581
582   //! Set a client-defined function that will be invoked when an error or warning occurs.
583   void setErrorCallback( RtAudioErrorCallback errorCallback );
584
585   //! Specify whether warning messages should be output or not.
586   /*!
587     The default behaviour is for warning messages to be output,
588     either to a client-defined error callback function (if specified)
589     or to stderr.
590   */
591   void showWarnings( bool value = true );
592
593  protected:
594
595   void openRtApi( RtAudio::Api api );
596   RtApi *rtapi_;
597 };
598
599 // Operating system dependent thread functionality.
600 #if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) || defined(__WINDOWS_WASAPI__)
601
602   #ifndef NOMINMAX
603     #define NOMINMAX
604   #endif
605   #include <windows.h>
606   #include <process.h>
607   #include <stdint.h>
608
609   typedef uintptr_t ThreadHandle;
610   typedef CRITICAL_SECTION StreamMutex;
611
612 #elif defined(__LINUX_ALSA__) || defined(__LINUX_PULSE__) || defined(__UNIX_JACK__) || defined(__LINUX_OSS__) || defined(__MACOSX_CORE__)
613   // Using pthread library for various flavors of unix.
614   #include <pthread.h>
615
616   typedef pthread_t ThreadHandle;
617   typedef pthread_mutex_t StreamMutex;
618
619 #else // Setup for "dummy" behavior
620
621   #define __RTAUDIO_DUMMY__
622   typedef int ThreadHandle;
623   typedef int StreamMutex;
624
625 #endif
626
627 // This global structure type is used to pass callback information
628 // between the private RtAudio stream structure and global callback
629 // handling functions.
630 struct CallbackInfo {
631   void *object;    // Used as a "this" pointer.
632   ThreadHandle thread;
633   void *callback;
634   void *userData;
635   void *apiInfo;   // void pointer for API specific callback information
636   bool isRunning;
637   bool doRealtime;
638   int priority;
639   bool deviceDisconnected;
640
641   // Default constructor.
642   CallbackInfo()
643   :object(0), callback(0), userData(0), apiInfo(0), isRunning(false), doRealtime(false), priority(0), deviceDisconnected(false) {}
644 };
645
646 // **************************************************************** //
647 //
648 // RtApi class declaration.
649 //
650 // Subclasses of RtApi contain all API- and OS-specific code necessary
651 // to fully implement the RtAudio API.
652 //
653 // Note that RtApi is an abstract base class and cannot be
654 // explicitly instantiated.  The class RtAudio will create an
655 // instance of an RtApi subclass (RtApiOss, RtApiAlsa,
656 // RtApiJack, RtApiCore, RtApiDs, or RtApiAsio).
657 //
658 // **************************************************************** //
659
660 #pragma pack(push, 1)
661 class S24 {
662
663  protected:
664   unsigned char c3[3];
665
666  public:
667   S24() {}
668
669   S24& operator = ( const int& i ) {
670     c3[0] = (i & 0x000000ff);
671     c3[1] = (i & 0x0000ff00) >> 8;
672     c3[2] = (i & 0x00ff0000) >> 16;
673     return *this;
674   }
675
676   S24( const double& d ) { *this = (int) d; }
677   S24( const float& f ) { *this = (int) f; }
678   S24( const signed short& s ) { *this = (int) s; }
679   S24( const char& c ) { *this = (int) c; }
680
681   int asInt() {
682     int i = c3[0] | (c3[1] << 8) | (c3[2] << 16);
683     if (i & 0x800000) i |= ~0xffffff;
684     return i;
685   }
686 };
687 #pragma pack(pop)
688
689 #if defined( HAVE_GETTIMEOFDAY )
690   #include <sys/time.h>
691 #endif
692
693 #include <sstream>
694
695 class RTAUDIO_DLL_PUBLIC RtApi
696 {
697 public:
698
699   RtApi();
700   virtual ~RtApi();
701   virtual RtAudio::Api getCurrentApi( void ) = 0;
702   virtual unsigned int getDeviceCount( void ) = 0;
703   virtual RtAudio::DeviceInfo getDeviceInfo( unsigned int device ) = 0;
704   virtual unsigned int getDefaultInputDevice( void );
705   virtual unsigned int getDefaultOutputDevice( void );
706   RtAudioErrorType openStream( RtAudio::StreamParameters *outputParameters,
707                                  RtAudio::StreamParameters *inputParameters,
708                                  RtAudioFormat format, unsigned int sampleRate,
709                                  unsigned int *bufferFrames, RtAudioCallback callback,
710                                  void *userData, RtAudio::StreamOptions *options );
711   virtual void closeStream( void );
712   virtual RtAudioErrorType startStream( void ) = 0;
713   virtual RtAudioErrorType stopStream( void ) = 0;
714   virtual RtAudioErrorType abortStream( void ) = 0;
715   long getStreamLatency( void );
716   unsigned int getStreamSampleRate( void );
717   virtual double getStreamTime( void ) const { return stream_.streamTime; }
718   virtual void setStreamTime( double time );
719   bool isStreamOpen( void ) const { return stream_.state != STREAM_CLOSED; }
720   bool isStreamRunning( void ) const { return stream_.state == STREAM_RUNNING; }
721   void setErrorCallback( RtAudioErrorCallback errorCallback ) { errorCallback_ = errorCallback; }
722   void showWarnings( bool value ) { showWarnings_ = value; }
723
724
725 protected:
726
727   static const unsigned int MAX_SAMPLE_RATES;
728   static const unsigned int SAMPLE_RATES[];
729
730   enum { FAILURE, SUCCESS };
731
732   enum StreamState {
733     STREAM_STOPPED,
734     STREAM_STOPPING,
735     STREAM_RUNNING,
736     STREAM_CLOSED = -50
737   };
738
739   enum StreamMode {
740     OUTPUT,
741     INPUT,
742     DUPLEX,
743     UNINITIALIZED = -75
744   };
745
746   // A protected structure used for buffer conversion.
747   struct ConvertInfo {
748     int channels;
749     int inJump, outJump;
750     RtAudioFormat inFormat, outFormat;
751     std::vector<int> inOffset;
752     std::vector<int> outOffset;
753   };
754
755   // A protected structure for audio streams.
756   struct RtApiStream {
757     unsigned int device[2];    // Playback and record, respectively.
758     void *apiHandle;           // void pointer for API specific stream handle information
759     StreamMode mode;           // OUTPUT, INPUT, or DUPLEX.
760     StreamState state;         // STOPPED, RUNNING, or CLOSED
761     char *userBuffer[2];       // Playback and record, respectively.
762     char *deviceBuffer;
763     bool doConvertBuffer[2];   // Playback and record, respectively.
764     bool userInterleaved;
765     bool deviceInterleaved[2]; // Playback and record, respectively.
766     bool doByteSwap[2];        // Playback and record, respectively.
767     unsigned int sampleRate;
768     unsigned int bufferSize;
769     unsigned int nBuffers;
770     unsigned int nUserChannels[2];    // Playback and record, respectively.
771     unsigned int nDeviceChannels[2];  // Playback and record channels, respectively.
772     unsigned int channelOffset[2];    // Playback and record, respectively.
773     unsigned long latency[2];         // Playback and record, respectively.
774     RtAudioFormat userFormat;
775     RtAudioFormat deviceFormat[2];    // Playback and record, respectively.
776     StreamMutex mutex;
777     CallbackInfo callbackInfo;
778     ConvertInfo convertInfo[2];
779     double streamTime;         // Number of elapsed seconds since the stream started.
780
781 #if defined(HAVE_GETTIMEOFDAY)
782     struct timeval lastTickTimestamp;
783 #endif
784
785     RtApiStream()
786       :apiHandle(0), deviceBuffer(0) { device[0] = 11111; device[1] = 11111; }
787   };
788
789   typedef S24 Int24;
790   typedef signed short Int16;
791   typedef signed int Int32;
792   typedef float Float32;
793   typedef double Float64;
794
795   std::ostringstream errorStream_;
796   std::string errorText_;
797   RtAudioErrorCallback errorCallback_;
798   bool showWarnings_;
799   RtApiStream stream_;
800
801   /*!
802     Protected, api-specific method that attempts to open a device
803     with the given parameters.  This function MUST be implemented by
804     all subclasses.  If an error is encountered during the probe, a
805     "warning" message is reported and FAILURE is returned. A
806     successful probe is indicated by a return value of SUCCESS.
807   */
808   virtual bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, 
809                                 unsigned int firstChannel, unsigned int sampleRate,
810                                 RtAudioFormat format, unsigned int *bufferSize,
811                                 RtAudio::StreamOptions *options );
812
813   //! A protected function used to increment the stream time.
814   void tickStreamTime( void );
815
816   //! Protected common method to clear an RtApiStream structure.
817   void clearStreamInfo();
818
819   //! Protected common error method to allow global control over error handling.
820   RtAudioErrorType error( RtAudioErrorType type );
821
822   /*!
823     Protected method used to perform format, channel number, and/or interleaving
824     conversions between the user and device buffers.
825   */
826   void convertBuffer( char *outBuffer, char *inBuffer, ConvertInfo &info );
827
828   //! Protected common method used to perform byte-swapping on buffers.
829   void byteSwapBuffer( char *buffer, unsigned int samples, RtAudioFormat format );
830
831   //! Protected common method that returns the number of bytes for a given format.
832   unsigned int formatBytes( RtAudioFormat format );
833
834   //! Protected common method that sets up the parameters for buffer conversion.
835   void setConvertInfo( StreamMode mode, unsigned int firstChannel );
836 };
837
838 // **************************************************************** //
839 //
840 // Inline RtAudio definitions.
841 //
842 // **************************************************************** //
843
844 inline RtAudio::Api RtAudio :: getCurrentApi( void ) { return rtapi_->getCurrentApi(); }
845 inline unsigned int RtAudio :: getDeviceCount( void ) { return rtapi_->getDeviceCount(); }
846 inline RtAudio::DeviceInfo RtAudio :: getDeviceInfo( unsigned int device ) { return rtapi_->getDeviceInfo( device ); }
847 inline unsigned int RtAudio :: getDefaultInputDevice( void ) { return rtapi_->getDefaultInputDevice(); }
848 inline unsigned int RtAudio :: getDefaultOutputDevice( void ) { return rtapi_->getDefaultOutputDevice(); }
849 inline void RtAudio :: closeStream( void ) { return rtapi_->closeStream(); }
850 inline RtAudioErrorType RtAudio :: startStream( void ) { return rtapi_->startStream(); }
851 inline RtAudioErrorType RtAudio :: stopStream( void )  { return rtapi_->stopStream(); }
852 inline RtAudioErrorType RtAudio :: abortStream( void ) { return rtapi_->abortStream(); }
853 inline bool RtAudio :: isStreamOpen( void ) const { return rtapi_->isStreamOpen(); }
854 inline bool RtAudio :: isStreamRunning( void ) const { return rtapi_->isStreamRunning(); }
855 inline long RtAudio :: getStreamLatency( void ) { return rtapi_->getStreamLatency(); }
856 inline unsigned int RtAudio :: getStreamSampleRate( void ) { return rtapi_->getStreamSampleRate(); }
857 inline double RtAudio :: getStreamTime( void ) { return rtapi_->getStreamTime(); }
858 inline void RtAudio :: setStreamTime( double time ) { return rtapi_->setStreamTime( time ); }
859 inline void RtAudio :: setErrorCallback( RtAudioErrorCallback errorCallback ) { rtapi_->setErrorCallback( errorCallback ); }
860 inline void RtAudio :: showWarnings( bool value ) { rtapi_->showWarnings( value ); }
861
862 // RtApi Subclass prototypes.
863
864 #if defined(__MACOSX_CORE__)
865
866 #include <CoreAudio/AudioHardware.h>
867
868 class RtApiCore: public RtApi
869 {
870 public:
871
872   RtApiCore();
873   ~RtApiCore();
874   RtAudio::Api getCurrentApi( void ) { return RtAudio::MACOSX_CORE; }
875   unsigned int getDeviceCount( void );
876   RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
877   unsigned int getDefaultOutputDevice( void );
878   unsigned int getDefaultInputDevice( void );
879   void closeStream( void );
880   RtAudioErrorType startStream( void );
881   RtAudioErrorType stopStream( void );
882   RtAudioErrorType abortStream( void );
883
884   // This function is intended for internal use only.  It must be
885   // public because it is called by the internal callback handler,
886   // which is not a member of RtAudio.  External use of this function
887   // will most likely produce highly undesireable results!
888   bool callbackEvent( AudioDeviceID deviceId,
889                       const AudioBufferList *inBufferList,
890                       const AudioBufferList *outBufferList );
891
892   private:
893
894   bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, 
895                         unsigned int firstChannel, unsigned int sampleRate,
896                         RtAudioFormat format, unsigned int *bufferSize,
897                         RtAudio::StreamOptions *options );
898   static const char* getErrorCode( OSStatus code );
899 };
900
901 #endif
902
903 #if defined(__UNIX_JACK__)
904
905 class RtApiJack: public RtApi
906 {
907 public:
908
909   RtApiJack();
910   ~RtApiJack();
911   RtAudio::Api getCurrentApi( void ) { return RtAudio::UNIX_JACK; }
912   unsigned int getDeviceCount( void );
913   RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
914   void closeStream( void );
915   RtAudioErrorType startStream( void );
916   RtAudioErrorType stopStream( void );
917   RtAudioErrorType abortStream( void );
918
919   // This function is intended for internal use only.  It must be
920   // public because it is called by the internal callback handler,
921   // which is not a member of RtAudio.  External use of this function
922   // will most likely produce highly undesireable results!
923   bool callbackEvent( unsigned long nframes );
924
925   private:
926
927   bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, 
928                         unsigned int firstChannel, unsigned int sampleRate,
929                         RtAudioFormat format, unsigned int *bufferSize,
930                         RtAudio::StreamOptions *options );
931
932   bool shouldAutoconnect_;
933 };
934
935 #endif
936
937 #if defined(__WINDOWS_ASIO__)
938
939 class RtApiAsio: public RtApi
940 {
941 public:
942
943   RtApiAsio();
944   ~RtApiAsio();
945   RtAudio::Api getCurrentApi( void ) { return RtAudio::WINDOWS_ASIO; }
946   unsigned int getDeviceCount( void );
947   RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
948   void closeStream( void );
949   void startStream( void );
950   void stopStream( void );
951   void abortStream( void );
952
953   // This function is intended for internal use only.  It must be
954   // public because it is called by the internal callback handler,
955   // which is not a member of RtAudio.  External use of this function
956   // will most likely produce highly undesireable results!
957   bool callbackEvent( long bufferIndex );
958
959   private:
960
961   std::vector<RtAudio::DeviceInfo> devices_;
962   void saveDeviceInfo( void );
963   bool coInitialized_;
964   bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, 
965                         unsigned int firstChannel, unsigned int sampleRate,
966                         RtAudioFormat format, unsigned int *bufferSize,
967                         RtAudio::StreamOptions *options );
968 };
969
970 #endif
971
972 #if defined(__WINDOWS_DS__)
973
974 class RtApiDs: public RtApi
975 {
976 public:
977
978   RtApiDs();
979   ~RtApiDs();
980   RtAudio::Api getCurrentApi( void ) { return RtAudio::WINDOWS_DS; }
981   unsigned int getDeviceCount( void );
982   unsigned int getDefaultOutputDevice( void );
983   unsigned int getDefaultInputDevice( void );
984   RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
985   void closeStream( void );
986   void startStream( void );
987   void stopStream( void );
988   void abortStream( void );
989
990   // This function is intended for internal use only.  It must be
991   // public because it is called by the internal callback handler,
992   // which is not a member of RtAudio.  External use of this function
993   // will most likely produce highly undesireable results!
994   void callbackEvent( void );
995
996   private:
997
998   bool coInitialized_;
999   bool buffersRolling;
1000   long duplexPrerollBytes;
1001   std::vector<struct DsDevice> dsDevices;
1002   bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, 
1003                         unsigned int firstChannel, unsigned int sampleRate,
1004                         RtAudioFormat format, unsigned int *bufferSize,
1005                         RtAudio::StreamOptions *options );
1006 };
1007
1008 #endif
1009
1010 #if defined(__WINDOWS_WASAPI__)
1011
1012 struct IMMDeviceEnumerator;
1013
1014 class RtApiWasapi : public RtApi
1015 {
1016 public:
1017   RtApiWasapi();
1018   virtual ~RtApiWasapi();
1019
1020   RtAudio::Api getCurrentApi( void ) { return RtAudio::WINDOWS_WASAPI; }
1021   unsigned int getDeviceCount( void );
1022   RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
1023   unsigned int getDefaultOutputDevice( void );
1024   unsigned int getDefaultInputDevice( void );
1025   void closeStream( void );
1026   void startStream( void );
1027   void stopStream( void );
1028   void abortStream( void );
1029
1030 private:
1031   bool coInitialized_;
1032   IMMDeviceEnumerator* deviceEnumerator_;
1033
1034   bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
1035                         unsigned int firstChannel, unsigned int sampleRate,
1036                         RtAudioFormat format, unsigned int* bufferSize,
1037                         RtAudio::StreamOptions* options );
1038
1039   static DWORD WINAPI runWasapiThread( void* wasapiPtr );
1040   static DWORD WINAPI stopWasapiThread( void* wasapiPtr );
1041   static DWORD WINAPI abortWasapiThread( void* wasapiPtr );
1042   void wasapiThread();
1043 };
1044
1045 #endif
1046
1047 #if defined(__LINUX_ALSA__)
1048
1049 class RtApiAlsa: public RtApi
1050 {
1051 public:
1052
1053   RtApiAlsa();
1054   ~RtApiAlsa();
1055   RtAudio::Api getCurrentApi() { return RtAudio::LINUX_ALSA; }
1056   unsigned int getDeviceCount( void );
1057   RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
1058   void closeStream( void );
1059   void startStream( void );
1060   void stopStream( void );
1061   void abortStream( void );
1062
1063   // This function is intended for internal use only.  It must be
1064   // public because it is called by the internal callback handler,
1065   // which is not a member of RtAudio.  External use of this function
1066   // will most likely produce highly undesireable results!
1067   void callbackEvent( void );
1068
1069   private:
1070
1071   std::vector<RtAudio::DeviceInfo> devices_;
1072   void saveDeviceInfo( void );
1073   bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, 
1074                         unsigned int firstChannel, unsigned int sampleRate,
1075                         RtAudioFormat format, unsigned int *bufferSize,
1076                         RtAudio::StreamOptions *options );
1077 };
1078
1079 #endif
1080
1081 #if defined(__LINUX_PULSE__)
1082
1083 class RtApiPulse: public RtApi
1084 {
1085 public:
1086   ~RtApiPulse();
1087   RtAudio::Api getCurrentApi() { return RtAudio::LINUX_PULSE; }
1088   unsigned int getDeviceCount( void );
1089   RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
1090   void closeStream( void );
1091   void startStream( void );
1092   void stopStream( void );
1093   void abortStream( void );
1094
1095   // This function is intended for internal use only.  It must be
1096   // public because it is called by the internal callback handler,
1097   // which is not a member of RtAudio.  External use of this function
1098   // will most likely produce highly undesireable results!
1099   void callbackEvent( void );
1100
1101   private:
1102
1103   std::vector<RtAudio::DeviceInfo> devices_;
1104   void saveDeviceInfo( void );
1105   bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
1106                         unsigned int firstChannel, unsigned int sampleRate,
1107                         RtAudioFormat format, unsigned int *bufferSize,
1108                         RtAudio::StreamOptions *options );
1109 };
1110
1111 #endif
1112
1113 #if defined(__LINUX_OSS__)
1114
1115 class RtApiOss: public RtApi
1116 {
1117 public:
1118
1119   RtApiOss();
1120   ~RtApiOss();
1121   RtAudio::Api getCurrentApi() { return RtAudio::LINUX_OSS; }
1122   unsigned int getDeviceCount( void );
1123   RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
1124   void closeStream( void );
1125   void startStream( void );
1126   void stopStream( void );
1127   void abortStream( void );
1128
1129   // This function is intended for internal use only.  It must be
1130   // public because it is called by the internal callback handler,
1131   // which is not a member of RtAudio.  External use of this function
1132   // will most likely produce highly undesireable results!
1133   void callbackEvent( void );
1134
1135   private:
1136
1137   bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, 
1138                         unsigned int firstChannel, unsigned int sampleRate,
1139                         RtAudioFormat format, unsigned int *bufferSize,
1140                         RtAudio::StreamOptions *options );
1141 };
1142
1143 #endif
1144
1145 #if defined(__RTAUDIO_DUMMY__)
1146
1147 class RtApiDummy: public RtApi
1148 {
1149 public:
1150
1151   RtApiDummy() { errorText_ = "RtApiDummy: This class provides no functionality."; error( RTAUDIO_WARNING ); }
1152   RtAudio::Api getCurrentApi( void ) { return RtAudio::RTAUDIO_DUMMY; }
1153   unsigned int getDeviceCount( void ) { return 0; }
1154   RtAudio::DeviceInfo getDeviceInfo( unsigned int /*device*/ ) { RtAudio::DeviceInfo info; return info; }
1155   void closeStream( void ) {}
1156   RtAudioErrorType startStream( void ) { return RTAUDIO_NO_ERROR; }
1157   RtAudioErrorType stopStream( void ) { return RTAUDIO_NO_ERROR; }
1158   RtAudioErrorType abortStream( void ) { return RTAUDIO_NO_ERROR; }
1159
1160   private:
1161
1162   bool probeDeviceOpen( unsigned int /*device*/, StreamMode /*mode*/, unsigned int /*channels*/, 
1163                         unsigned int /*firstChannel*/, unsigned int /*sampleRate*/,
1164                         RtAudioFormat /*format*/, unsigned int * /*bufferSize*/,
1165                         RtAudio::StreamOptions * /*options*/ ) { return false; }
1166 };
1167
1168 #endif
1169
1170 #endif
1171
1172 // Indentation settings for Vim and Emacs
1173 //
1174 // Local Variables:
1175 // c-basic-offset: 2
1176 // indent-tabs-mode: nil
1177 // End:
1178 //
1179 // vim: et sts=2 sw=2