JackTrip
RtAudio.h
Go to the documentation of this file.
1 /************************************************************************/
39 /************************************************************************/
40 
45 // RtAudio: Version 4.0.11
46 
47 #ifndef __RTAUDIO_H
48 #define __RTAUDIO_H
49 
50 #include <string>
51 #include <vector>
52 #include "RtError.h"
53 
72 typedef unsigned long RtAudioFormat;
73 static const RtAudioFormat RTAUDIO_SINT8 = 0x1; // 8-bit signed integer.
74 static const RtAudioFormat RTAUDIO_SINT16 = 0x2; // 16-bit signed integer.
75 static const RtAudioFormat RTAUDIO_SINT24 = 0x4; // Lower 3 bytes of 32-bit signed integer.
76 static const RtAudioFormat RTAUDIO_SINT32 = 0x8; // 32-bit signed integer.
77 static const RtAudioFormat RTAUDIO_FLOAT32 = 0x10; // Normalized between plus/minus 1.0.
78 static const RtAudioFormat RTAUDIO_FLOAT64 = 0x20; // Normalized between plus/minus 1.0.
79 
122 typedef unsigned int RtAudioStreamFlags;
123 static const RtAudioStreamFlags RTAUDIO_NONINTERLEAVED = 0x1; // Use non-interleaved buffers (default = interleaved).
124 static const RtAudioStreamFlags RTAUDIO_MINIMIZE_LATENCY = 0x2; // Attempt to set stream parameters for lowest possible latency.
125 static const RtAudioStreamFlags RTAUDIO_HOG_DEVICE = 0x4; // Attempt grab device and prevent use by others.
126 static const RtAudioStreamFlags RTAUDIO_SCHEDULE_REALTIME = 0x8; // Try to select realtime scheduling for callback thread.
127 static const RtAudioStreamFlags RTAUDIO_ALSA_USE_DEFAULT = 0x10; // Use the "default" PCM device (ALSA only).
128 
140 typedef unsigned int RtAudioStreamStatus;
141 static const RtAudioStreamStatus RTAUDIO_INPUT_OVERFLOW = 0x1; // Input data was discarded because of an overflow condition at the driver.
142 static const RtAudioStreamStatus RTAUDIO_OUTPUT_UNDERFLOW = 0x2; // The output buffer ran low, likely causing a gap in the output sound.
143 
145 
183 typedef int (*RtAudioCallback)( void *outputBuffer, void *inputBuffer,
184  unsigned int nFrames,
185  double streamTime,
186  RtAudioStreamStatus status,
187  void *userData );
188 
189 
190 // **************************************************************** //
191 //
192 // RtAudio class declaration.
193 //
194 // RtAudio is a "controller" used to select an available audio i/o
195 // interface. It presents a common API for the user to call but all
196 // functionality is implemented by the class RtApi and its
197 // subclasses. RtAudio creates an instance of an RtApi subclass
198 // based on the user's API choice. If no choice is made, RtAudio
199 // attempts to make a "logical" API selection.
200 //
201 // **************************************************************** //
202 
203 class RtApi;
204 
205 class RtAudio
206 {
207  public:
208 
210  enum Api {
220  };
221 
223  struct DeviceInfo {
224  bool probed;
225  std::string name;
226  unsigned int outputChannels;
227  unsigned int inputChannels;
228  unsigned int duplexChannels;
231  std::vector<unsigned int> sampleRates;
234  // Default constructor.
237  isDefaultOutput(false), isDefaultInput(false), nativeFormats(0) {}
238  };
239 
242  unsigned int deviceId;
243  unsigned int nChannels;
244  unsigned int firstChannel;
246  // Default constructor.
248  : deviceId(0), nChannels(0), firstChannel(0) {}
249  };
250 
252 
308  struct StreamOptions {
310  unsigned int numberOfBuffers;
311  std::string streamName;
312  int priority;
314  // Default constructor.
316  : flags(0), numberOfBuffers(0), priority(0) {}
317  };
318 
320 
325  static void getCompiledApi( std::vector<RtAudio::Api> &apis ) throw();
326 
328 
336  RtAudio( RtAudio::Api api=UNSPECIFIED ) throw();
337 
339 
343  ~RtAudio() throw();
344 
346  RtAudio::Api getCurrentApi( void ) throw();
347 
349 
354  unsigned int getDeviceCount( void ) throw();
355 
357 
367  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
368 
370 
377  unsigned int getDefaultOutputDevice( void ) throw();
378 
380 
387  unsigned int getDefaultInputDevice( void ) throw();
388 
390 
427  void openStream( RtAudio::StreamParameters *outputParameters,
428  RtAudio::StreamParameters *inputParameters,
429  RtAudioFormat format, unsigned int sampleRate,
430  unsigned int *bufferFrames, RtAudioCallback callback,
431  void *userData = NULL, RtAudio::StreamOptions *options = NULL );
432 
434 
438  void closeStream( void ) throw();
439 
441 
447  void startStream( void );
448 
450 
456  void stopStream( void );
457 
459 
465  void abortStream( void );
466 
468  bool isStreamOpen( void ) const throw();
469 
471  bool isStreamRunning( void ) const throw();
472 
474 
477  double getStreamTime( void );
478 
480 
488  long getStreamLatency( void );
489 
491 
496  unsigned int getStreamSampleRate( void );
497 
499  void showWarnings( bool value = true ) throw();
500 
501  protected:
502 
503  void openRtApi( RtAudio::Api api );
505 };
506 
507 // Operating system dependent thread functionality.
508 #if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)
509  #include <windows.h>
510  #include <process.h>
511 
512  typedef unsigned long ThreadHandle;
513  typedef CRITICAL_SECTION StreamMutex;
514 
515 #elif defined(__LINUX_ALSA__) || defined(__LINUX_PULSE__) || defined(__UNIX_JACK__) || defined(__LINUX_OSS__) || defined(__MACOSX_CORE__)
516  // Using pthread library for various flavors of unix.
517  #include <pthread.h>
518 
519  typedef pthread_t ThreadHandle;
520  typedef pthread_mutex_t StreamMutex;
521 
522 #else // Setup for "dummy" behavior
523 
524  #define __RTAUDIO_DUMMY__
525  typedef int ThreadHandle;
526  typedef int StreamMutex;
527 
528 #endif
529 
530 // This global structure type is used to pass callback information
531 // between the private RtAudio stream structure and global callback
532 // handling functions.
533 struct CallbackInfo {
534  void *object; // Used as a "this" pointer.
536  void *callback;
537  void *userData;
538  void *apiInfo; // void pointer for API specific callback information
539  bool isRunning;
540 
541  // Default constructor.
543  :object(0), callback(0), userData(0), apiInfo(0), isRunning(false) {}
544 };
545 
546 // **************************************************************** //
547 //
548 // RtApi class declaration.
549 //
550 // Subclasses of RtApi contain all API- and OS-specific code necessary
551 // to fully implement the RtAudio API.
552 //
553 // Note that RtApi is an abstract base class and cannot be
554 // explicitly instantiated. The class RtAudio will create an
555 // instance of an RtApi subclass (RtApiOss, RtApiAlsa,
556 // RtApiJack, RtApiCore, RtApiDs, or RtApiAsio).
557 //
558 // **************************************************************** //
559 
560 #if defined( HAVE_GETTIMEOFDAY )
561  #include <sys/time.h>
562 #endif
563 
564 #include <sstream>
565 
566 class RtApi
567 {
568 public:
569 
570  RtApi();
571  virtual ~RtApi();
572  virtual RtAudio::Api getCurrentApi( void ) = 0;
573  virtual unsigned int getDeviceCount( void ) = 0;
574  virtual RtAudio::DeviceInfo getDeviceInfo( unsigned int device ) = 0;
575  virtual unsigned int getDefaultInputDevice( void );
576  virtual unsigned int getDefaultOutputDevice( void );
577  void openStream( RtAudio::StreamParameters *outputParameters,
578  RtAudio::StreamParameters *inputParameters,
579  RtAudioFormat format, unsigned int sampleRate,
580  unsigned int *bufferFrames, RtAudioCallback callback,
581  void *userData, RtAudio::StreamOptions *options );
582  virtual void closeStream( void );
583  virtual void startStream( void ) = 0;
584  virtual void stopStream( void ) = 0;
585  virtual void abortStream( void ) = 0;
586  long getStreamLatency( void );
587  unsigned int getStreamSampleRate( void );
588  virtual double getStreamTime( void );
589  bool isStreamOpen( void ) const { return stream_.state != STREAM_CLOSED; };
590  bool isStreamRunning( void ) const { return stream_.state == STREAM_RUNNING; };
591  void showWarnings( bool value ) { showWarnings_ = value; };
592 
593 
594 protected:
595 
596  static const unsigned int MAX_SAMPLE_RATES;
597  static const unsigned int SAMPLE_RATES[];
598 
599  enum { FAILURE, SUCCESS };
600 
601  enum StreamState {
605  STREAM_CLOSED = -50
606  };
607 
608  enum StreamMode {
612  UNINITIALIZED = -75
613  };
614 
615  // A protected structure used for buffer conversion.
616  struct ConvertInfo {
617  int channels;
618  int inJump, outJump;
620  std::vector<int> inOffset;
621  std::vector<int> outOffset;
622  };
623 
624  // A protected structure for audio streams.
625  struct RtApiStream {
626  unsigned int device[2]; // Playback and record, respectively.
627  void *apiHandle; // void pointer for API specific stream handle information
628  StreamMode mode; // OUTPUT, INPUT, or DUPLEX.
629  StreamState state; // STOPPED, RUNNING, or CLOSED
630  char *userBuffer[2]; // Playback and record, respectively.
632  bool doConvertBuffer[2]; // Playback and record, respectively.
634  bool deviceInterleaved[2]; // Playback and record, respectively.
635  bool doByteSwap[2]; // Playback and record, respectively.
636  unsigned int sampleRate;
637  unsigned int bufferSize;
638  unsigned int nBuffers;
639  unsigned int nUserChannels[2]; // Playback and record, respectively.
640  unsigned int nDeviceChannels[2]; // Playback and record channels, respectively.
641  unsigned int channelOffset[2]; // Playback and record, respectively.
642  unsigned long latency[2]; // Playback and record, respectively.
644  RtAudioFormat deviceFormat[2]; // Playback and record, respectively.
647  ConvertInfo convertInfo[2];
648  double streamTime; // Number of elapsed seconds since the stream started.
649 
650 #if defined(HAVE_GETTIMEOFDAY)
651  struct timeval lastTickTimestamp;
652 #endif
653 
655  :apiHandle(0), deviceBuffer(0) { device[0] = 11111; device[1] = 11111; }
656  };
657 
658  typedef signed short Int16;
659  typedef signed int Int32;
660  typedef float Float32;
661  typedef double Float64;
662 
663  std::ostringstream errorStream_;
664  std::string errorText_;
667 
675  virtual bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
676  unsigned int firstChannel, unsigned int sampleRate,
677  RtAudioFormat format, unsigned int *bufferSize,
678  RtAudio::StreamOptions *options );
679 
681  void tickStreamTime( void );
682 
684  void clearStreamInfo();
685 
690  void verifyStream( void );
691 
693  void error( RtError::Type type );
694 
699  void convertBuffer( char *outBuffer, char *inBuffer, ConvertInfo &info );
700 
702  void byteSwapBuffer( char *buffer, unsigned int samples, RtAudioFormat format );
703 
705  unsigned int formatBytes( RtAudioFormat format );
706 
708  void setConvertInfo( StreamMode mode, unsigned int firstChannel );
709 };
710 
711 // **************************************************************** //
712 //
713 // Inline RtAudio definitions.
714 //
715 // **************************************************************** //
716 
717 inline RtAudio::Api RtAudio :: getCurrentApi( void ) throw() { return rtapi_->getCurrentApi(); }
718 inline unsigned int RtAudio :: getDeviceCount( void ) throw() { return rtapi_->getDeviceCount(); }
719 inline RtAudio::DeviceInfo RtAudio :: getDeviceInfo( unsigned int device ) { return rtapi_->getDeviceInfo( device ); }
720 inline unsigned int RtAudio :: getDefaultInputDevice( void ) throw() { return rtapi_->getDefaultInputDevice(); }
721 inline unsigned int RtAudio :: getDefaultOutputDevice( void ) throw() { return rtapi_->getDefaultOutputDevice(); }
722 inline void RtAudio :: closeStream( void ) throw() { return rtapi_->closeStream(); }
723 inline void RtAudio :: startStream( void ) { return rtapi_->startStream(); }
724 inline void RtAudio :: stopStream( void ) { return rtapi_->stopStream(); }
725 inline void RtAudio :: abortStream( void ) { return rtapi_->abortStream(); }
726 inline bool RtAudio :: isStreamOpen( void ) const throw() { return rtapi_->isStreamOpen(); }
727 inline bool RtAudio :: isStreamRunning( void ) const throw() { return rtapi_->isStreamRunning(); }
728 inline long RtAudio :: getStreamLatency( void ) { return rtapi_->getStreamLatency(); }
729 inline unsigned int RtAudio :: getStreamSampleRate( void ) { return rtapi_->getStreamSampleRate(); };
730 inline double RtAudio :: getStreamTime( void ) { return rtapi_->getStreamTime(); }
731 inline void RtAudio :: showWarnings( bool value ) throw() { rtapi_->showWarnings( value ); }
732 
733 // RtApi Subclass prototypes.
734 
735 #if defined(__MACOSX_CORE__)
736 
737 #include <CoreAudio/AudioHardware.h>
738 
739 class RtApiCore: public RtApi
740 {
741 public:
742 
743  RtApiCore();
744  ~RtApiCore();
745  RtAudio::Api getCurrentApi( void ) { return RtAudio::MACOSX_CORE; };
746  unsigned int getDeviceCount( void );
747  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
748  unsigned int getDefaultOutputDevice( void );
749  unsigned int getDefaultInputDevice( void );
750  void closeStream( void );
751  void startStream( void );
752  void stopStream( void );
753  void abortStream( void );
754  long getStreamLatency( void );
755 
756  // This function is intended for internal use only. It must be
757  // public because it is called by the internal callback handler,
758  // which is not a member of RtAudio. External use of this function
759  // will most likely produce highly undesireable results!
760  bool callbackEvent( AudioDeviceID deviceId,
761  const AudioBufferList *inBufferList,
762  const AudioBufferList *outBufferList );
763 
764  private:
765 
766  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
767  unsigned int firstChannel, unsigned int sampleRate,
768  RtAudioFormat format, unsigned int *bufferSize,
769  RtAudio::StreamOptions *options );
770  static const char* getErrorCode( OSStatus code );
771 };
772 
773 #endif
774 
775 #if defined(__UNIX_JACK__)
776 
777 class RtApiJack: public RtApi
778 {
779 public:
780 
781  RtApiJack();
782  ~RtApiJack();
783  RtAudio::Api getCurrentApi( void ) { return RtAudio::UNIX_JACK; };
784  unsigned int getDeviceCount( void );
785  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
786  void closeStream( void );
787  void startStream( void );
788  void stopStream( void );
789  void abortStream( void );
790  long getStreamLatency( void );
791 
792  // This function is intended for internal use only. It must be
793  // public because it is called by the internal callback handler,
794  // which is not a member of RtAudio. External use of this function
795  // will most likely produce highly undesireable results!
796  bool callbackEvent( unsigned long nframes );
797 
798  private:
799 
800  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
801  unsigned int firstChannel, unsigned int sampleRate,
802  RtAudioFormat format, unsigned int *bufferSize,
803  RtAudio::StreamOptions *options );
804 };
805 
806 #endif
807 
808 #if defined(__WINDOWS_ASIO__)
809 
810 class RtApiAsio: public RtApi
811 {
812 public:
813 
814  RtApiAsio();
815  ~RtApiAsio();
817  unsigned int getDeviceCount( void );
818  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
819  void closeStream( void );
820  void startStream( void );
821  void stopStream( void );
822  void abortStream( void );
823  long getStreamLatency( void );
824 
825  // This function is intended for internal use only. It must be
826  // public because it is called by the internal callback handler,
827  // which is not a member of RtAudio. External use of this function
828  // will most likely produce highly undesireable results!
829  bool callbackEvent( long bufferIndex );
830 
831  private:
832 
833  std::vector<RtAudio::DeviceInfo> devices_;
834  void saveDeviceInfo( void );
835  bool coInitialized_;
836  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
837  unsigned int firstChannel, unsigned int sampleRate,
838  RtAudioFormat format, unsigned int *bufferSize,
839  RtAudio::StreamOptions *options );
840 };
841 
842 #endif
843 
844 #if defined(__WINDOWS_DS__)
845 
846 class RtApiDs: public RtApi
847 {
848 public:
849 
850  RtApiDs();
851  ~RtApiDs();
852  RtAudio::Api getCurrentApi( void ) { return RtAudio::WINDOWS_DS; };
853  unsigned int getDeviceCount( void );
854  unsigned int getDefaultOutputDevice( void );
855  unsigned int getDefaultInputDevice( void );
856  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
857  void closeStream( void );
858  void startStream( void );
859  void stopStream( void );
860  void abortStream( void );
861  long getStreamLatency( void );
862 
863  // This function is intended for internal use only. It must be
864  // public because it is called by the internal callback handler,
865  // which is not a member of RtAudio. External use of this function
866  // will most likely produce highly undesireable results!
867  void callbackEvent( void );
868 
869  private:
870 
871  bool coInitialized_;
872  bool buffersRolling;
873  long duplexPrerollBytes;
874  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
875  unsigned int firstChannel, unsigned int sampleRate,
876  RtAudioFormat format, unsigned int *bufferSize,
877  RtAudio::StreamOptions *options );
878 };
879 
880 #endif
881 
882 #if defined(__LINUX_ALSA__)
883 
884 class RtApiAlsa: public RtApi
885 {
886 public:
887 
888  RtApiAlsa();
889  ~RtApiAlsa();
891  unsigned int getDeviceCount( void );
892  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
893  void closeStream( void );
894  void startStream( void );
895  void stopStream( void );
896  void abortStream( void );
897 
898  // This function is intended for internal use only. It must be
899  // public because it is called by the internal callback handler,
900  // which is not a member of RtAudio. External use of this function
901  // will most likely produce highly undesireable results!
902  void callbackEvent( void );
903 
904  private:
905 
906  std::vector<RtAudio::DeviceInfo> devices_;
907  void saveDeviceInfo( void );
908  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
909  unsigned int firstChannel, unsigned int sampleRate,
910  RtAudioFormat format, unsigned int *bufferSize,
911  RtAudio::StreamOptions *options );
912 };
913 
914 #endif
915 
916 #if defined(__LINUX_PULSE__)
917 
918 class RtApiPulse: public RtApi
919 {
920 public:
921  ~RtApiPulse();
923  unsigned int getDeviceCount( void );
924  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
925  void closeStream( void );
926  void startStream( void );
927  void stopStream( void );
928  void abortStream( void );
929 
930  // This function is intended for internal use only. It must be
931  // public because it is called by the internal callback handler,
932  // which is not a member of RtAudio. External use of this function
933  // will most likely produce highly undesireable results!
934  void callbackEvent( void );
935 
936  private:
937 
938  std::vector<RtAudio::DeviceInfo> devices_;
939  void saveDeviceInfo( void );
940  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
941  unsigned int firstChannel, unsigned int sampleRate,
942  RtAudioFormat format, unsigned int *bufferSize,
943  RtAudio::StreamOptions *options );
944 };
945 
946 #endif
947 
948 #if defined(__LINUX_OSS__)
949 
950 class RtApiOss: public RtApi
951 {
952 public:
953 
954  RtApiOss();
955  ~RtApiOss();
957  unsigned int getDeviceCount( void );
958  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
959  void closeStream( void );
960  void startStream( void );
961  void stopStream( void );
962  void abortStream( void );
963 
964  // This function is intended for internal use only. It must be
965  // public because it is called by the internal callback handler,
966  // which is not a member of RtAudio. External use of this function
967  // will most likely produce highly undesireable results!
968  void callbackEvent( void );
969 
970  private:
971 
972  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
973  unsigned int firstChannel, unsigned int sampleRate,
974  RtAudioFormat format, unsigned int *bufferSize,
975  RtAudio::StreamOptions *options );
976 };
977 
978 #endif
979 
980 #if defined(__RTAUDIO_DUMMY__)
981 
982 class RtApiDummy: public RtApi
983 {
984 public:
985 
986  RtApiDummy() { errorText_ = "RtApiDummy: This class provides no functionality."; error( RtError::WARNING ); };
988  unsigned int getDeviceCount( void ) { return 0; };
989  RtAudio::DeviceInfo getDeviceInfo( unsigned int device ) { RtAudio::DeviceInfo info; return info; };
990  void closeStream( void ) {};
991  void startStream( void ) {};
992  void stopStream( void ) {};
993  void abortStream( void ) {};
994 
995  private:
996 
997  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
998  unsigned int firstChannel, unsigned int sampleRate,
999  RtAudioFormat format, unsigned int *bufferSize,
1000  RtAudio::StreamOptions *options ) { return false; };
1001 };
1002 
1003 #endif
1004 
1005 #endif
1006 
1007 // Indentation settings for Vim and Emacs
1008 //
1009 // Local Variables:
1010 // c-basic-offset: 2
1011 // indent-tabs-mode: nil
1012 // End:
1013 //
1014 // vim: et sts=2 sw=2
unsigned int firstChannel
Definition: RtAudio.h:244
std::vector< int > inOffset
Definition: RtAudio.h:620
void stopStream(void)
Stop a stream, allowing any samples remaining in the output queue to be played.
Definition: RtAudio.h:724
virtual unsigned int getDefaultOutputDevice(void)
Definition: RtAudio.cpp:306
Definition: RtAudio.h:213
bool userInterleaved
Definition: RtAudio.h:633
std::string name
Definition: RtAudio.h:225
virtual void stopStream(void)=0
int outJump
Definition: RtAudio.h:618
void * apiInfo
Definition: RtAudio.h:538
CallbackInfo()
Definition: RtAudio.h:542
std::vector< unsigned int > sampleRates
Definition: RtAudio.h:231
unsigned int nBuffers
Definition: RtAudio.h:638
RtAudio(RtAudio::Api api=UNSPECIFIED)
The class constructor.
Definition: RtAudio.cpp:150
void openStream(RtAudio::StreamParameters *outputParameters, RtAudio::StreamParameters *inputParameters, RtAudioFormat format, unsigned int sampleRate, unsigned int *bufferFrames, RtAudioCallback callback, void *userData=NULL, RtAudio::StreamOptions *options=NULL)
A public function for opening a stream with the specified parameters.
Definition: RtAudio.cpp:187
unsigned int RtAudioStreamFlags
RtAudio stream option flags.
Definition: RtAudio.h:122
Definition: RtAudio.h:219
bool isStreamRunning(void) const
Definition: RtAudio.h:590
void * callback
Definition: RtAudio.h:536
StreamState state
Definition: RtAudio.h:629
Realtime audio i/o C++ classes.
Definition: RtAudio.h:205
unsigned int inputChannels
Definition: RtAudio.h:227
void startStream(void)
Definition: RtAudio.h:991
unsigned int duplexChannels
Definition: RtAudio.h:228
bool isDefaultOutput
Definition: RtAudio.h:229
virtual unsigned int getDeviceCount(void)=0
void * apiHandle
Definition: RtAudio.h:627
void showWarnings(bool value=true)
Specify whether warning messages should be printed to stderr.
Definition: RtAudio.h:731
bool isStreamRunning(void) const
Returns true if the stream is running and false if it is stopped or not open.
Definition: RtAudio.h:727
unsigned long RtAudioFormat
RtAudio data format type.
Definition: RtAudio.h:72
ThreadHandle thread
Definition: RtAudio.h:535
Definition: RtAudio.h:218
int(* RtAudioCallback)(void *outputBuffer, void *inputBuffer, unsigned int nFrames, double streamTime, RtAudioStreamStatus status, void *userData)
RtAudio callback function prototype.
Definition: RtAudio.h:183
void abortStream(void)
Definition: RtAudio.h:993
bool isRunning
Definition: RtAudio.h:539
void openRtApi(RtAudio::Api api)
Definition: RtAudio.cpp:110
bool isStreamOpen(void) const
Definition: RtAudio.h:589
Definition: RtError.h:24
unsigned int getStreamSampleRate(void)
Returns actual sample rate in use by the stream.
Definition: RtAudio.h:729
Definition: RtAudio.h:602
signed short Int16
Definition: RtAudio.h:658
~RtAudio()
The destructor.
Definition: RtAudio.cpp:182
The structure for specifying input or ouput stream parameters.
Definition: RtAudio.h:241
RtAudio::DeviceInfo getDeviceInfo(unsigned int device)
Return an RtAudio::DeviceInfo structure for a specified device number.
Definition: RtAudio.h:719
unsigned int outputChannels
Definition: RtAudio.h:226
unsigned int sampleRate
Definition: RtAudio.h:636
double streamTime
Definition: RtAudio.h:648
StreamParameters()
Definition: RtAudio.h:247
RtApiDummy()
Definition: RtAudio.h:986
long getStreamLatency(void)
Definition: RtAudio.cpp:340
Definition: RtAudio.h:616
std::ostringstream errorStream_
Definition: RtAudio.h:663
RtApiStream stream_
Definition: RtAudio.h:666
unsigned int bufferSize
Definition: RtAudio.h:637
signed int Int32
Definition: RtAudio.h:659
virtual void abortStream(void)=0
unsigned int deviceId
Definition: RtAudio.h:242
int StreamMutex
Definition: RtAudio.h:526
RtAudioFormat outFormat
Definition: RtAudio.h:619
Definition: RtAudio.h:533
void stopStream(void)
Definition: RtAudio.h:992
virtual double getStreamTime(void)
Definition: RtAudio.cpp:353
static void getCompiledApi(std::vector< RtAudio::Api > &apis)
A static function to determine the available compiled audio APIs.
Definition: RtAudio.cpp:78
RtAudioFormat userFormat
Definition: RtAudio.h:643
virtual RtAudio::DeviceInfo getDeviceInfo(unsigned int device)=0
DeviceInfo()
Definition: RtAudio.h:235
std::string streamName
Definition: RtAudio.h:311
unsigned int RtAudioStreamStatus
RtAudio stream status (over- or underflow) flags.
Definition: RtAudio.h:140
void closeStream(void)
A function that closes a stream and frees any associated stream memory.
Definition: RtAudio.h:722
RtApiStream()
Definition: RtAudio.h:654
Type
Defined RtError types.
Definition: RtError.h:23
virtual void closeStream(void)
Definition: RtAudio.cpp:312
void * object
Definition: RtAudio.h:534
Definition: RtAudio.h:212
Api
Audio API specifier arguments.
Definition: RtAudio.h:210
float Float32
Definition: RtAudio.h:660
double getStreamTime(void)
Returns the number of elapsed seconds since the stream was started.
Definition: RtAudio.h:730
RtAudio::Api getCurrentApi(void)
Definition: RtAudio.h:987
RtApi * rtapi_
Definition: RtAudio.h:504
bool showWarnings_
Definition: RtAudio.h:665
unsigned int getDefaultInputDevice(void)
A function that returns the index of the default input device.
Definition: RtAudio.h:720
int channels
Definition: RtAudio.h:617
bool isStreamOpen(void) const
Returns true if a stream is open and false if not.
Definition: RtAudio.h:726
Definition: RtAudio.h:604
bool probed
Definition: RtAudio.h:224
Definition: RtAudio.h:215
Definition: RtAudio.h:610
RtAudioStreamFlags flags
Definition: RtAudio.h:309
int priority
Definition: RtAudio.h:312
double Float64
Definition: RtAudio.h:661
CallbackInfo callbackInfo
Definition: RtAudio.h:646
void abortStream(void)
Stop a stream, discarding any samples remaining in the input/output queue.
Definition: RtAudio.h:725
int ThreadHandle
Definition: RtAudio.h:525
void startStream(void)
A function that starts a stream.
Definition: RtAudio.h:723
unsigned int getDeviceCount(void)
A public function that queries for the number of audio devices available.
Definition: RtAudio.h:718
RtAudioFormat nativeFormats
Definition: RtAudio.h:232
StreamMutex mutex
Definition: RtAudio.h:645
The public device information structure for returning queried values.
Definition: RtAudio.h:223
Definition: RtAudio.h:625
Definition: RtAudio.h:214
StreamOptions()
Definition: RtAudio.h:315
The structure for specifying stream options.
Definition: RtAudio.h:308
Definition: RtAudio.h:566
virtual unsigned int getDefaultInputDevice(void)
Definition: RtAudio.cpp:300
StreamState
Definition: RtAudio.h:601
void showWarnings(bool value)
Definition: RtAudio.h:591
Definition: RtAudio.h:217
virtual void startStream(void)=0
bool isDefaultInput
Definition: RtAudio.h:230
unsigned int nChannels
Definition: RtAudio.h:243
StreamMode mode
Definition: RtAudio.h:628
std::vector< int > outOffset
Definition: RtAudio.h:621
StreamMode
Definition: RtAudio.h:608
void closeStream(void)
Definition: RtAudio.h:990
virtual RtAudio::Api getCurrentApi(void)=0
Definition: RtAudio.h:603
Definition: RtAudio.h:982
Definition: RtAudio.h:216
Definition: RtAudio.h:611
Definition: RtAudio.h:211
RtAudio::Api getCurrentApi(void)
Returns the audio API specifier for the current instance of RtAudio.
Definition: RtAudio.h:717
RtAudio::DeviceInfo getDeviceInfo(unsigned int device)
Definition: RtAudio.h:989
Definition: RtAudio.h:609
std::string errorText_
Definition: RtAudio.h:664
unsigned int numberOfBuffers
Definition: RtAudio.h:310
long getStreamLatency(void)
Returns the internal stream latency in sample frames.
Definition: RtAudio.h:728
char * deviceBuffer
Definition: RtAudio.h:631
unsigned int getStreamSampleRate(void)
Definition: RtAudio.cpp:376
unsigned int getDeviceCount(void)
Definition: RtAudio.h:988
void * userData
Definition: RtAudio.h:537
unsigned int getDefaultOutputDevice(void)
A function that returns the index of the default output device.
Definition: RtAudio.h:721