f@0: /************************************************************************/ f@0: /*! \class RtAudio f@0: \brief Realtime audio i/o C++ classes. f@0: f@0: RtAudio provides a common API (Application Programming Interface) f@0: for realtime audio input/output across Linux (native ALSA, Jack, f@0: and OSS), Macintosh OS X (CoreAudio and Jack), and Windows f@0: (DirectSound, ASIO and WASAPI) operating systems. f@0: f@0: RtAudio WWW site: http://www.music.mcgill.ca/~gary/rtaudio/ f@0: f@0: RtAudio: realtime audio i/o C++ classes f@0: Copyright (c) 2001-2014 Gary P. Scavone f@0: f@0: Permission is hereby granted, free of charge, to any person f@0: obtaining a copy of this software and associated documentation files f@0: (the "Software"), to deal in the Software without restriction, f@0: including without limitation the rights to use, copy, modify, merge, f@0: publish, distribute, sublicense, and/or sell copies of the Software, f@0: and to permit persons to whom the Software is furnished to do so, f@0: subject to the following conditions: f@0: f@0: The above copyright notice and this permission notice shall be f@0: included in all copies or substantial portions of the Software. f@0: f@0: Any person wishing to distribute modifications to the Software is f@0: asked to send the modifications to the original developer so that f@0: they can be incorporated into the canonical version. This is, f@0: however, not a binding provision of this license. f@0: f@0: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, f@0: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF f@0: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. f@0: IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR f@0: ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF f@0: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION f@0: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. f@0: */ f@0: /************************************************************************/ f@0: f@0: /*! f@0: \file RtAudio.h f@0: */ f@0: f@0: #ifndef __RTAUDIO_H f@0: #define __RTAUDIO_H f@0: f@0: #define RTAUDIO_VERSION "4.1.1" f@0: f@0: #include f@0: #include f@0: #include f@0: #include f@0: f@0: /*! \typedef typedef unsigned long RtAudioFormat; f@0: \brief RtAudio data format type. f@0: f@0: Support for signed integers and floats. Audio data fed to/from an f@0: RtAudio stream is assumed to ALWAYS be in host byte order. The f@0: internal routines will automatically take care of any necessary f@0: byte-swapping between the host format and the soundcard. Thus, f@0: endian-ness is not a concern in the following format definitions. f@0: f@0: - \e RTAUDIO_SINT8: 8-bit signed integer. f@0: - \e RTAUDIO_SINT16: 16-bit signed integer. f@0: - \e RTAUDIO_SINT24: 24-bit signed integer. f@0: - \e RTAUDIO_SINT32: 32-bit signed integer. f@0: - \e RTAUDIO_FLOAT32: Normalized between plus/minus 1.0. f@0: - \e RTAUDIO_FLOAT64: Normalized between plus/minus 1.0. f@0: */ f@0: typedef unsigned long RtAudioFormat; f@0: static const RtAudioFormat RTAUDIO_SINT8 = 0x1; // 8-bit signed integer. f@0: static const RtAudioFormat RTAUDIO_SINT16 = 0x2; // 16-bit signed integer. f@0: static const RtAudioFormat RTAUDIO_SINT24 = 0x4; // 24-bit signed integer. f@0: static const RtAudioFormat RTAUDIO_SINT32 = 0x8; // 32-bit signed integer. f@0: static const RtAudioFormat RTAUDIO_FLOAT32 = 0x10; // Normalized between plus/minus 1.0. f@0: static const RtAudioFormat RTAUDIO_FLOAT64 = 0x20; // Normalized between plus/minus 1.0. f@0: f@0: /*! \typedef typedef unsigned long RtAudioStreamFlags; f@0: \brief RtAudio stream option flags. f@0: f@0: The following flags can be OR'ed together to allow a client to f@0: make changes to the default stream behavior: f@0: f@0: - \e RTAUDIO_NONINTERLEAVED: Use non-interleaved buffers (default = interleaved). f@0: - \e RTAUDIO_MINIMIZE_LATENCY: Attempt to set stream parameters for lowest possible latency. f@0: - \e RTAUDIO_HOG_DEVICE: Attempt grab device for exclusive use. f@0: - \e RTAUDIO_ALSA_USE_DEFAULT: Use the "default" PCM device (ALSA only). f@0: f@0: By default, RtAudio streams pass and receive audio data from the f@0: client in an interleaved format. By passing the f@0: RTAUDIO_NONINTERLEAVED flag to the openStream() function, audio f@0: data will instead be presented in non-interleaved buffers. In f@0: this case, each buffer argument in the RtAudioCallback function f@0: will point to a single array of data, with \c nFrames samples for f@0: each channel concatenated back-to-back. For example, the first f@0: sample of data for the second channel would be located at index \c f@0: nFrames (assuming the \c buffer pointer was recast to the correct f@0: data type for the stream). f@0: f@0: Certain audio APIs offer a number of parameters that influence the f@0: I/O latency of a stream. By default, RtAudio will attempt to set f@0: these parameters internally for robust (glitch-free) performance f@0: (though some APIs, like Windows Direct Sound, make this difficult). f@0: By passing the RTAUDIO_MINIMIZE_LATENCY flag to the openStream() f@0: function, internal stream settings will be influenced in an attempt f@0: to minimize stream latency, though possibly at the expense of stream f@0: performance. f@0: f@0: If the RTAUDIO_HOG_DEVICE flag is set, RtAudio will attempt to f@0: open the input and/or output stream device(s) for exclusive use. f@0: Note that this is not possible with all supported audio APIs. f@0: f@0: If the RTAUDIO_SCHEDULE_REALTIME flag is set, RtAudio will attempt f@0: to select realtime scheduling (round-robin) for the callback thread. f@0: f@0: If the RTAUDIO_ALSA_USE_DEFAULT flag is set, RtAudio will attempt to f@0: open the "default" PCM device when using the ALSA API. Note that this f@0: will override any specified input or output device id. f@0: */ f@0: typedef unsigned int RtAudioStreamFlags; f@0: static const RtAudioStreamFlags RTAUDIO_NONINTERLEAVED = 0x1; // Use non-interleaved buffers (default = interleaved). f@0: static const RtAudioStreamFlags RTAUDIO_MINIMIZE_LATENCY = 0x2; // Attempt to set stream parameters for lowest possible latency. f@0: static const RtAudioStreamFlags RTAUDIO_HOG_DEVICE = 0x4; // Attempt grab device and prevent use by others. f@0: static const RtAudioStreamFlags RTAUDIO_SCHEDULE_REALTIME = 0x8; // Try to select realtime scheduling for callback thread. f@0: static const RtAudioStreamFlags RTAUDIO_ALSA_USE_DEFAULT = 0x10; // Use the "default" PCM device (ALSA only). f@0: f@0: /*! \typedef typedef unsigned long RtAudioStreamStatus; f@0: \brief RtAudio stream status (over- or underflow) flags. f@0: f@0: Notification of a stream over- or underflow is indicated by a f@0: non-zero stream \c status argument in the RtAudioCallback function. f@0: The stream status can be one of the following two options, f@0: depending on whether the stream is open for output and/or input: f@0: f@0: - \e RTAUDIO_INPUT_OVERFLOW: Input data was discarded because of an overflow condition at the driver. f@0: - \e RTAUDIO_OUTPUT_UNDERFLOW: The output buffer ran low, likely producing a break in the output sound. f@0: */ f@0: typedef unsigned int RtAudioStreamStatus; f@0: static const RtAudioStreamStatus RTAUDIO_INPUT_OVERFLOW = 0x1; // Input data was discarded because of an overflow condition at the driver. f@0: static const RtAudioStreamStatus RTAUDIO_OUTPUT_UNDERFLOW = 0x2; // The output buffer ran low, likely causing a gap in the output sound. f@0: f@0: //! RtAudio callback function prototype. f@0: /*! f@0: All RtAudio clients must create a function of type RtAudioCallback f@0: to read and/or write data from/to the audio stream. When the f@0: underlying audio system is ready for new input or output data, this f@0: function will be invoked. f@0: f@0: \param outputBuffer For output (or duplex) streams, the client f@0: should write \c nFrames of audio sample frames into this f@0: buffer. This argument should be recast to the datatype f@0: specified when the stream was opened. For input-only f@0: streams, this argument will be NULL. f@0: f@0: \param inputBuffer For input (or duplex) streams, this buffer will f@0: hold \c nFrames of input audio sample frames. This f@0: argument should be recast to the datatype specified when the f@0: stream was opened. For output-only streams, this argument f@0: will be NULL. f@0: f@0: \param nFrames The number of sample frames of input or output f@0: data in the buffers. The actual buffer size in bytes is f@0: dependent on the data type and number of channels in use. f@0: f@0: \param streamTime The number of seconds that have elapsed since the f@0: stream was started. f@0: f@0: \param status If non-zero, this argument indicates a data overflow f@0: or underflow condition for the stream. The particular f@0: condition can be determined by comparison with the f@0: RtAudioStreamStatus flags. f@0: f@0: \param userData A pointer to optional data provided by the client f@0: when opening the stream (default = NULL). f@0: f@0: To continue normal stream operation, the RtAudioCallback function f@0: should return a value of zero. To stop the stream and drain the f@0: output buffer, the function should return a value of one. To abort f@0: the stream immediately, the client should return a value of two. f@0: */ f@0: typedef int (*RtAudioCallback)( void *outputBuffer, void *inputBuffer, f@0: unsigned int nFrames, f@0: double streamTime, f@0: RtAudioStreamStatus status, f@0: void *userData ); f@0: f@0: /************************************************************************/ f@0: /*! \class RtAudioError f@0: \brief Exception handling class for RtAudio. f@0: f@0: The RtAudioError class is quite simple but it does allow errors to be f@0: "caught" by RtAudioError::Type. See the RtAudio documentation to know f@0: which methods can throw an RtAudioError. f@0: */ f@0: /************************************************************************/ f@0: f@0: class RtAudioError : public std::exception f@0: { f@0: public: f@0: //! Defined RtAudioError types. f@0: enum Type { f@0: WARNING, /*!< A non-critical error. */ f@0: DEBUG_WARNING, /*!< A non-critical error which might be useful for debugging. */ f@0: UNSPECIFIED, /*!< The default, unspecified error type. */ f@0: NO_DEVICES_FOUND, /*!< No devices found on system. */ f@0: INVALID_DEVICE, /*!< An invalid device ID was specified. */ f@0: MEMORY_ERROR, /*!< An error occured during memory allocation. */ f@0: INVALID_PARAMETER, /*!< An invalid parameter was specified to a function. */ f@0: INVALID_USE, /*!< The function was called incorrectly. */ f@0: DRIVER_ERROR, /*!< A system driver error occured. */ f@0: SYSTEM_ERROR, /*!< A system error occured. */ f@0: THREAD_ERROR /*!< A thread error occured. */ f@0: }; f@0: f@0: //! The constructor. f@0: RtAudioError( const std::string& message, Type type = RtAudioError::UNSPECIFIED ) throw() : message_(message), type_(type) {} f@0: f@0: //! The destructor. f@0: virtual ~RtAudioError( void ) throw() {} f@0: f@0: //! Prints thrown error message to stderr. f@0: virtual void printMessage( void ) const throw() { std::cerr << '\n' << message_ << "\n\n"; } f@0: f@0: //! Returns the thrown error message type. f@0: virtual const Type& getType(void) const throw() { return type_; } f@0: f@0: //! Returns the thrown error message string. f@0: virtual const std::string& getMessage(void) const throw() { return message_; } f@0: f@0: //! Returns the thrown error message as a c-style string. f@0: virtual const char* what( void ) const throw() { return message_.c_str(); } f@0: f@0: protected: f@0: std::string message_; f@0: Type type_; f@0: }; f@0: f@0: //! RtAudio error callback function prototype. f@0: /*! f@0: \param type Type of error. f@0: \param errorText Error description. f@0: */ f@0: typedef void (*RtAudioErrorCallback)( RtAudioError::Type type, const std::string &errorText ); f@0: f@0: // **************************************************************** // f@0: // f@0: // RtAudio class declaration. f@0: // f@0: // RtAudio is a "controller" used to select an available audio i/o f@0: // interface. It presents a common API for the user to call but all f@0: // functionality is implemented by the class RtApi and its f@0: // subclasses. RtAudio creates an instance of an RtApi subclass f@0: // based on the user's API choice. If no choice is made, RtAudio f@0: // attempts to make a "logical" API selection. f@0: // f@0: // **************************************************************** // f@0: f@0: class RtApi; f@0: f@0: class RtAudio f@0: { f@0: public: f@0: f@0: //! Audio API specifier arguments. f@0: enum Api { f@0: UNSPECIFIED, /*!< Search for a working compiled API. */ f@0: LINUX_ALSA, /*!< The Advanced Linux Sound Architecture API. */ f@0: LINUX_PULSE, /*!< The Linux PulseAudio API. */ f@0: LINUX_OSS, /*!< The Linux Open Sound System API. */ f@0: UNIX_JACK, /*!< The Jack Low-Latency Audio Server API. */ f@0: MACOSX_CORE, /*!< Macintosh OS-X Core Audio API. */ f@0: WINDOWS_WASAPI, /*!< The Microsoft WASAPI API. */ f@0: WINDOWS_ASIO, /*!< The Steinberg Audio Stream I/O API. */ f@0: WINDOWS_DS, /*!< The Microsoft Direct Sound API. */ f@0: RTAUDIO_DUMMY /*!< A compilable but non-functional API. */ f@0: }; f@0: f@0: //! The public device information structure for returning queried values. f@0: struct DeviceInfo { f@0: bool probed; /*!< true if the device capabilities were successfully probed. */ f@0: std::string name; /*!< Character string device identifier. */ f@0: unsigned int outputChannels; /*!< Maximum output channels supported by device. */ f@0: unsigned int inputChannels; /*!< Maximum input channels supported by device. */ f@0: unsigned int duplexChannels; /*!< Maximum simultaneous input/output channels supported by device. */ f@0: bool isDefaultOutput; /*!< true if this is the default output device. */ f@0: bool isDefaultInput; /*!< true if this is the default input device. */ f@0: std::vector sampleRates; /*!< Supported sample rates (queried from list of standard rates). */ f@0: RtAudioFormat nativeFormats; /*!< Bit mask of supported data formats. */ f@0: f@0: // Default constructor. f@0: DeviceInfo() f@0: :probed(false), outputChannels(0), inputChannels(0), duplexChannels(0), f@0: isDefaultOutput(false), isDefaultInput(false), nativeFormats(0) {} f@0: }; f@0: f@0: //! The structure for specifying input or ouput stream parameters. f@0: struct StreamParameters { f@0: unsigned int deviceId; /*!< Device index (0 to getDeviceCount() - 1). */ f@0: unsigned int nChannels; /*!< Number of channels. */ f@0: unsigned int firstChannel; /*!< First channel index on device (default = 0). */ f@0: f@0: // Default constructor. f@0: StreamParameters() f@0: : deviceId(0), nChannels(0), firstChannel(0) {} f@0: }; f@0: f@0: //! The structure for specifying stream options. f@0: /*! f@0: The following flags can be OR'ed together to allow a client to f@0: make changes to the default stream behavior: f@0: f@0: - \e RTAUDIO_NONINTERLEAVED: Use non-interleaved buffers (default = interleaved). f@0: - \e RTAUDIO_MINIMIZE_LATENCY: Attempt to set stream parameters for lowest possible latency. f@0: - \e RTAUDIO_HOG_DEVICE: Attempt grab device for exclusive use. f@0: - \e RTAUDIO_SCHEDULE_REALTIME: Attempt to select realtime scheduling for callback thread. f@0: - \e RTAUDIO_ALSA_USE_DEFAULT: Use the "default" PCM device (ALSA only). f@0: f@0: By default, RtAudio streams pass and receive audio data from the f@0: client in an interleaved format. By passing the f@0: RTAUDIO_NONINTERLEAVED flag to the openStream() function, audio f@0: data will instead be presented in non-interleaved buffers. In f@0: this case, each buffer argument in the RtAudioCallback function f@0: will point to a single array of data, with \c nFrames samples for f@0: each channel concatenated back-to-back. For example, the first f@0: sample of data for the second channel would be located at index \c f@0: nFrames (assuming the \c buffer pointer was recast to the correct f@0: data type for the stream). f@0: f@0: Certain audio APIs offer a number of parameters that influence the f@0: I/O latency of a stream. By default, RtAudio will attempt to set f@0: these parameters internally for robust (glitch-free) performance f@0: (though some APIs, like Windows Direct Sound, make this difficult). f@0: By passing the RTAUDIO_MINIMIZE_LATENCY flag to the openStream() f@0: function, internal stream settings will be influenced in an attempt f@0: to minimize stream latency, though possibly at the expense of stream f@0: performance. f@0: f@0: If the RTAUDIO_HOG_DEVICE flag is set, RtAudio will attempt to f@0: open the input and/or output stream device(s) for exclusive use. f@0: Note that this is not possible with all supported audio APIs. f@0: f@0: If the RTAUDIO_SCHEDULE_REALTIME flag is set, RtAudio will attempt f@0: to select realtime scheduling (round-robin) for the callback thread. f@0: The \c priority parameter will only be used if the RTAUDIO_SCHEDULE_REALTIME f@0: flag is set. It defines the thread's realtime priority. f@0: f@0: If the RTAUDIO_ALSA_USE_DEFAULT flag is set, RtAudio will attempt to f@0: open the "default" PCM device when using the ALSA API. Note that this f@0: will override any specified input or output device id. f@0: f@0: The \c numberOfBuffers parameter can be used to control stream f@0: latency in the Windows DirectSound, Linux OSS, and Linux Alsa APIs f@0: only. A value of two is usually the smallest allowed. Larger f@0: numbers can potentially result in more robust stream performance, f@0: though likely at the cost of stream latency. The value set by the f@0: user is replaced during execution of the RtAudio::openStream() f@0: function by the value actually used by the system. f@0: f@0: The \c streamName parameter can be used to set the client name f@0: when using the Jack API. By default, the client name is set to f@0: RtApiJack. However, if you wish to create multiple instances of f@0: RtAudio with Jack, each instance must have a unique client name. f@0: */ f@0: struct StreamOptions { f@0: RtAudioStreamFlags flags; /*!< A bit-mask of stream flags (RTAUDIO_NONINTERLEAVED, RTAUDIO_MINIMIZE_LATENCY, RTAUDIO_HOG_DEVICE, RTAUDIO_ALSA_USE_DEFAULT). */ f@0: unsigned int numberOfBuffers; /*!< Number of stream buffers. */ f@0: std::string streamName; /*!< A stream name (currently used only in Jack). */ f@0: int priority; /*!< Scheduling priority of callback thread (only used with flag RTAUDIO_SCHEDULE_REALTIME). */ f@0: f@0: // Default constructor. f@0: StreamOptions() f@0: : flags(0), numberOfBuffers(0), priority(0) {} f@0: }; f@0: f@0: //! A static function to determine the current RtAudio version. f@0: static std::string getVersion( void ) throw(); f@0: f@0: //! A static function to determine the available compiled audio APIs. f@0: /*! f@0: The values returned in the std::vector can be compared against f@0: the enumerated list values. Note that there can be more than one f@0: API compiled for certain operating systems. f@0: */ f@0: static void getCompiledApi( std::vector &apis ) throw(); f@0: f@0: //! The class constructor. f@0: /*! f@0: The constructor performs minor initialization tasks. An exception f@0: can be thrown if no API support is compiled. f@0: f@0: If no API argument is specified and multiple API support has been f@0: compiled, the default order of use is JACK, ALSA, OSS (Linux f@0: systems) and ASIO, DS (Windows systems). f@0: */ f@0: RtAudio( RtAudio::Api api=UNSPECIFIED ); f@0: f@0: //! The destructor. f@0: /*! f@0: If a stream is running or open, it will be stopped and closed f@0: automatically. f@0: */ f@0: ~RtAudio() throw(); f@0: f@0: //! Returns the audio API specifier for the current instance of RtAudio. f@0: RtAudio::Api getCurrentApi( void ) throw(); f@0: f@0: //! A public function that queries for the number of audio devices available. f@0: /*! f@0: This function performs a system query of available devices each time it f@0: is called, thus supporting devices connected \e after instantiation. If f@0: a system error occurs during processing, a warning will be issued. f@0: */ f@0: unsigned int getDeviceCount( void ) throw(); f@0: f@0: //! Return an RtAudio::DeviceInfo structure for a specified device number. f@0: /*! f@0: f@0: Any device integer between 0 and getDeviceCount() - 1 is valid. f@0: If an invalid argument is provided, an RtAudioError (type = INVALID_USE) f@0: will be thrown. If a device is busy or otherwise unavailable, the f@0: structure member "probed" will have a value of "false" and all f@0: other members are undefined. If the specified device is the f@0: current default input or output device, the corresponding f@0: "isDefault" member will have a value of "true". f@0: */ f@0: RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); f@0: f@0: //! A function that returns the index of the default output device. f@0: /*! f@0: If the underlying audio API does not provide a "default f@0: device", or if no devices are available, the return value will be f@0: 0. Note that this is a valid device identifier and it is the f@0: client's responsibility to verify that a device is available f@0: before attempting to open a stream. f@0: */ f@0: unsigned int getDefaultOutputDevice( void ) throw(); f@0: f@0: //! A function that returns the index of the default input device. f@0: /*! f@0: If the underlying audio API does not provide a "default f@0: device", or if no devices are available, the return value will be f@0: 0. Note that this is a valid device identifier and it is the f@0: client's responsibility to verify that a device is available f@0: before attempting to open a stream. f@0: */ f@0: unsigned int getDefaultInputDevice( void ) throw(); f@0: f@0: //! A public function for opening a stream with the specified parameters. f@0: /*! f@0: An RtAudioError (type = SYSTEM_ERROR) is thrown if a stream cannot be f@0: opened with the specified parameters or an error occurs during f@0: processing. An RtAudioError (type = INVALID_USE) is thrown if any f@0: invalid device ID or channel number parameters are specified. f@0: f@0: \param outputParameters Specifies output stream parameters to use f@0: when opening a stream, including a device ID, number of channels, f@0: and starting channel number. For input-only streams, this f@0: argument should be NULL. The device ID is an index value between f@0: 0 and getDeviceCount() - 1. f@0: \param inputParameters Specifies input stream parameters to use f@0: when opening a stream, including a device ID, number of channels, f@0: and starting channel number. For output-only streams, this f@0: argument should be NULL. The device ID is an index value between f@0: 0 and getDeviceCount() - 1. f@0: \param format An RtAudioFormat specifying the desired sample data format. f@0: \param sampleRate The desired sample rate (sample frames per second). f@0: \param *bufferFrames A pointer to a value indicating the desired f@0: internal buffer size in sample frames. The actual value f@0: used by the device is returned via the same pointer. A f@0: value of zero can be specified, in which case the lowest f@0: allowable value is determined. f@0: \param callback A client-defined function that will be invoked f@0: when input data is available and/or output data is needed. f@0: \param userData An optional pointer to data that can be accessed f@0: from within the callback function. f@0: \param options An optional pointer to a structure containing various f@0: global stream options, including a list of OR'ed RtAudioStreamFlags f@0: and a suggested number of stream buffers that can be used to f@0: control stream latency. More buffers typically result in more f@0: robust performance, though at a cost of greater latency. If a f@0: value of zero is specified, a system-specific median value is f@0: chosen. If the RTAUDIO_MINIMIZE_LATENCY flag bit is set, the f@0: lowest allowable value is used. The actual value used is f@0: returned via the structure argument. The parameter is API dependent. f@0: \param errorCallback A client-defined function that will be invoked f@0: when an error has occured. f@0: */ f@0: void openStream( RtAudio::StreamParameters *outputParameters, f@0: RtAudio::StreamParameters *inputParameters, f@0: RtAudioFormat format, unsigned int sampleRate, f@0: unsigned int *bufferFrames, RtAudioCallback callback, f@0: void *userData = NULL, RtAudio::StreamOptions *options = NULL, RtAudioErrorCallback errorCallback = NULL ); f@0: f@0: //! A function that closes a stream and frees any associated stream memory. f@0: /*! f@0: If a stream is not open, this function issues a warning and f@0: returns (no exception is thrown). f@0: */ f@0: void closeStream( void ) throw(); f@0: f@0: //! A function that starts a stream. f@0: /*! f@0: An RtAudioError (type = SYSTEM_ERROR) is thrown if an error occurs f@0: during processing. An RtAudioError (type = INVALID_USE) is thrown if a f@0: stream is not open. A warning is issued if the stream is already f@0: running. f@0: */ f@0: void startStream( void ); f@0: f@0: //! Stop a stream, allowing any samples remaining in the output queue to be played. f@0: /*! f@0: An RtAudioError (type = SYSTEM_ERROR) is thrown if an error occurs f@0: during processing. An RtAudioError (type = INVALID_USE) is thrown if a f@0: stream is not open. A warning is issued if the stream is already f@0: stopped. f@0: */ f@0: void stopStream( void ); f@0: f@0: //! Stop a stream, discarding any samples remaining in the input/output queue. f@0: /*! f@0: An RtAudioError (type = SYSTEM_ERROR) is thrown if an error occurs f@0: during processing. An RtAudioError (type = INVALID_USE) is thrown if a f@0: stream is not open. A warning is issued if the stream is already f@0: stopped. f@0: */ f@0: void abortStream( void ); f@0: f@0: //! Returns true if a stream is open and false if not. f@0: bool isStreamOpen( void ) const throw(); f@0: f@0: //! Returns true if the stream is running and false if it is stopped or not open. f@0: bool isStreamRunning( void ) const throw(); f@0: f@0: //! Returns the number of elapsed seconds since the stream was started. f@0: /*! f@0: If a stream is not open, an RtAudioError (type = INVALID_USE) will be thrown. f@0: */ f@0: double getStreamTime( void ); f@0: f@0: //! Set the stream time to a time in seconds greater than or equal to 0.0. f@0: /*! f@0: If a stream is not open, an RtAudioError (type = INVALID_USE) will be thrown. f@0: */ f@0: void setStreamTime( double time ); f@0: f@0: //! Returns the internal stream latency in sample frames. f@0: /*! f@0: The stream latency refers to delay in audio input and/or output f@0: caused by internal buffering by the audio system and/or hardware. f@0: For duplex streams, the returned value will represent the sum of f@0: the input and output latencies. If a stream is not open, an f@0: RtAudioError (type = INVALID_USE) will be thrown. If the API does not f@0: report latency, the return value will be zero. f@0: */ f@0: long getStreamLatency( void ); f@0: f@0: //! Returns actual sample rate in use by the stream. f@0: /*! f@0: On some systems, the sample rate used may be slightly different f@0: than that specified in the stream parameters. If a stream is not f@0: open, an RtAudioError (type = INVALID_USE) will be thrown. f@0: */ f@0: unsigned int getStreamSampleRate( void ); f@0: f@0: //! Specify whether warning messages should be printed to stderr. f@0: void showWarnings( bool value = true ) throw(); f@0: f@0: protected: f@0: f@0: void openRtApi( RtAudio::Api api ); f@0: RtApi *rtapi_; f@0: }; f@0: f@0: // Operating system dependent thread functionality. f@0: #if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) || defined(__WINDOWS_WASAPI__) f@0: f@0: #ifndef NOMINMAX f@0: #define NOMINMAX f@0: #endif f@0: #include f@0: #include f@0: f@0: typedef uintptr_t ThreadHandle; f@0: typedef CRITICAL_SECTION StreamMutex; f@0: f@0: #elif defined(__LINUX_ALSA__) || defined(__LINUX_PULSE__) || defined(__UNIX_JACK__) || defined(__LINUX_OSS__) || defined(__MACOSX_CORE__) f@0: // Using pthread library for various flavors of unix. f@0: #include f@0: f@0: typedef pthread_t ThreadHandle; f@0: typedef pthread_mutex_t StreamMutex; f@0: f@0: #else // Setup for "dummy" behavior f@0: f@0: #define __RTAUDIO_DUMMY__ f@0: typedef int ThreadHandle; f@0: typedef int StreamMutex; f@0: f@0: #endif f@0: f@0: // This global structure type is used to pass callback information f@0: // between the private RtAudio stream structure and global callback f@0: // handling functions. f@0: struct CallbackInfo { f@0: void *object; // Used as a "this" pointer. f@0: ThreadHandle thread; f@0: void *callback; f@0: void *userData; f@0: void *errorCallback; f@0: void *apiInfo; // void pointer for API specific callback information f@0: bool isRunning; f@0: bool doRealtime; f@0: int priority; f@0: f@0: // Default constructor. f@0: CallbackInfo() f@0: :object(0), callback(0), userData(0), errorCallback(0), apiInfo(0), isRunning(false), doRealtime(false) {} f@0: }; f@0: f@0: // **************************************************************** // f@0: // f@0: // RtApi class declaration. f@0: // f@0: // Subclasses of RtApi contain all API- and OS-specific code necessary f@0: // to fully implement the RtAudio API. f@0: // f@0: // Note that RtApi is an abstract base class and cannot be f@0: // explicitly instantiated. The class RtAudio will create an f@0: // instance of an RtApi subclass (RtApiOss, RtApiAlsa, f@0: // RtApiJack, RtApiCore, RtApiDs, or RtApiAsio). f@0: // f@0: // **************************************************************** // f@0: f@0: #pragma pack(push, 1) f@0: class S24 { f@0: f@0: protected: f@0: unsigned char c3[3]; f@0: f@0: public: f@0: S24() {} f@0: f@0: S24& operator = ( const int& i ) { f@0: c3[0] = (i & 0x000000ff); f@0: c3[1] = (i & 0x0000ff00) >> 8; f@0: c3[2] = (i & 0x00ff0000) >> 16; f@0: return *this; f@0: } f@0: f@0: S24( const S24& v ) { *this = v; } f@0: S24( const double& d ) { *this = (int) d; } f@0: S24( const float& f ) { *this = (int) f; } f@0: S24( const signed short& s ) { *this = (int) s; } f@0: S24( const char& c ) { *this = (int) c; } f@0: f@0: int asInt() { f@0: int i = c3[0] | (c3[1] << 8) | (c3[2] << 16); f@0: if (i & 0x800000) i |= ~0xffffff; f@0: return i; f@0: } f@0: }; f@0: #pragma pack(pop) f@0: f@0: #if defined( HAVE_GETTIMEOFDAY ) f@0: #include f@0: #endif f@0: f@0: #include f@0: f@0: class RtApi f@0: { f@0: public: f@0: f@0: RtApi(); f@0: virtual ~RtApi(); f@0: virtual RtAudio::Api getCurrentApi( void ) = 0; f@0: virtual unsigned int getDeviceCount( void ) = 0; f@0: virtual RtAudio::DeviceInfo getDeviceInfo( unsigned int device ) = 0; f@0: virtual unsigned int getDefaultInputDevice( void ); f@0: virtual unsigned int getDefaultOutputDevice( void ); f@0: void openStream( RtAudio::StreamParameters *outputParameters, f@0: RtAudio::StreamParameters *inputParameters, f@0: RtAudioFormat format, unsigned int sampleRate, f@0: unsigned int *bufferFrames, RtAudioCallback callback, f@0: void *userData, RtAudio::StreamOptions *options, f@0: RtAudioErrorCallback errorCallback ); f@0: virtual void closeStream( void ); f@0: virtual void startStream( void ) = 0; f@0: virtual void stopStream( void ) = 0; f@0: virtual void abortStream( void ) = 0; f@0: long getStreamLatency( void ); f@0: unsigned int getStreamSampleRate( void ); f@0: virtual double getStreamTime( void ); f@0: virtual void setStreamTime( double time ); f@0: bool isStreamOpen( void ) const { return stream_.state != STREAM_CLOSED; } f@0: bool isStreamRunning( void ) const { return stream_.state == STREAM_RUNNING; } f@0: void showWarnings( bool value ) { showWarnings_ = value; } f@0: f@0: f@0: protected: f@0: f@0: static const unsigned int MAX_SAMPLE_RATES; f@0: static const unsigned int SAMPLE_RATES[]; f@0: f@0: enum { FAILURE, SUCCESS }; f@0: f@0: enum StreamState { f@0: STREAM_STOPPED, f@0: STREAM_STOPPING, f@0: STREAM_RUNNING, f@0: STREAM_CLOSED = -50 f@0: }; f@0: f@0: enum StreamMode { f@0: OUTPUT, f@0: INPUT, f@0: DUPLEX, f@0: UNINITIALIZED = -75 f@0: }; f@0: f@0: // A protected structure used for buffer conversion. f@0: struct ConvertInfo { f@0: int channels; f@0: int inJump, outJump; f@0: RtAudioFormat inFormat, outFormat; f@0: std::vector inOffset; f@0: std::vector outOffset; f@0: }; f@0: f@0: // A protected structure for audio streams. f@0: struct RtApiStream { f@0: unsigned int device[2]; // Playback and record, respectively. f@0: void *apiHandle; // void pointer for API specific stream handle information f@0: StreamMode mode; // OUTPUT, INPUT, or DUPLEX. f@0: StreamState state; // STOPPED, RUNNING, or CLOSED f@0: char *userBuffer[2]; // Playback and record, respectively. f@0: char *deviceBuffer; f@0: bool doConvertBuffer[2]; // Playback and record, respectively. f@0: bool userInterleaved; f@0: bool deviceInterleaved[2]; // Playback and record, respectively. f@0: bool doByteSwap[2]; // Playback and record, respectively. f@0: unsigned int sampleRate; f@0: unsigned int bufferSize; f@0: unsigned int nBuffers; f@0: unsigned int nUserChannels[2]; // Playback and record, respectively. f@0: unsigned int nDeviceChannels[2]; // Playback and record channels, respectively. f@0: unsigned int channelOffset[2]; // Playback and record, respectively. f@0: unsigned long latency[2]; // Playback and record, respectively. f@0: RtAudioFormat userFormat; f@0: RtAudioFormat deviceFormat[2]; // Playback and record, respectively. f@0: StreamMutex mutex; f@0: CallbackInfo callbackInfo; f@0: ConvertInfo convertInfo[2]; f@0: double streamTime; // Number of elapsed seconds since the stream started. f@0: f@0: #if defined(HAVE_GETTIMEOFDAY) f@0: struct timeval lastTickTimestamp; f@0: #endif f@0: f@0: RtApiStream() f@0: :apiHandle(0), deviceBuffer(0) { device[0] = 11111; device[1] = 11111; } f@0: }; f@0: f@0: typedef S24 Int24; f@0: typedef signed short Int16; f@0: typedef signed int Int32; f@0: typedef float Float32; f@0: typedef double Float64; f@0: f@0: std::ostringstream errorStream_; f@0: std::string errorText_; f@0: bool showWarnings_; f@0: RtApiStream stream_; f@0: bool firstErrorOccurred_; f@0: f@0: /*! f@0: Protected, api-specific method that attempts to open a device f@0: with the given parameters. This function MUST be implemented by f@0: all subclasses. If an error is encountered during the probe, a f@0: "warning" message is reported and FAILURE is returned. A f@0: successful probe is indicated by a return value of SUCCESS. f@0: */ f@0: virtual bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, f@0: unsigned int firstChannel, unsigned int sampleRate, f@0: RtAudioFormat format, unsigned int *bufferSize, f@0: RtAudio::StreamOptions *options ); f@0: f@0: //! A protected function used to increment the stream time. f@0: void tickStreamTime( void ); f@0: f@0: //! Protected common method to clear an RtApiStream structure. f@0: void clearStreamInfo(); f@0: f@0: /*! f@0: Protected common method that throws an RtAudioError (type = f@0: INVALID_USE) if a stream is not open. f@0: */ f@0: void verifyStream( void ); f@0: f@0: //! Protected common error method to allow global control over error handling. f@0: void error( RtAudioError::Type type ); f@0: f@0: /*! f@0: Protected method used to perform format, channel number, and/or interleaving f@0: conversions between the user and device buffers. f@0: */ f@0: void convertBuffer( char *outBuffer, char *inBuffer, ConvertInfo &info ); f@0: f@0: //! Protected common method used to perform byte-swapping on buffers. f@0: void byteSwapBuffer( char *buffer, unsigned int samples, RtAudioFormat format ); f@0: f@0: //! Protected common method that returns the number of bytes for a given format. f@0: unsigned int formatBytes( RtAudioFormat format ); f@0: f@0: //! Protected common method that sets up the parameters for buffer conversion. f@0: void setConvertInfo( StreamMode mode, unsigned int firstChannel ); f@0: }; f@0: f@0: // **************************************************************** // f@0: // f@0: // Inline RtAudio definitions. f@0: // f@0: // **************************************************************** // f@0: f@0: inline RtAudio::Api RtAudio :: getCurrentApi( void ) throw() { return rtapi_->getCurrentApi(); } f@0: inline unsigned int RtAudio :: getDeviceCount( void ) throw() { return rtapi_->getDeviceCount(); } f@0: inline RtAudio::DeviceInfo RtAudio :: getDeviceInfo( unsigned int device ) { return rtapi_->getDeviceInfo( device ); } f@0: inline unsigned int RtAudio :: getDefaultInputDevice( void ) throw() { return rtapi_->getDefaultInputDevice(); } f@0: inline unsigned int RtAudio :: getDefaultOutputDevice( void ) throw() { return rtapi_->getDefaultOutputDevice(); } f@0: inline void RtAudio :: closeStream( void ) throw() { return rtapi_->closeStream(); } f@0: inline void RtAudio :: startStream( void ) { return rtapi_->startStream(); } f@0: inline void RtAudio :: stopStream( void ) { return rtapi_->stopStream(); } f@0: inline void RtAudio :: abortStream( void ) { return rtapi_->abortStream(); } f@0: inline bool RtAudio :: isStreamOpen( void ) const throw() { return rtapi_->isStreamOpen(); } f@0: inline bool RtAudio :: isStreamRunning( void ) const throw() { return rtapi_->isStreamRunning(); } f@0: inline long RtAudio :: getStreamLatency( void ) { return rtapi_->getStreamLatency(); } f@0: inline unsigned int RtAudio :: getStreamSampleRate( void ) { return rtapi_->getStreamSampleRate(); } f@0: inline double RtAudio :: getStreamTime( void ) { return rtapi_->getStreamTime(); } f@0: inline void RtAudio :: setStreamTime( double time ) { return rtapi_->setStreamTime( time ); } f@0: inline void RtAudio :: showWarnings( bool value ) throw() { rtapi_->showWarnings( value ); } f@0: f@0: // RtApi Subclass prototypes. f@0: f@0: #if defined(__MACOSX_CORE__) f@0: f@0: #include f@0: f@0: class RtApiCore: public RtApi f@0: { f@0: public: f@0: f@0: RtApiCore(); f@0: ~RtApiCore(); f@0: RtAudio::Api getCurrentApi( void ) { return RtAudio::MACOSX_CORE; } f@0: unsigned int getDeviceCount( void ); f@0: RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); f@0: unsigned int getDefaultOutputDevice( void ); f@0: unsigned int getDefaultInputDevice( void ); f@0: void closeStream( void ); f@0: void startStream( void ); f@0: void stopStream( void ); f@0: void abortStream( void ); f@0: long getStreamLatency( void ); f@0: f@0: // This function is intended for internal use only. It must be f@0: // public because it is called by the internal callback handler, f@0: // which is not a member of RtAudio. External use of this function f@0: // will most likely produce highly undesireable results! f@0: bool callbackEvent( AudioDeviceID deviceId, f@0: const AudioBufferList *inBufferList, f@0: const AudioBufferList *outBufferList ); f@0: f@0: private: f@0: f@0: bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, f@0: unsigned int firstChannel, unsigned int sampleRate, f@0: RtAudioFormat format, unsigned int *bufferSize, f@0: RtAudio::StreamOptions *options ); f@0: static const char* getErrorCode( OSStatus code ); f@0: }; f@0: f@0: #endif f@0: f@0: #if defined(__UNIX_JACK__) f@0: f@0: class RtApiJack: public RtApi f@0: { f@0: public: f@0: f@0: RtApiJack(); f@0: ~RtApiJack(); f@0: RtAudio::Api getCurrentApi( void ) { return RtAudio::UNIX_JACK; } f@0: unsigned int getDeviceCount( void ); f@0: RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); f@0: void closeStream( void ); f@0: void startStream( void ); f@0: void stopStream( void ); f@0: void abortStream( void ); f@0: long getStreamLatency( void ); f@0: f@0: // This function is intended for internal use only. It must be f@0: // public because it is called by the internal callback handler, f@0: // which is not a member of RtAudio. External use of this function f@0: // will most likely produce highly undesireable results! f@0: bool callbackEvent( unsigned long nframes ); f@0: f@0: private: f@0: f@0: bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, f@0: unsigned int firstChannel, unsigned int sampleRate, f@0: RtAudioFormat format, unsigned int *bufferSize, f@0: RtAudio::StreamOptions *options ); f@0: }; f@0: f@0: #endif f@0: f@0: #if defined(__WINDOWS_ASIO__) f@0: f@0: class RtApiAsio: public RtApi f@0: { f@0: public: f@0: f@0: RtApiAsio(); f@0: ~RtApiAsio(); f@0: RtAudio::Api getCurrentApi( void ) { return RtAudio::WINDOWS_ASIO; } f@0: unsigned int getDeviceCount( void ); f@0: RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); f@0: void closeStream( void ); f@0: void startStream( void ); f@0: void stopStream( void ); f@0: void abortStream( void ); f@0: long getStreamLatency( void ); f@0: f@0: // This function is intended for internal use only. It must be f@0: // public because it is called by the internal callback handler, f@0: // which is not a member of RtAudio. External use of this function f@0: // will most likely produce highly undesireable results! f@0: bool callbackEvent( long bufferIndex ); f@0: f@0: private: f@0: f@0: std::vector devices_; f@0: void saveDeviceInfo( void ); f@0: bool coInitialized_; f@0: bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, f@0: unsigned int firstChannel, unsigned int sampleRate, f@0: RtAudioFormat format, unsigned int *bufferSize, f@0: RtAudio::StreamOptions *options ); f@0: }; f@0: f@0: #endif f@0: f@0: #if defined(__WINDOWS_DS__) f@0: f@0: class RtApiDs: public RtApi f@0: { f@0: public: f@0: f@0: RtApiDs(); f@0: ~RtApiDs(); f@0: RtAudio::Api getCurrentApi( void ) { return RtAudio::WINDOWS_DS; } f@0: unsigned int getDeviceCount( void ); f@0: unsigned int getDefaultOutputDevice( void ); f@0: unsigned int getDefaultInputDevice( void ); f@0: RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); f@0: void closeStream( void ); f@0: void startStream( void ); f@0: void stopStream( void ); f@0: void abortStream( void ); f@0: long getStreamLatency( void ); f@0: f@0: // This function is intended for internal use only. It must be f@0: // public because it is called by the internal callback handler, f@0: // which is not a member of RtAudio. External use of this function f@0: // will most likely produce highly undesireable results! f@0: void callbackEvent( void ); f@0: f@0: private: f@0: f@0: bool coInitialized_; f@0: bool buffersRolling; f@0: long duplexPrerollBytes; f@0: std::vector dsDevices; f@0: bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, f@0: unsigned int firstChannel, unsigned int sampleRate, f@0: RtAudioFormat format, unsigned int *bufferSize, f@0: RtAudio::StreamOptions *options ); f@0: }; f@0: f@0: #endif f@0: f@0: #if defined(__WINDOWS_WASAPI__) f@0: f@0: struct IMMDeviceEnumerator; f@0: f@0: class RtApiWasapi : public RtApi f@0: { f@0: public: f@0: RtApiWasapi(); f@0: ~RtApiWasapi(); f@0: f@0: RtAudio::Api getCurrentApi( void ) { return RtAudio::WINDOWS_WASAPI; } f@0: unsigned int getDeviceCount( void ); f@0: RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); f@0: unsigned int getDefaultOutputDevice( void ); f@0: unsigned int getDefaultInputDevice( void ); f@0: void closeStream( void ); f@0: void startStream( void ); f@0: void stopStream( void ); f@0: void abortStream( void ); f@0: f@0: private: f@0: bool coInitialized_; f@0: IMMDeviceEnumerator* deviceEnumerator_; f@0: f@0: bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, f@0: unsigned int firstChannel, unsigned int sampleRate, f@0: RtAudioFormat format, unsigned int* bufferSize, f@0: RtAudio::StreamOptions* options ); f@0: f@0: static DWORD WINAPI runWasapiThread( void* wasapiPtr ); f@0: static DWORD WINAPI stopWasapiThread( void* wasapiPtr ); f@0: static DWORD WINAPI abortWasapiThread( void* wasapiPtr ); f@0: void wasapiThread(); f@0: }; f@0: f@0: #endif f@0: f@0: #if defined(__LINUX_ALSA__) f@0: f@0: class RtApiAlsa: public RtApi f@0: { f@0: public: f@0: f@0: RtApiAlsa(); f@0: ~RtApiAlsa(); f@0: RtAudio::Api getCurrentApi() { return RtAudio::LINUX_ALSA; } f@0: unsigned int getDeviceCount( void ); f@0: RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); f@0: void closeStream( void ); f@0: void startStream( void ); f@0: void stopStream( void ); f@0: void abortStream( void ); f@0: f@0: // This function is intended for internal use only. It must be f@0: // public because it is called by the internal callback handler, f@0: // which is not a member of RtAudio. External use of this function f@0: // will most likely produce highly undesireable results! f@0: void callbackEvent( void ); f@0: f@0: private: f@0: f@0: std::vector devices_; f@0: void saveDeviceInfo( void ); f@0: bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, f@0: unsigned int firstChannel, unsigned int sampleRate, f@0: RtAudioFormat format, unsigned int *bufferSize, f@0: RtAudio::StreamOptions *options ); f@0: }; f@0: f@0: #endif f@0: f@0: #if defined(__LINUX_PULSE__) f@0: f@0: class RtApiPulse: public RtApi f@0: { f@0: public: f@0: ~RtApiPulse(); f@0: RtAudio::Api getCurrentApi() { return RtAudio::LINUX_PULSE; } f@0: unsigned int getDeviceCount( void ); f@0: RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); f@0: void closeStream( void ); f@0: void startStream( void ); f@0: void stopStream( void ); f@0: void abortStream( void ); f@0: f@0: // This function is intended for internal use only. It must be f@0: // public because it is called by the internal callback handler, f@0: // which is not a member of RtAudio. External use of this function f@0: // will most likely produce highly undesireable results! f@0: void callbackEvent( void ); f@0: f@0: private: f@0: f@0: std::vector devices_; f@0: void saveDeviceInfo( void ); f@0: bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, f@0: unsigned int firstChannel, unsigned int sampleRate, f@0: RtAudioFormat format, unsigned int *bufferSize, f@0: RtAudio::StreamOptions *options ); f@0: }; f@0: f@0: #endif f@0: f@0: #if defined(__LINUX_OSS__) f@0: f@0: class RtApiOss: public RtApi f@0: { f@0: public: f@0: f@0: RtApiOss(); f@0: ~RtApiOss(); f@0: RtAudio::Api getCurrentApi() { return RtAudio::LINUX_OSS; } f@0: unsigned int getDeviceCount( void ); f@0: RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); f@0: void closeStream( void ); f@0: void startStream( void ); f@0: void stopStream( void ); f@0: void abortStream( void ); f@0: f@0: // This function is intended for internal use only. It must be f@0: // public because it is called by the internal callback handler, f@0: // which is not a member of RtAudio. External use of this function f@0: // will most likely produce highly undesireable results! f@0: void callbackEvent( void ); f@0: f@0: private: f@0: f@0: bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels, f@0: unsigned int firstChannel, unsigned int sampleRate, f@0: RtAudioFormat format, unsigned int *bufferSize, f@0: RtAudio::StreamOptions *options ); f@0: }; f@0: f@0: #endif f@0: f@0: #if defined(__RTAUDIO_DUMMY__) f@0: f@0: class RtApiDummy: public RtApi f@0: { f@0: public: f@0: f@0: RtApiDummy() { errorText_ = "RtApiDummy: This class provides no functionality."; error( RtAudioError::WARNING ); } f@0: RtAudio::Api getCurrentApi( void ) { return RtAudio::RTAUDIO_DUMMY; } f@0: unsigned int getDeviceCount( void ) { return 0; } f@0: RtAudio::DeviceInfo getDeviceInfo( unsigned int /*device*/ ) { RtAudio::DeviceInfo info; return info; } f@0: void closeStream( void ) {} f@0: void startStream( void ) {} f@0: void stopStream( void ) {} f@0: void abortStream( void ) {} f@0: f@0: private: f@0: f@0: bool probeDeviceOpen( unsigned int /*device*/, StreamMode /*mode*/, unsigned int /*channels*/, f@0: unsigned int /*firstChannel*/, unsigned int /*sampleRate*/, f@0: RtAudioFormat /*format*/, unsigned int * /*bufferSize*/, f@0: RtAudio::StreamOptions * /*options*/ ) { return false; } f@0: }; f@0: f@0: #endif f@0: f@0: #endif f@0: f@0: // Indentation settings for Vim and Emacs f@0: // f@0: // Local Variables: f@0: // c-basic-offset: 2 f@0: // indent-tabs-mode: nil f@0: // End: f@0: // f@0: // vim: et sts=2 sw=2