Home   Class/Enum List   File List   Compound Members  

RtAudio.h
Go to the documentation of this file.
1 /************************************************************************/
39 /************************************************************************/
40 
45 #ifndef __RTAUDIO_H
46 #define __RTAUDIO_H
47 
48 #define RTAUDIO_VERSION "4.1.0"
49 
50 #include <string>
51 #include <vector>
52 #include <exception>
53 #include <iostream>
54 
71 typedef unsigned long RtAudioFormat;
72 static const RtAudioFormat RTAUDIO_SINT8 = 0x1; // 8-bit signed integer.
73 static const RtAudioFormat RTAUDIO_SINT16 = 0x2; // 16-bit signed integer.
74 static const RtAudioFormat RTAUDIO_SINT24 = 0x4; // 24-bit signed integer.
75 static const RtAudioFormat RTAUDIO_SINT32 = 0x8; // 32-bit signed integer.
76 static const RtAudioFormat RTAUDIO_FLOAT32 = 0x10; // Normalized between plus/minus 1.0.
77 static const RtAudioFormat RTAUDIO_FLOAT64 = 0x20; // Normalized between plus/minus 1.0.
78 
121 typedef unsigned int RtAudioStreamFlags;
122 static const RtAudioStreamFlags RTAUDIO_NONINTERLEAVED = 0x1; // Use non-interleaved buffers (default = interleaved).
123 static const RtAudioStreamFlags RTAUDIO_MINIMIZE_LATENCY = 0x2; // Attempt to set stream parameters for lowest possible latency.
124 static const RtAudioStreamFlags RTAUDIO_HOG_DEVICE = 0x4; // Attempt grab device and prevent use by others.
125 static const RtAudioStreamFlags RTAUDIO_SCHEDULE_REALTIME = 0x8; // Try to select realtime scheduling for callback thread.
126 static const RtAudioStreamFlags RTAUDIO_ALSA_USE_DEFAULT = 0x10; // Use the "default" PCM device (ALSA only).
127 
139 typedef unsigned int RtAudioStreamStatus;
140 static const RtAudioStreamStatus RTAUDIO_INPUT_OVERFLOW = 0x1; // Input data was discarded because of an overflow condition at the driver.
141 static const RtAudioStreamStatus RTAUDIO_OUTPUT_UNDERFLOW = 0x2; // The output buffer ran low, likely causing a gap in the output sound.
142 
144 
182 typedef int (*RtAudioCallback)( void *outputBuffer, void *inputBuffer,
183  unsigned int nFrames,
184  double streamTime,
185  RtAudioStreamStatus status,
186  void *userData );
187 
188 /************************************************************************/
196 /************************************************************************/
197 
198 class RtAudioError : public std::exception
199 {
200  public:
202  enum Type {
214  };
215 
217  RtAudioError( const std::string& message, Type type = RtAudioError::UNSPECIFIED ) throw() : message_(message), type_(type) {}
218 
220  virtual ~RtAudioError( void ) throw() {}
221 
223  virtual void printMessage( void ) const throw() { std::cerr << '\n' << message_ << "\n\n"; }
224 
226  virtual const Type& getType(void) const throw() { return type_; }
227 
229  virtual const std::string& getMessage(void) const throw() { return message_; }
230 
232  virtual const char* what( void ) const throw() { return message_.c_str(); }
233 
234  protected:
235  std::string message_;
236  Type type_;
237 };
238 
240 
244 typedef void (*RtAudioErrorCallback)( RtAudioError::Type type, const std::string &errorText );
245 
246 // **************************************************************** //
247 //
248 // RtAudio class declaration.
249 //
250 // RtAudio is a "controller" used to select an available audio i/o
251 // interface. It presents a common API for the user to call but all
252 // functionality is implemented by the class RtApi and its
253 // subclasses. RtAudio creates an instance of an RtApi subclass
254 // based on the user's API choice. If no choice is made, RtAudio
255 // attempts to make a "logical" API selection.
256 //
257 // **************************************************************** //
258 
259 class RtApi;
260 
261 class RtAudio
262 {
263  public:
264 
266  enum Api {
277  };
278 
280  struct DeviceInfo {
281  bool probed;
282  std::string name;
283  unsigned int outputChannels;
284  unsigned int inputChannels;
285  unsigned int duplexChannels;
288  std::vector<unsigned int> sampleRates;
291  // Default constructor.
292  DeviceInfo()
294  isDefaultOutput(false), isDefaultInput(false), nativeFormats(0) {}
295  };
296 
299  unsigned int deviceId;
300  unsigned int nChannels;
301  unsigned int firstChannel;
303  // Default constructor.
305  : deviceId(0), nChannels(0), firstChannel(0) {}
306  };
307 
309 
365  struct StreamOptions {
367  unsigned int numberOfBuffers;
368  std::string streamName;
369  int priority;
371  // Default constructor.
372  StreamOptions()
373  : flags(0), numberOfBuffers(0), priority(0) {}
374  };
375 
377  static std::string getVersion( void ) throw();
378 
380 
385  static void getCompiledApi( std::vector<RtAudio::Api> &apis ) throw();
386 
388 
396  RtAudio( RtAudio::Api api=UNSPECIFIED );
397 
399 
403  ~RtAudio() throw();
404 
406  RtAudio::Api getCurrentApi( void ) throw();
407 
409 
414  unsigned int getDeviceCount( void ) throw();
415 
417 
427  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
428 
430 
437  unsigned int getDefaultOutputDevice( void ) throw();
438 
440 
447  unsigned int getDefaultInputDevice( void ) throw();
448 
450 
489  void openStream( RtAudio::StreamParameters *outputParameters,
490  RtAudio::StreamParameters *inputParameters,
491  RtAudioFormat format, unsigned int sampleRate,
492  unsigned int *bufferFrames, RtAudioCallback callback,
493  void *userData = NULL, RtAudio::StreamOptions *options = NULL, RtAudioErrorCallback errorCallback = NULL );
494 
496 
500  void closeStream( void ) throw();
501 
503 
509  void startStream( void );
510 
512 
518  void stopStream( void );
519 
521 
527  void abortStream( void );
528 
530  bool isStreamOpen( void ) const throw();
531 
533  bool isStreamRunning( void ) const throw();
534 
536 
539  double getStreamTime( void );
540 
542 
550  long getStreamLatency( void );
551 
553 
558  unsigned int getStreamSampleRate( void );
559 
561  void showWarnings( bool value = true ) throw();
562 
563  protected:
564 
565  void openRtApi( RtAudio::Api api );
566  RtApi *rtapi_;
567 };
568 
569 // Operating system dependent thread functionality.
570 #if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) || defined(__WINDOWS_WASAPI__)
571  #include <windows.h>
572  #include <process.h>
573 
574  typedef ULONG_PTR ThreadHandle;
575  typedef CRITICAL_SECTION StreamMutex;
576 
577 #elif defined(__LINUX_ALSA__) || defined(__LINUX_PULSE__) || defined(__UNIX_JACK__) || defined(__LINUX_OSS__) || defined(__MACOSX_CORE__)
578  // Using pthread library for various flavors of unix.
579  #include <pthread.h>
580 
581  typedef pthread_t ThreadHandle;
582  typedef pthread_mutex_t StreamMutex;
583 
584 #else // Setup for "dummy" behavior
585 
586  #define __RTAUDIO_DUMMY__
587  typedef int ThreadHandle;
588  typedef int StreamMutex;
589 
590 #endif
591 
592 // This global structure type is used to pass callback information
593 // between the private RtAudio stream structure and global callback
594 // handling functions.
595 struct CallbackInfo {
596  void *object; // Used as a "this" pointer.
597  ThreadHandle thread;
598  void *callback;
599  void *userData;
600  void *errorCallback;
601  void *apiInfo; // void pointer for API specific callback information
602  bool isRunning;
603  bool doRealtime;
604  int priority;
605 
606  // Default constructor.
607  CallbackInfo()
608  :object(0), callback(0), userData(0), errorCallback(0), apiInfo(0), isRunning(false), doRealtime(false) {}
609 };
610 
611 // **************************************************************** //
612 //
613 // RtApi class declaration.
614 //
615 // Subclasses of RtApi contain all API- and OS-specific code necessary
616 // to fully implement the RtAudio API.
617 //
618 // Note that RtApi is an abstract base class and cannot be
619 // explicitly instantiated. The class RtAudio will create an
620 // instance of an RtApi subclass (RtApiOss, RtApiAlsa,
621 // RtApiJack, RtApiCore, RtApiDs, or RtApiAsio).
622 //
623 // **************************************************************** //
624 
625 #pragma pack(push, 1)
626 class S24 {
627 
628  protected:
629  unsigned char c3[3];
630 
631  public:
632  S24() {}
633 
634  S24& operator = ( const int& i ) {
635  c3[0] = (i & 0x000000ff);
636  c3[1] = (i & 0x0000ff00) >> 8;
637  c3[2] = (i & 0x00ff0000) >> 16;
638  return *this;
639  }
640 
641  S24( const S24& v ) { *this = v; }
642  S24( const double& d ) { *this = (int) d; }
643  S24( const float& f ) { *this = (int) f; }
644  S24( const signed short& s ) { *this = (int) s; }
645  S24( const char& c ) { *this = (int) c; }
646 
647  int asInt() {
648  int i = c3[0] | (c3[1] << 8) | (c3[2] << 16);
649  if (i & 0x800000) i |= ~0xffffff;
650  return i;
651  }
652 };
653 #pragma pack(pop)
654 
655 #if defined( HAVE_GETTIMEOFDAY )
656  #include <sys/time.h>
657 #endif
658 
659 #include <sstream>
660 
661 class RtApi
662 {
663 public:
664 
665  RtApi();
666  virtual ~RtApi();
667  virtual RtAudio::Api getCurrentApi( void ) = 0;
668  virtual unsigned int getDeviceCount( void ) = 0;
669  virtual RtAudio::DeviceInfo getDeviceInfo( unsigned int device ) = 0;
670  virtual unsigned int getDefaultInputDevice( void );
671  virtual unsigned int getDefaultOutputDevice( void );
672  void openStream( RtAudio::StreamParameters *outputParameters,
673  RtAudio::StreamParameters *inputParameters,
674  RtAudioFormat format, unsigned int sampleRate,
675  unsigned int *bufferFrames, RtAudioCallback callback,
676  void *userData, RtAudio::StreamOptions *options,
677  RtAudioErrorCallback errorCallback );
678  virtual void closeStream( void );
679  virtual void startStream( void ) = 0;
680  virtual void stopStream( void ) = 0;
681  virtual void abortStream( void ) = 0;
682  long getStreamLatency( void );
683  unsigned int getStreamSampleRate( void );
684  virtual double getStreamTime( void );
685  bool isStreamOpen( void ) const { return stream_.state != STREAM_CLOSED; }
686  bool isStreamRunning( void ) const { return stream_.state == STREAM_RUNNING; }
687  void showWarnings( bool value ) { showWarnings_ = value; }
688 
689 
690 protected:
691 
692  static const unsigned int MAX_SAMPLE_RATES;
693  static const unsigned int SAMPLE_RATES[];
694 
695  enum { FAILURE, SUCCESS };
696 
697  enum StreamState {
698  STREAM_STOPPED,
699  STREAM_STOPPING,
700  STREAM_RUNNING,
701  STREAM_CLOSED = -50
702  };
703 
704  enum StreamMode {
705  OUTPUT,
706  INPUT,
707  DUPLEX,
708  UNINITIALIZED = -75
709  };
710 
711  // A protected structure used for buffer conversion.
712  struct ConvertInfo {
713  int channels;
714  int inJump, outJump;
715  RtAudioFormat inFormat, outFormat;
716  std::vector<int> inOffset;
717  std::vector<int> outOffset;
718  };
719 
720  // A protected structure for audio streams.
721  struct RtApiStream {
722  unsigned int device[2]; // Playback and record, respectively.
723  void *apiHandle; // void pointer for API specific stream handle information
724  StreamMode mode; // OUTPUT, INPUT, or DUPLEX.
725  StreamState state; // STOPPED, RUNNING, or CLOSED
726  char *userBuffer[2]; // Playback and record, respectively.
727  char *deviceBuffer;
728  bool doConvertBuffer[2]; // Playback and record, respectively.
729  bool userInterleaved;
730  bool deviceInterleaved[2]; // Playback and record, respectively.
731  bool doByteSwap[2]; // Playback and record, respectively.
732  unsigned int sampleRate;
733  unsigned int bufferSize;
734  unsigned int nBuffers;
735  unsigned int nUserChannels[2]; // Playback and record, respectively.
736  unsigned int nDeviceChannels[2]; // Playback and record channels, respectively.
737  unsigned int channelOffset[2]; // Playback and record, respectively.
738  unsigned long latency[2]; // Playback and record, respectively.
739  RtAudioFormat userFormat;
740  RtAudioFormat deviceFormat[2]; // Playback and record, respectively.
741  StreamMutex mutex;
742  CallbackInfo callbackInfo;
743  ConvertInfo convertInfo[2];
744  double streamTime; // Number of elapsed seconds since the stream started.
745 
746 #if defined(HAVE_GETTIMEOFDAY)
747  struct timeval lastTickTimestamp;
748 #endif
749 
750  RtApiStream()
751  :apiHandle(0), deviceBuffer(0) { device[0] = 11111; device[1] = 11111; }
752  };
753 
754  typedef S24 Int24;
755  typedef signed short Int16;
756  typedef signed int Int32;
757  typedef float Float32;
758  typedef double Float64;
759 
760  std::ostringstream errorStream_;
761  std::string errorText_;
762  bool showWarnings_;
763  RtApiStream stream_;
764  bool firstErrorOccurred_;
765 
773  virtual bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
774  unsigned int firstChannel, unsigned int sampleRate,
775  RtAudioFormat format, unsigned int *bufferSize,
776  RtAudio::StreamOptions *options );
777 
779  void tickStreamTime( void );
780 
782  void clearStreamInfo();
783 
788  void verifyStream( void );
789 
791  void error( RtAudioError::Type type );
792 
797  void convertBuffer( char *outBuffer, char *inBuffer, ConvertInfo &info );
798 
800  void byteSwapBuffer( char *buffer, unsigned int samples, RtAudioFormat format );
801 
803  unsigned int formatBytes( RtAudioFormat format );
804 
806  void setConvertInfo( StreamMode mode, unsigned int firstChannel );
807 };
808 
809 // **************************************************************** //
810 //
811 // Inline RtAudio definitions.
812 //
813 // **************************************************************** //
814 
815 inline RtAudio::Api RtAudio :: getCurrentApi( void ) throw() { return rtapi_->getCurrentApi(); }
816 inline unsigned int RtAudio :: getDeviceCount( void ) throw() { return rtapi_->getDeviceCount(); }
817 inline RtAudio::DeviceInfo RtAudio :: getDeviceInfo( unsigned int device ) { return rtapi_->getDeviceInfo( device ); }
818 inline unsigned int RtAudio :: getDefaultInputDevice( void ) throw() { return rtapi_->getDefaultInputDevice(); }
819 inline unsigned int RtAudio :: getDefaultOutputDevice( void ) throw() { return rtapi_->getDefaultOutputDevice(); }
820 inline void RtAudio :: closeStream( void ) throw() { return rtapi_->closeStream(); }
821 inline void RtAudio :: startStream( void ) { return rtapi_->startStream(); }
822 inline void RtAudio :: stopStream( void ) { return rtapi_->stopStream(); }
823 inline void RtAudio :: abortStream( void ) { return rtapi_->abortStream(); }
824 inline bool RtAudio :: isStreamOpen( void ) const throw() { return rtapi_->isStreamOpen(); }
825 inline bool RtAudio :: isStreamRunning( void ) const throw() { return rtapi_->isStreamRunning(); }
826 inline long RtAudio :: getStreamLatency( void ) { return rtapi_->getStreamLatency(); }
827 inline unsigned int RtAudio :: getStreamSampleRate( void ) { return rtapi_->getStreamSampleRate(); }
828 inline double RtAudio :: getStreamTime( void ) { return rtapi_->getStreamTime(); }
829 inline void RtAudio :: showWarnings( bool value ) throw() { rtapi_->showWarnings( value ); }
830 
831 // RtApi Subclass prototypes.
832 
833 #if defined(__MACOSX_CORE__)
834 
835 #include <CoreAudio/AudioHardware.h>
836 
837 class RtApiCore: public RtApi
838 {
839 public:
840 
841  RtApiCore();
842  ~RtApiCore();
844  unsigned int getDeviceCount( void );
845  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
846  unsigned int getDefaultOutputDevice( void );
847  unsigned int getDefaultInputDevice( void );
848  void closeStream( void );
849  void startStream( void );
850  void stopStream( void );
851  void abortStream( void );
852  long getStreamLatency( void );
853 
854  // This function is intended for internal use only. It must be
855  // public because it is called by the internal callback handler,
856  // which is not a member of RtAudio. External use of this function
857  // will most likely produce highly undesireable results!
858  bool callbackEvent( AudioDeviceID deviceId,
859  const AudioBufferList *inBufferList,
860  const AudioBufferList *outBufferList );
861 
862  private:
863 
864  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
865  unsigned int firstChannel, unsigned int sampleRate,
866  RtAudioFormat format, unsigned int *bufferSize,
867  RtAudio::StreamOptions *options );
868  static const char* getErrorCode( OSStatus code );
869 };
870 
871 #endif
872 
873 #if defined(__UNIX_JACK__)
874 
875 class RtApiJack: public RtApi
876 {
877 public:
878 
879  RtApiJack();
880  ~RtApiJack();
881  RtAudio::Api getCurrentApi( void ) { return RtAudio::UNIX_JACK; }
882  unsigned int getDeviceCount( void );
883  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
884  void closeStream( void );
885  void startStream( void );
886  void stopStream( void );
887  void abortStream( void );
888  long getStreamLatency( void );
889 
890  // This function is intended for internal use only. It must be
891  // public because it is called by the internal callback handler,
892  // which is not a member of RtAudio. External use of this function
893  // will most likely produce highly undesireable results!
894  bool callbackEvent( unsigned long nframes );
895 
896  private:
897 
898  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
899  unsigned int firstChannel, unsigned int sampleRate,
900  RtAudioFormat format, unsigned int *bufferSize,
901  RtAudio::StreamOptions *options );
902 };
903 
904 #endif
905 
906 #if defined(__WINDOWS_ASIO__)
907 
908 class RtApiAsio: public RtApi
909 {
910 public:
911 
912  RtApiAsio();
913  ~RtApiAsio();
915  unsigned int getDeviceCount( void );
916  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
917  void closeStream( void );
918  void startStream( void );
919  void stopStream( void );
920  void abortStream( void );
921  long getStreamLatency( void );
922 
923  // This function is intended for internal use only. It must be
924  // public because it is called by the internal callback handler,
925  // which is not a member of RtAudio. External use of this function
926  // will most likely produce highly undesireable results!
927  bool callbackEvent( long bufferIndex );
928 
929  private:
930 
931  std::vector<RtAudio::DeviceInfo> devices_;
932  void saveDeviceInfo( void );
933  bool coInitialized_;
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 );
938 };
939 
940 #endif
941 
942 #if defined(__WINDOWS_DS__)
943 
944 class RtApiDs: public RtApi
945 {
946 public:
947 
948  RtApiDs();
949  ~RtApiDs();
951  unsigned int getDeviceCount( void );
952  unsigned int getDefaultOutputDevice( void );
953  unsigned int getDefaultInputDevice( void );
954  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
955  void closeStream( void );
956  void startStream( void );
957  void stopStream( void );
958  void abortStream( void );
959  long getStreamLatency( void );
960 
961  // This function is intended for internal use only. It must be
962  // public because it is called by the internal callback handler,
963  // which is not a member of RtAudio. External use of this function
964  // will most likely produce highly undesireable results!
965  void callbackEvent( void );
966 
967  private:
968 
969  bool coInitialized_;
970  bool buffersRolling;
971  long duplexPrerollBytes;
972  std::vector<struct DsDevice> dsDevices;
973  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
974  unsigned int firstChannel, unsigned int sampleRate,
975  RtAudioFormat format, unsigned int *bufferSize,
976  RtAudio::StreamOptions *options );
977 };
978 
979 #endif
980 
981 #if defined(__WINDOWS_WASAPI__)
982 
983 struct IMMDeviceEnumerator;
984 
985 class RtApiWasapi : public RtApi
986 {
987 public:
988  RtApiWasapi();
989  ~RtApiWasapi();
990 
992  unsigned int getDeviceCount( void );
993  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
994  unsigned int getDefaultOutputDevice( void );
995  unsigned int getDefaultInputDevice( void );
996  void closeStream( void );
997  void startStream( void );
998  void stopStream( void );
999  void abortStream( void );
1000 
1001 private:
1002  bool coInitialized_;
1003  IMMDeviceEnumerator* deviceEnumerator_;
1004 
1005  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
1006  unsigned int firstChannel, unsigned int sampleRate,
1007  RtAudioFormat format, unsigned int* bufferSize,
1008  RtAudio::StreamOptions* options );
1009 
1010  static DWORD WINAPI runWasapiThread( void* wasapiPtr );
1011  static DWORD WINAPI stopWasapiThread( void* wasapiPtr );
1012  static DWORD WINAPI abortWasapiThread( void* wasapiPtr );
1013  void wasapiThread();
1014 };
1015 
1016 #endif
1017 
1018 #if defined(__LINUX_ALSA__)
1019 
1020 class RtApiAlsa: public RtApi
1021 {
1022 public:
1023 
1024  RtApiAlsa();
1025  ~RtApiAlsa();
1027  unsigned int getDeviceCount( void );
1028  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
1029  void closeStream( void );
1030  void startStream( void );
1031  void stopStream( void );
1032  void abortStream( void );
1033 
1034  // This function is intended for internal use only. It must be
1035  // public because it is called by the internal callback handler,
1036  // which is not a member of RtAudio. External use of this function
1037  // will most likely produce highly undesireable results!
1038  void callbackEvent( void );
1039 
1040  private:
1041 
1042  std::vector<RtAudio::DeviceInfo> devices_;
1043  void saveDeviceInfo( void );
1044  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
1045  unsigned int firstChannel, unsigned int sampleRate,
1046  RtAudioFormat format, unsigned int *bufferSize,
1047  RtAudio::StreamOptions *options );
1048 };
1049 
1050 #endif
1051 
1052 #if defined(__LINUX_PULSE__)
1053 
1054 class RtApiPulse: public RtApi
1055 {
1056 public:
1057  ~RtApiPulse();
1059  unsigned int getDeviceCount( void );
1060  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
1061  void closeStream( void );
1062  void startStream( void );
1063  void stopStream( void );
1064  void abortStream( void );
1065 
1066  // This function is intended for internal use only. It must be
1067  // public because it is called by the internal callback handler,
1068  // which is not a member of RtAudio. External use of this function
1069  // will most likely produce highly undesireable results!
1070  void callbackEvent( void );
1071 
1072  private:
1073 
1074  std::vector<RtAudio::DeviceInfo> devices_;
1075  void saveDeviceInfo( void );
1076  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
1077  unsigned int firstChannel, unsigned int sampleRate,
1078  RtAudioFormat format, unsigned int *bufferSize,
1079  RtAudio::StreamOptions *options );
1080 };
1081 
1082 #endif
1083 
1084 #if defined(__LINUX_OSS__)
1085 
1086 class RtApiOss: public RtApi
1087 {
1088 public:
1089 
1090  RtApiOss();
1091  ~RtApiOss();
1093  unsigned int getDeviceCount( void );
1094  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
1095  void closeStream( void );
1096  void startStream( void );
1097  void stopStream( void );
1098  void abortStream( void );
1099 
1100  // This function is intended for internal use only. It must be
1101  // public because it is called by the internal callback handler,
1102  // which is not a member of RtAudio. External use of this function
1103  // will most likely produce highly undesireable results!
1104  void callbackEvent( void );
1105 
1106  private:
1107 
1108  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
1109  unsigned int firstChannel, unsigned int sampleRate,
1110  RtAudioFormat format, unsigned int *bufferSize,
1111  RtAudio::StreamOptions *options );
1112 };
1113 
1114 #endif
1115 
1116 #if defined(__RTAUDIO_DUMMY__)
1117 
1118 class RtApiDummy: public RtApi
1119 {
1120 public:
1121 
1122  RtApiDummy() { errorText_ = "RtApiDummy: This class provides no functionality."; error( RtAudioError::WARNING ); }
1124  unsigned int getDeviceCount( void ) { return 0; }
1125  RtAudio::DeviceInfo getDeviceInfo( unsigned int /*device*/ ) { RtAudio::DeviceInfo info; return info; }
1126  void closeStream( void ) {}
1127  void startStream( void ) {}
1128  void stopStream( void ) {}
1129  void abortStream( void ) {}
1130 
1131  private:
1132 
1133  bool probeDeviceOpen( unsigned int /*device*/, StreamMode /*mode*/, unsigned int /*channels*/,
1134  unsigned int /*firstChannel*/, unsigned int /*sampleRate*/,
1135  RtAudioFormat /*format*/, unsigned int * /*bufferSize*/,
1136  RtAudio::StreamOptions * /*options*/ ) { return false; }
1137 };
1138 
1139 #endif
1140 
1141 #endif
1142 
1143 // Indentation settings for Vim and Emacs
1144 //
1145 // Local Variables:
1146 // c-basic-offset: 2
1147 // indent-tabs-mode: nil
1148 // End:
1149 //
1150 // vim: et sts=2 sw=2

©2001-2014 Gary P. Scavone, McGill University. All Rights Reserved.
Maintained by Gary P. Scavone.