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.

1181 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. #if defined(__GNUC__) && __GNUC__ < 8
  558. S24( const S24& v ) { *this = v; }
  559. #endif
  560. S24( const double& d ) { *this = (int) d; }
  561. S24( const float& f ) { *this = (int) f; }
  562. S24( const signed short& s ) { *this = (int) s; }
  563. S24( const char& c ) { *this = (int) c; }
  564. int asInt() {
  565. int i = c3[0] | (c3[1] << 8) | (c3[2] << 16);
  566. if (i & 0x800000) i |= ~0xffffff;
  567. return i;
  568. }
  569. };
  570. #pragma pack(pop)
  571. #if defined( HAVE_GETTIMEOFDAY )
  572. #include <sys/time.h>
  573. #endif
  574. #include <sstream>
  575. class RTAUDIO_DLL_PUBLIC RtApi
  576. {
  577. public:
  578. RtApi();
  579. virtual ~RtApi();
  580. virtual RtAudio::Api getCurrentApi( void ) const = 0;
  581. virtual unsigned int getDeviceCount( void ) = 0;
  582. virtual RtAudio::DeviceInfo getDeviceInfo( unsigned int device ) = 0;
  583. virtual unsigned int getDefaultInputDevice( void );
  584. virtual unsigned int getDefaultOutputDevice( void );
  585. void openStream( RtAudio::StreamParameters *outputParameters,
  586. RtAudio::StreamParameters *inputParameters,
  587. RtAudioFormat format, unsigned int sampleRate,
  588. unsigned int *bufferFrames, RtAudioCallback callback,
  589. void *userData, RtAudio::StreamOptions *options,
  590. RtAudioBufferSizeCallback bufSizeCallback,
  591. RtAudioErrorCallback errorCallback );
  592. virtual void closeStream( void );
  593. virtual void startStream( void ) = 0;
  594. virtual void stopStream( void ) = 0;
  595. virtual void abortStream( void ) = 0;
  596. long getStreamLatency( void );
  597. unsigned int getStreamSampleRate( void );
  598. virtual double getStreamTime( void );
  599. virtual void setStreamTime( double time );
  600. bool isStreamOpen( void ) const { return stream_.state != STREAM_CLOSED; }
  601. bool isStreamRunning( void ) const { return stream_.state == STREAM_RUNNING; }
  602. void showWarnings( bool value ) { showWarnings_ = value; }
  603. protected:
  604. static const unsigned int MAX_SAMPLE_RATES;
  605. static const unsigned int SAMPLE_RATES[];
  606. enum { FAILURE, SUCCESS };
  607. enum StreamState {
  608. STREAM_STOPPED,
  609. STREAM_STOPPING,
  610. STREAM_RUNNING,
  611. STREAM_CLOSED = -50
  612. };
  613. enum StreamMode {
  614. OUTPUT,
  615. INPUT,
  616. DUPLEX,
  617. UNINITIALIZED = -75
  618. };
  619. // A protected structure used for buffer conversion.
  620. struct ConvertInfo {
  621. int channels;
  622. int inJump, outJump;
  623. RtAudioFormat inFormat, outFormat;
  624. std::vector<int> inOffset;
  625. std::vector<int> outOffset;
  626. };
  627. // A protected structure for audio streams.
  628. struct RtApiStream {
  629. unsigned int device[2]; // Playback and record, respectively.
  630. void *apiHandle; // void pointer for API specific stream handle information
  631. StreamMode mode; // OUTPUT, INPUT, or DUPLEX.
  632. StreamState state; // STOPPED, RUNNING, or CLOSED
  633. char *userBuffer[2]; // Playback and record, respectively.
  634. char *deviceBuffer;
  635. bool doConvertBuffer[2]; // Playback and record, respectively.
  636. bool userInterleaved;
  637. bool deviceInterleaved[2]; // Playback and record, respectively.
  638. bool doByteSwap[2]; // Playback and record, respectively.
  639. unsigned int sampleRate;
  640. unsigned int bufferSize;
  641. unsigned int nBuffers;
  642. unsigned int nUserChannels[2]; // Playback and record, respectively.
  643. unsigned int nDeviceChannels[2]; // Playback and record channels, respectively.
  644. unsigned int channelOffset[2]; // Playback and record, respectively.
  645. unsigned long latency[2]; // Playback and record, respectively.
  646. RtAudioFormat userFormat;
  647. RtAudioFormat deviceFormat[2]; // Playback and record, respectively.
  648. StreamMutex mutex;
  649. CallbackInfo callbackInfo;
  650. ConvertInfo convertInfo[2];
  651. double streamTime; // Number of elapsed seconds since the stream started.
  652. #if defined(HAVE_GETTIMEOFDAY)
  653. struct timeval lastTickTimestamp;
  654. #endif
  655. RtApiStream()
  656. :apiHandle(0), deviceBuffer(0) { device[0] = 11111; device[1] = 11111; }
  657. };
  658. typedef S24 Int24;
  659. typedef signed short Int16;
  660. typedef signed int Int32;
  661. typedef float Float32;
  662. typedef double Float64;
  663. std::ostringstream errorStream_;
  664. std::string errorText_;
  665. bool showWarnings_;
  666. RtApiStream stream_;
  667. bool firstErrorOccurred_;
  668. /*!
  669. Protected, api-specific method that attempts to open a device
  670. with the given parameters. This function MUST be implemented by
  671. all subclasses. If an error is encountered during the probe, a
  672. "warning" message is reported and FAILURE is returned. A
  673. successful probe is indicated by a return value of SUCCESS.
  674. */
  675. virtual bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
  676. unsigned int firstChannel, unsigned int sampleRate,
  677. RtAudioFormat format, unsigned int *bufferSize,
  678. RtAudio::StreamOptions *options );
  679. //! A protected function used to increment the stream time.
  680. void tickStreamTime( void );
  681. //! Protected common method to clear an RtApiStream structure.
  682. void clearStreamInfo();
  683. /*!
  684. Protected common method that throws an RtAudioError (type =
  685. INVALID_USE) if a stream is not open.
  686. */
  687. void verifyStream( void );
  688. //! Protected common error method to allow global control over error handling.
  689. void error( RtAudioError::Type type );
  690. /*!
  691. Protected method used to perform format, channel number, and/or interleaving
  692. conversions between the user and device buffers.
  693. */
  694. void convertBuffer( char *outBuffer, char *inBuffer, ConvertInfo &info );
  695. //! Protected common method used to perform byte-swapping on buffers.
  696. void byteSwapBuffer( char *buffer, unsigned int samples, RtAudioFormat format );
  697. //! Protected common method that returns the number of bytes for a given format.
  698. unsigned int formatBytes( RtAudioFormat format );
  699. //! Protected common method that sets up the parameters for buffer conversion.
  700. void setConvertInfo( StreamMode mode, unsigned int firstChannel );
  701. };
  702. // **************************************************************** //
  703. //
  704. // Inline RtAudio definitions.
  705. //
  706. // **************************************************************** //
  707. inline RtAudio::Api RtAudio :: getCurrentApi( void ) const { return rtapi_->getCurrentApi(); }
  708. inline unsigned int RtAudio :: getDeviceCount( void ) { return rtapi_->getDeviceCount(); }
  709. inline RtAudio::DeviceInfo RtAudio :: getDeviceInfo( unsigned int device ) { return rtapi_->getDeviceInfo( device ); }
  710. inline unsigned int RtAudio :: getDefaultInputDevice( void ) { return rtapi_->getDefaultInputDevice(); }
  711. inline unsigned int RtAudio :: getDefaultOutputDevice( void ) { return rtapi_->getDefaultOutputDevice(); }
  712. inline void RtAudio :: closeStream( void ) { return rtapi_->closeStream(); }
  713. inline void RtAudio :: startStream( void ) { return rtapi_->startStream(); }
  714. inline void RtAudio :: stopStream( void ) { return rtapi_->stopStream(); }
  715. inline void RtAudio :: abortStream( void ) { return rtapi_->abortStream(); }
  716. inline bool RtAudio :: isStreamOpen( void ) const { return rtapi_->isStreamOpen(); }
  717. inline bool RtAudio :: isStreamRunning( void ) const { return rtapi_->isStreamRunning(); }
  718. inline long RtAudio :: getStreamLatency( void ) { return rtapi_->getStreamLatency(); }
  719. inline unsigned int RtAudio :: getStreamSampleRate( void ) { return rtapi_->getStreamSampleRate(); }
  720. inline double RtAudio :: getStreamTime( void ) { return rtapi_->getStreamTime(); }
  721. inline void RtAudio :: setStreamTime( double time ) { return rtapi_->setStreamTime( time ); }
  722. inline void RtAudio :: showWarnings( bool value ) { rtapi_->showWarnings( value ); }
  723. // RtApi Subclass prototypes.
  724. #if defined(__MACOSX_CORE__)
  725. #include <CoreAudio/AudioHardware.h>
  726. class RtApiCore: public RtApi
  727. {
  728. public:
  729. RtApiCore();
  730. ~RtApiCore();
  731. RtAudio::Api getCurrentApi( void ) const { return RtAudio::MACOSX_CORE; }
  732. unsigned int getDeviceCount( void );
  733. RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
  734. unsigned int getDefaultOutputDevice( void );
  735. unsigned int getDefaultInputDevice( void );
  736. void closeStream( void );
  737. void startStream( void );
  738. void stopStream( void );
  739. void abortStream( void );
  740. long getStreamLatency( void );
  741. // This function is intended for internal use only. It must be
  742. // public because it is called by the internal callback handler,
  743. // which is not a member of RtAudio. External use of this function
  744. // will most likely produce highly undesireable results!
  745. bool callbackEvent( AudioDeviceID deviceId,
  746. const AudioBufferList *inBufferList,
  747. const AudioBufferList *outBufferList );
  748. private:
  749. bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
  750. unsigned int firstChannel, unsigned int sampleRate,
  751. RtAudioFormat format, unsigned int *bufferSize,
  752. RtAudio::StreamOptions *options );
  753. static const char* getErrorCode( OSStatus code );
  754. };
  755. #endif
  756. #if defined(__UNIX_JACK__)
  757. class RtApiJack: public RtApi
  758. {
  759. public:
  760. RtApiJack();
  761. ~RtApiJack();
  762. RtAudio::Api getCurrentApi( void ) const { return RtAudio::UNIX_JACK; }
  763. unsigned int getDeviceCount( void );
  764. RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
  765. void closeStream( void );
  766. void startStream( void );
  767. void stopStream( void );
  768. void abortStream( void );
  769. long getStreamLatency( void );
  770. // This function is intended for internal use only. It must be
  771. // public because it is called by the internal callback handler,
  772. // which is not a member of RtAudio. External use of this function
  773. // will most likely produce highly undesireable results!
  774. bool callbackEvent( unsigned long nframes );
  775. // Buffer size change callback
  776. bool bufferSizeEvent( unsigned long nframes );
  777. private:
  778. bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
  779. unsigned int firstChannel, unsigned int sampleRate,
  780. RtAudioFormat format, unsigned int *bufferSize,
  781. RtAudio::StreamOptions *options );
  782. bool shouldAutoconnect_;
  783. };
  784. #endif
  785. #if defined(__WINDOWS_ASIO__)
  786. class RtApiAsio: public RtApi
  787. {
  788. public:
  789. RtApiAsio();
  790. ~RtApiAsio();
  791. RtAudio::Api getCurrentApi( void ) const { return RtAudio::WINDOWS_ASIO; }
  792. unsigned int getDeviceCount( void );
  793. RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
  794. void closeStream( void );
  795. void startStream( void );
  796. void stopStream( void );
  797. void abortStream( void );
  798. long getStreamLatency( void );
  799. // This function is intended for internal use only. It must be
  800. // public because it is called by the internal callback handler,
  801. // which is not a member of RtAudio. External use of this function
  802. // will most likely produce highly undesireable results!
  803. bool callbackEvent( long bufferIndex );
  804. private:
  805. std::vector<RtAudio::DeviceInfo> devices_;
  806. void saveDeviceInfo( void );
  807. bool coInitialized_;
  808. 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. #endif
  814. #if defined(__WINDOWS_DS__)
  815. class RtApiDs: public RtApi
  816. {
  817. public:
  818. RtApiDs();
  819. ~RtApiDs();
  820. RtAudio::Api getCurrentApi( void ) const { return RtAudio::WINDOWS_DS; }
  821. unsigned int getDeviceCount( void );
  822. unsigned int getDefaultOutputDevice( void );
  823. unsigned int getDefaultInputDevice( void );
  824. RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
  825. void closeStream( void );
  826. void startStream( void );
  827. void stopStream( void );
  828. void abortStream( void );
  829. long getStreamLatency( void );
  830. // This function is intended for internal use only. It must be
  831. // public because it is called by the internal callback handler,
  832. // which is not a member of RtAudio. External use of this function
  833. // will most likely produce highly undesireable results!
  834. void callbackEvent( void );
  835. private:
  836. bool coInitialized_;
  837. bool buffersRolling;
  838. long duplexPrerollBytes;
  839. std::vector<struct DsDevice> dsDevices;
  840. bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
  841. unsigned int firstChannel, unsigned int sampleRate,
  842. RtAudioFormat format, unsigned int *bufferSize,
  843. RtAudio::StreamOptions *options );
  844. };
  845. #endif
  846. #if defined(__WINDOWS_WASAPI__)
  847. struct IMMDeviceEnumerator;
  848. class RtApiWasapi : public RtApi
  849. {
  850. public:
  851. RtApiWasapi();
  852. ~RtApiWasapi();
  853. RtAudio::Api getCurrentApi( void ) const { return RtAudio::WINDOWS_WASAPI; }
  854. unsigned int getDeviceCount( void );
  855. RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
  856. unsigned int getDefaultOutputDevice( void );
  857. unsigned int getDefaultInputDevice( void );
  858. void closeStream( void );
  859. void startStream( void );
  860. void stopStream( void );
  861. void abortStream( void );
  862. private:
  863. bool coInitialized_;
  864. IMMDeviceEnumerator* deviceEnumerator_;
  865. bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
  866. unsigned int firstChannel, unsigned int sampleRate,
  867. RtAudioFormat format, unsigned int* bufferSize,
  868. RtAudio::StreamOptions* options );
  869. static DWORD WINAPI runWasapiThread( void* wasapiPtr );
  870. static DWORD WINAPI stopWasapiThread( void* wasapiPtr );
  871. static DWORD WINAPI abortWasapiThread( void* wasapiPtr );
  872. void wasapiThread();
  873. };
  874. #endif
  875. #if defined(__LINUX_ALSA__)
  876. class RtApiAlsa: public RtApi
  877. {
  878. public:
  879. RtApiAlsa();
  880. ~RtApiAlsa();
  881. RtAudio::Api getCurrentApi() const { return RtAudio::LINUX_ALSA; }
  882. unsigned int getDeviceCount( void );
  883. RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
  884. void closeStream( void );
  885. void startStream( void );
  886. void stopStream( void );
  887. void abortStream( void );
  888. // This function is intended for internal use only. It must be
  889. // public because it is called by the internal callback handler,
  890. // which is not a member of RtAudio. External use of this function
  891. // will most likely produce highly undesireable results!
  892. void callbackEvent( void );
  893. private:
  894. std::vector<RtAudio::DeviceInfo> devices_;
  895. void saveDeviceInfo( void );
  896. bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
  897. unsigned int firstChannel, unsigned int sampleRate,
  898. RtAudioFormat format, unsigned int *bufferSize,
  899. RtAudio::StreamOptions *options );
  900. };
  901. #endif
  902. #if defined(__UNIX_PULSE__)
  903. class RtApiPulse: public RtApi
  904. {
  905. public:
  906. ~RtApiPulse();
  907. RtAudio::Api getCurrentApi() const { return RtAudio::UNIX_PULSE; }
  908. unsigned int getDeviceCount( void );
  909. RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
  910. void closeStream( void );
  911. void startStream( void );
  912. void stopStream( void );
  913. void abortStream( void );
  914. // This function is intended for internal use only. It must be
  915. // public because it is called by the internal callback handler,
  916. // which is not a member of RtAudio. External use of this function
  917. // will most likely produce highly undesireable results!
  918. void callbackEvent( void );
  919. private:
  920. std::vector<RtAudio::DeviceInfo> devices_;
  921. void saveDeviceInfo( void );
  922. bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
  923. unsigned int firstChannel, unsigned int sampleRate,
  924. RtAudioFormat format, unsigned int *bufferSize,
  925. RtAudio::StreamOptions *options );
  926. };
  927. #endif
  928. #if defined(__LINUX_OSS__)
  929. class RtApiOss: public RtApi
  930. {
  931. public:
  932. RtApiOss();
  933. ~RtApiOss();
  934. RtAudio::Api getCurrentApi() const { return RtAudio::LINUX_OSS; }
  935. unsigned int getDeviceCount( void );
  936. RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
  937. void closeStream( void );
  938. void startStream( void );
  939. void stopStream( void );
  940. void abortStream( void );
  941. // This function is intended for internal use only. It must be
  942. // public because it is called by the internal callback handler,
  943. // which is not a member of RtAudio. External use of this function
  944. // will most likely produce highly undesireable results!
  945. void callbackEvent( void );
  946. private:
  947. bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
  948. unsigned int firstChannel, unsigned int sampleRate,
  949. RtAudioFormat format, unsigned int *bufferSize,
  950. RtAudio::StreamOptions *options );
  951. };
  952. #endif
  953. #if defined(__RTAUDIO_DUMMY__)
  954. class RtApiDummy: public RtApi
  955. {
  956. public:
  957. RtApiDummy() { errorText_ = "RtApiDummy: This class provides no functionality."; error( RtAudioError::WARNING ); }
  958. RtAudio::Api getCurrentApi( void ) const { return RtAudio::RTAUDIO_DUMMY; }
  959. unsigned int getDeviceCount( void ) { return 0; }
  960. RtAudio::DeviceInfo getDeviceInfo( unsigned int /*device*/ ) { RtAudio::DeviceInfo info; return info; }
  961. void closeStream( void ) {}
  962. void startStream( void ) {}
  963. void stopStream( void ) {}
  964. void abortStream( void ) {}
  965. private:
  966. bool probeDeviceOpen( unsigned int /*device*/, StreamMode /*mode*/, unsigned int /*channels*/,
  967. unsigned int /*firstChannel*/, unsigned int /*sampleRate*/,
  968. RtAudioFormat /*format*/, unsigned int * /*bufferSize*/,
  969. RtAudio::StreamOptions * /*options*/ ) { return false; }
  970. };
  971. #endif
  972. #endif
  973. // Indentation settings for Vim and Emacs
  974. //
  975. // Local Variables:
  976. // c-basic-offset: 2
  977. // indent-tabs-mode: nil
  978. // End:
  979. //
  980. // vim: et sts=2 sw=2