📄 rtaudio.h
字号:
size in sample frames. The actual value used by the device is returned via the same pointer. A value of zero can be specified, in which case the lowest allowable value is determined. \param numberOfBuffers: A value which can be used to help control device latency. More buffers typically result in more robust performance, though at a cost of greater latency. A value of zero can be specified, in which case the lowest allowable value is used. */ void openStream( int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int numberOfBuffers ); //! A public method for opening a stream and also returning \c numberOfBuffers parameter via pointer argument. /*! See the previous function call for details. This overloaded version differs only in that it takes a pointer argument for the \c numberOfBuffers parameter and returns the value used by the audio device (which may be different from that requested). Note that the \c numberofBuffers parameter is not used with the Linux Jack, Macintosh CoreAudio, and Windows ASIO APIs. */ void openStream( int outputDevice, int outputChannels, int inputDevice, int inputChannels, RtAudioFormat format, int sampleRate, int *bufferSize, int *numberOfBuffers ); //! A public method which sets a user-defined callback function for a given stream. /*! This method assigns a callback function to a previously opened stream for non-blocking stream functionality. A separate process is initiated, though the user function is called only when the stream is "running" (between calls to the startStream() and stopStream() methods, respectively). The callback process remains active for the duration of the stream and is automatically shutdown when the stream is closed (via the closeStream() method or by object destruction). The callback process can also be shutdown and the user function de-referenced through an explicit call to the cancelStreamCallback() method. Note that the stream can use only blocking or callback functionality at a particular time, though it is possible to alternate modes on the same stream through the use of the setStreamCallback() and cancelStreamCallback() methods (the blocking tickStream() method can be used before a callback is set and/or after a callback is cancelled). An RtError will be thrown if called when no stream is open or a thread errors occurs. */ void setStreamCallback(RtAudioCallback callback, void *userData) { rtapi_->setStreamCallback( callback, userData ); }; //! A public method which cancels a callback process and function for the stream. /*! This method shuts down a callback process and de-references the user function for the stream. Callback functionality can subsequently be restarted on the stream via the setStreamCallback() method. An RtError will be thrown if called when no stream is open. */ void cancelStreamCallback() { rtapi_->cancelStreamCallback(); }; //! A public method which returns the number of audio devices found. int getDeviceCount(void) { return rtapi_->getDeviceCount(); }; //! Return an RtAudioDeviceInfo structure for a specified device number. /*! Any device integer between 1 and getDeviceCount() is valid. If a device is busy or otherwise unavailable, the structure member "probed" will have a value of "false" and all other members are undefined. If the specified device is the current default input or output device, the "isDefault" member will have a value of "true". An RtError will be thrown for an invalid device argument. */ RtAudioDeviceInfo getDeviceInfo(int device) { return rtapi_->getDeviceInfo( device ); }; //! A public method which returns a pointer to the buffer for an open stream. /*! The user should fill and/or read the buffer data in interleaved format and then call the tickStream() method. An RtError will be thrown if called when no stream is open. */ char * const getStreamBuffer() { return rtapi_->getStreamBuffer(); }; //! Public method used to trigger processing of input/output data for a stream. /*! This method blocks until all buffer data is read/written. An RtError will be thrown if a driver error occurs or if called when no stream is open. */ void tickStream() { rtapi_->tickStream(); }; //! Public method which closes a stream and frees any associated buffers. /*! If a stream is not open, this method issues a warning and returns (an RtError is not thrown). */ void closeStream() { rtapi_->closeStream(); }; //! Public method which starts a stream. /*! An RtError will be thrown if a driver error occurs or if called when no stream is open. */ void startStream() { rtapi_->startStream(); }; //! Stop a stream, allowing any samples remaining in the queue to be played out and/or read in. /*! An RtError will be thrown if a driver error occurs or if called when no stream is open. */ void stopStream() { rtapi_->stopStream(); }; //! Stop a stream, discarding any samples remaining in the input/output queue. /*! An RtError will be thrown if a driver error occurs or if called when no stream is open. */ void abortStream() { rtapi_->abortStream(); }; protected: void initialize( RtAudioApi api ); RtApi *rtapi_;};// RtApi Subclass prototypes.#if defined(__LINUX_ALSA__)class RtApiAlsa: public RtApi{public: RtApiAlsa(); ~RtApiAlsa(); void tickStream(); void closeStream(); void startStream(); void stopStream(); void abortStream(); int streamWillBlock(); void setStreamCallback( RtAudioCallback callback, void *userData ); void cancelStreamCallback(); private: void initialize(void); void probeDeviceInfo( RtApiDevice *info ); bool probeDeviceOpen( int device, StreamMode mode, int channels, int sampleRate, RtAudioFormat format, int *bufferSize, int numberOfBuffers );};#endif#if defined(__LINUX_JACK__)class RtApiJack: public RtApi{public: RtApiJack(); ~RtApiJack(); void tickStream(); void closeStream(); void startStream(); void stopStream(); void abortStream(); void setStreamCallback( RtAudioCallback callback, void *userData ); void cancelStreamCallback(); // This function is intended for internal use only. It must be // public because it is called by the internal callback handler, // which is not a member of RtAudio. External use of this function // will most likely produce highly undesireable results! void callbackEvent( unsigned long nframes ); private: void initialize(void); void probeDeviceInfo( RtApiDevice *info ); bool probeDeviceOpen( int device, StreamMode mode, int channels, int sampleRate, RtAudioFormat format, int *bufferSize, int numberOfBuffers );};#endif#if defined(__LINUX_OSS__)class RtApiOss: public RtApi{public: RtApiOss(); ~RtApiOss(); void tickStream(); void closeStream(); void startStream(); void stopStream(); void abortStream(); int streamWillBlock(); void setStreamCallback( RtAudioCallback callback, void *userData ); void cancelStreamCallback(); private: void initialize(void); void probeDeviceInfo( RtApiDevice *info ); bool probeDeviceOpen( int device, StreamMode mode, int channels, int sampleRate, RtAudioFormat format, int *bufferSize, int numberOfBuffers );};#endif#if defined(__MACOSX_CORE__)#include <CoreAudio/AudioHardware.h>class RtApiCore: public RtApi{public: RtApiCore(); ~RtApiCore(); int getDefaultOutputDevice(void); int getDefaultInputDevice(void); void tickStream(); void closeStream(); void startStream(); void stopStream(); void abortStream(); void setStreamCallback( RtAudioCallback callback, void *userData ); void cancelStreamCallback(); // This function is intended for internal use only. It must be // public because it is called by the internal callback handler, // which is not a member of RtAudio. External use of this function // will most likely produce highly undesireable results! void callbackEvent( AudioDeviceID deviceId, void *inData, void *outData ); private: void initialize(void); void probeDeviceInfo( RtApiDevice *info ); bool probeDeviceOpen( int device, StreamMode mode, int channels, int sampleRate, RtAudioFormat format, int *bufferSize, int numberOfBuffers );};#endif#if defined(__WINDOWS_DS__)class RtApiDs: public RtApi{public: RtApiDs(); ~RtApiDs(); int getDefaultOutputDevice(void); int getDefaultInputDevice(void); void tickStream(); void closeStream(); void startStream(); void stopStream(); void abortStream(); int streamWillBlock(); void setStreamCallback( RtAudioCallback callback, void *userData ); void cancelStreamCallback(); public: // \brief Internal structure that provide debug information on the state of a running DSound device. struct RtDsStatistics { // \brief Sample Rate. long sampleRate; // \brief The size of one sample * number of channels on the input device. int inputFrameSize; // \brief The size of one sample * number of channels on the output device. int outputFrameSize; /* \brief The number of times the read pointer had to be adjusted to avoid reading from an unsafe buffer position. * * This field is only used when running in DUPLEX mode. INPUT mode devices just wait until the data is * available. */ int numberOfReadOverruns; // \brief The number of times the write pointer had to be adjusted to avoid writing in an unsafe buffer position. int numberOfWriteUnderruns; // \brief Number of bytes by attribute to buffer configuration by which writing must lead the current write pointer. int writeDeviceBufferLeadBytes; // \brief Number of bytes by attributable to the device driver by which writing must lead the current write pointer on this output device. unsigned long writeDeviceSafeLeadBytes; // \brief Number of bytes by which reading must trail the current read pointer on this input device. unsigned long readDeviceSafeLeadBytes; /* \brief Estimated latency in seconds. * * For INPUT mode devices, based the latency of the device's safe read pointer, plus one buffer's * worth of additional latency. * * For OUTPUT mode devices, the latency of the device's safe write pointer, plus N buffers of * additional buffer latency. * * For DUPLEX devices, the sum of latencies for both input and output devices. DUPLEX devices * also back off the read pointers an additional amount in order to maintain synchronization * between out-of-phase read and write pointers. This time is also included. * * Note that most software packages report latency between the safe write pointer * and the software lead pointer, excluding the hardware device's safe write pointer * latency. Figures of 1 or 2ms of latency on Windows audio devices are invariably of this type. * The reality is that hardware devices often have latencies of 30ms or more (often much * higher for duplex operation). */ double latency; }; // \brief Report on the current state of a running DSound device. static RtDsStatistics getDsStatistics(); private: void initialize(void); void probeDeviceInfo( RtApiDevice *info ); bool probeDeviceOpen( int device, StreamMode mode, int channels, int sampleRate, RtAudioFormat format, int *bufferSize, int numberOfBuffers ); bool coInitialized; bool buffersRolling; long duplexPrerollBytes; static RtDsStatistics statistics;};#endif#if defined(__WINDOWS_ASIO__)class RtApiAsio: public RtApi{public: RtApiAsio(); ~RtApiAsio(); void tickStream(); void closeStream(); void startStream(); void stopStream(); void abortStream(); void setStreamCallback( RtAudioCallback callback, void *userData ); void cancelStreamCallback(); // This function is intended for internal use only. It must be // public because it is called by the internal callback handler, // which is not a member of RtAudio. External use of this function // will most likely produce highly undesireable results! void callbackEvent( long bufferIndex ); private: void initialize(void); void probeDeviceInfo( RtApiDevice *info ); bool probeDeviceOpen( int device, StreamMode mode, int channels, int sampleRate, RtAudioFormat format, int *bufferSize, int numberOfBuffers ); bool coInitialized;};#endif#if defined(__IRIX_AL__)class RtApiAl: public RtApi{public: RtApiAl(); ~RtApiAl(); int getDefaultOutputDevice(void); int getDefaultInputDevice(void); void tickStream(); void closeStream(); void startStream(); void stopStream(); void abortStream(); int streamWillBlock(); void setStreamCallback( RtAudioCallback callback, void *userData ); void cancelStreamCallback(); private: void initialize(void); void probeDeviceInfo( RtApiDevice *info ); bool probeDeviceOpen( int device, StreamMode mode, int channels, int sampleRate, RtAudioFormat format, int *bufferSize, int numberOfBuffers );};#endif// Define the following flag to have extra information spewed to stderr.//#define __RTAUDIO_DEBUG__#endif // SYMBIAN#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -