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