Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1179 lines
46KB

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