Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


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.2"
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;
289  unsigned int preferredSampleRate;
292  // Default constructor.
293  DeviceInfo()
296  };
297 
300  unsigned int deviceId;
301  unsigned int nChannels;
302  unsigned int firstChannel;
304  // Default constructor.
306  : deviceId(0), nChannels(0), firstChannel(0) {}
307  };
308 
310 
366  struct StreamOptions {
368  unsigned int numberOfBuffers;
369  std::string streamName;
370  int priority;
372  // Default constructor.
373  StreamOptions()
374  : flags(0), numberOfBuffers(0), priority(0) {}
375  };
376 
378  static std::string getVersion( void ) throw();
379 
381 
386  static void getCompiledApi( std::vector<RtAudio::Api> &apis ) throw();
387 
389 
397  RtAudio( RtAudio::Api api=UNSPECIFIED );
398 
400 
404  ~RtAudio() throw();
405 
407  RtAudio::Api getCurrentApi( void ) throw();
408 
410 
415  unsigned int getDeviceCount( void ) throw();
416 
418 
428  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
429 
431 
438  unsigned int getDefaultOutputDevice( void ) throw();
439 
441 
448  unsigned int getDefaultInputDevice( void ) throw();
449 
451 
490  void openStream( RtAudio::StreamParameters *outputParameters,
491  RtAudio::StreamParameters *inputParameters,
492  RtAudioFormat format, unsigned int sampleRate,
493  unsigned int *bufferFrames, RtAudioCallback callback,
494  void *userData = NULL, RtAudio::StreamOptions *options = NULL, RtAudioErrorCallback errorCallback = NULL );
495 
497 
501  void closeStream( void ) throw();
502 
504 
510  void startStream( void );
511 
513 
519  void stopStream( void );
520 
522 
528  void abortStream( void );
529 
531  bool isStreamOpen( void ) const throw();
532 
534  bool isStreamRunning( void ) const throw();
535 
537 
540  double getStreamTime( void );
541 
543 
546  void setStreamTime( double time );
547 
549 
557  long getStreamLatency( void );
558 
560 
565  unsigned int getStreamSampleRate( void );
566 
568  void showWarnings( bool value = true ) throw();
569 
570  protected:
571 
572  void openRtApi( RtAudio::Api api );
573  RtApi *rtapi_;
574 };
575 
576 // Operating system dependent thread functionality.
577 #if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) || defined(__WINDOWS_WASAPI__)
578 
579  #ifndef NOMINMAX
580  #define NOMINMAX
581  #endif
582  #include <windows.h>
583  #include <process.h>
584 
585  typedef uintptr_t ThreadHandle;
586  typedef CRITICAL_SECTION StreamMutex;
587 
588 #elif defined(__LINUX_ALSA__) || defined(__LINUX_PULSE__) || defined(__UNIX_JACK__) || defined(__LINUX_OSS__) || defined(__MACOSX_CORE__)
589  // Using pthread library for various flavors of unix.
590  #include <pthread.h>
591 
592  typedef pthread_t ThreadHandle;
593  typedef pthread_mutex_t StreamMutex;
594 
595 #else // Setup for "dummy" behavior
596 
597  #define __RTAUDIO_DUMMY__
598  typedef int ThreadHandle;
599  typedef int StreamMutex;
600 
601 #endif
602 
603 // This global structure type is used to pass callback information
604 // between the private RtAudio stream structure and global callback
605 // handling functions.
606 struct CallbackInfo {
607  void *object; // Used as a "this" pointer.
608  ThreadHandle thread;
609  void *callback;
610  void *userData;
611  void *errorCallback;
612  void *apiInfo; // void pointer for API specific callback information
613  bool isRunning;
614  bool doRealtime;
615  int priority;
616 
617  // Default constructor.
618  CallbackInfo()
619  :object(0), callback(0), userData(0), errorCallback(0), apiInfo(0), isRunning(false), doRealtime(false) {}
620 };
621 
622 // **************************************************************** //
623 //
624 // RtApi class declaration.
625 //
626 // Subclasses of RtApi contain all API- and OS-specific code necessary
627 // to fully implement the RtAudio API.
628 //
629 // Note that RtApi is an abstract base class and cannot be
630 // explicitly instantiated. The class RtAudio will create an
631 // instance of an RtApi subclass (RtApiOss, RtApiAlsa,
632 // RtApiJack, RtApiCore, RtApiDs, or RtApiAsio).
633 //
634 // **************************************************************** //
635 
636 #pragma pack(push, 1)
637 class S24 {
638 
639  protected:
640  unsigned char c3[3];
641 
642  public:
643  S24() {}
644 
645  S24& operator = ( const int& i ) {
646  c3[0] = (i & 0x000000ff);
647  c3[1] = (i & 0x0000ff00) >> 8;
648  c3[2] = (i & 0x00ff0000) >> 16;
649  return *this;
650  }
651 
652  S24( const S24& v ) { *this = v; }
653  S24( const double& d ) { *this = (int) d; }
654  S24( const float& f ) { *this = (int) f; }
655  S24( const signed short& s ) { *this = (int) s; }
656  S24( const char& c ) { *this = (int) c; }
657 
658  int asInt() {
659  int i = c3[0] | (c3[1] << 8) | (c3[2] << 16);
660  if (i & 0x800000) i |= ~0xffffff;
661  return i;
662  }
663 };
664 #pragma pack(pop)
665 
666 #if defined( HAVE_GETTIMEOFDAY )
667  #include <sys/time.h>
668 #endif
669 
670 #include <sstream>
671 
672 class RtApi
673 {
674 public:
675 
676  RtApi();
677  virtual ~RtApi();
678  virtual RtAudio::Api getCurrentApi( void ) = 0;
679  virtual unsigned int getDeviceCount( void ) = 0;
680  virtual RtAudio::DeviceInfo getDeviceInfo( unsigned int device ) = 0;
681  virtual unsigned int getDefaultInputDevice( void );
682  virtual unsigned int getDefaultOutputDevice( void );
683  void openStream( RtAudio::StreamParameters *outputParameters,
684  RtAudio::StreamParameters *inputParameters,
685  RtAudioFormat format, unsigned int sampleRate,
686  unsigned int *bufferFrames, RtAudioCallback callback,
687  void *userData, RtAudio::StreamOptions *options,
688  RtAudioErrorCallback errorCallback );
689  virtual void closeStream( void );
690  virtual void startStream( void ) = 0;
691  virtual void stopStream( void ) = 0;
692  virtual void abortStream( void ) = 0;
693  long getStreamLatency( void );
694  unsigned int getStreamSampleRate( void );
695  virtual double getStreamTime( void );
696  virtual void setStreamTime( double time );
697  bool isStreamOpen( void ) const { return stream_.state != STREAM_CLOSED; }
698  bool isStreamRunning( void ) const { return stream_.state == STREAM_RUNNING; }
699  void showWarnings( bool value ) { showWarnings_ = value; }
700 
701 
702 protected:
703 
704  static const unsigned int MAX_SAMPLE_RATES;
705  static const unsigned int SAMPLE_RATES[];
706 
707  enum { FAILURE, SUCCESS };
708 
709  enum StreamState {
710  STREAM_STOPPED,
711  STREAM_STOPPING,
712  STREAM_RUNNING,
713  STREAM_CLOSED = -50
714  };
715 
716  enum StreamMode {
717  OUTPUT,
718  INPUT,
719  DUPLEX,
720  UNINITIALIZED = -75
721  };
722 
723  // A protected structure used for buffer conversion.
724  struct ConvertInfo {
725  int channels;
726  int inJump, outJump;
727  RtAudioFormat inFormat, outFormat;
728  std::vector<int> inOffset;
729  std::vector<int> outOffset;
730  };
731 
732  // A protected structure for audio streams.
733  struct RtApiStream {
734  unsigned int device[2]; // Playback and record, respectively.
735  void *apiHandle; // void pointer for API specific stream handle information
736  StreamMode mode; // OUTPUT, INPUT, or DUPLEX.
737  StreamState state; // STOPPED, RUNNING, or CLOSED
738  char *userBuffer[2]; // Playback and record, respectively.
739  char *deviceBuffer;
740  bool doConvertBuffer[2]; // Playback and record, respectively.
741  bool userInterleaved;
742  bool deviceInterleaved[2]; // Playback and record, respectively.
743  bool doByteSwap[2]; // Playback and record, respectively.
744  unsigned int sampleRate;
745  unsigned int bufferSize;
746  unsigned int nBuffers;
747  unsigned int nUserChannels[2]; // Playback and record, respectively.
748  unsigned int nDeviceChannels[2]; // Playback and record channels, respectively.
749  unsigned int channelOffset[2]; // Playback and record, respectively.
750  unsigned long latency[2]; // Playback and record, respectively.
751  RtAudioFormat userFormat;
752  RtAudioFormat deviceFormat[2]; // Playback and record, respectively.
753  StreamMutex mutex;
754  CallbackInfo callbackInfo;
755  ConvertInfo convertInfo[2];
756  double streamTime; // Number of elapsed seconds since the stream started.
757 
758 #if defined(HAVE_GETTIMEOFDAY)
759  struct timeval lastTickTimestamp;
760 #endif
761 
762  RtApiStream()
763  :apiHandle(0), deviceBuffer(0) { device[0] = 11111; device[1] = 11111; }
764  };
765 
766  typedef S24 Int24;
767  typedef signed short Int16;
768  typedef signed int Int32;
769  typedef float Float32;
770  typedef double Float64;
771 
772  std::ostringstream errorStream_;
773  std::string errorText_;
774  bool showWarnings_;
775  RtApiStream stream_;
776  bool firstErrorOccurred_;
777 
785  virtual bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
786  unsigned int firstChannel, unsigned int sampleRate,
787  RtAudioFormat format, unsigned int *bufferSize,
788  RtAudio::StreamOptions *options );
789 
791  void tickStreamTime( void );
792 
794  void clearStreamInfo();
795 
800  void verifyStream( void );
801 
803  void error( RtAudioError::Type type );
804 
809  void convertBuffer( char *outBuffer, char *inBuffer, ConvertInfo &info );
810 
812  void byteSwapBuffer( char *buffer, unsigned int samples, RtAudioFormat format );
813 
815  unsigned int formatBytes( RtAudioFormat format );
816 
818  void setConvertInfo( StreamMode mode, unsigned int firstChannel );
819 };
820 
821 // **************************************************************** //
822 //
823 // Inline RtAudio definitions.
824 //
825 // **************************************************************** //
826 
827 inline RtAudio::Api RtAudio :: getCurrentApi( void ) throw() { return rtapi_->getCurrentApi(); }
828 inline unsigned int RtAudio :: getDeviceCount( void ) throw() { return rtapi_->getDeviceCount(); }
829 inline RtAudio::DeviceInfo RtAudio :: getDeviceInfo( unsigned int device ) { return rtapi_->getDeviceInfo( device ); }
830 inline unsigned int RtAudio :: getDefaultInputDevice( void ) throw() { return rtapi_->getDefaultInputDevice(); }
831 inline unsigned int RtAudio :: getDefaultOutputDevice( void ) throw() { return rtapi_->getDefaultOutputDevice(); }
832 inline void RtAudio :: closeStream( void ) throw() { return rtapi_->closeStream(); }
833 inline void RtAudio :: startStream( void ) { return rtapi_->startStream(); }
834 inline void RtAudio :: stopStream( void ) { return rtapi_->stopStream(); }
835 inline void RtAudio :: abortStream( void ) { return rtapi_->abortStream(); }
836 inline bool RtAudio :: isStreamOpen( void ) const throw() { return rtapi_->isStreamOpen(); }
837 inline bool RtAudio :: isStreamRunning( void ) const throw() { return rtapi_->isStreamRunning(); }
838 inline long RtAudio :: getStreamLatency( void ) { return rtapi_->getStreamLatency(); }
839 inline unsigned int RtAudio :: getStreamSampleRate( void ) { return rtapi_->getStreamSampleRate(); }
840 inline double RtAudio :: getStreamTime( void ) { return rtapi_->getStreamTime(); }
841 inline void RtAudio :: setStreamTime( double time ) { return rtapi_->setStreamTime( time ); }
842 inline void RtAudio :: showWarnings( bool value ) throw() { rtapi_->showWarnings( value ); }
843 
844 // RtApi Subclass prototypes.
845 
846 #if defined(__MACOSX_CORE__)
847 
848 #include <CoreAudio/AudioHardware.h>
849 
850 class RtApiCore: public RtApi
851 {
852 public:
853 
854  RtApiCore();
855  ~RtApiCore();
857  unsigned int getDeviceCount( void );
858  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
859  unsigned int getDefaultOutputDevice( void );
860  unsigned int getDefaultInputDevice( void );
861  void closeStream( void );
862  void startStream( void );
863  void stopStream( void );
864  void abortStream( void );
865  long getStreamLatency( void );
866 
867  // This function is intended for internal use only. It must be
868  // public because it is called by the internal callback handler,
869  // which is not a member of RtAudio. External use of this function
870  // will most likely produce highly undesireable results!
871  bool callbackEvent( AudioDeviceID deviceId,
872  const AudioBufferList *inBufferList,
873  const AudioBufferList *outBufferList );
874 
875  private:
876 
877  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
878  unsigned int firstChannel, unsigned int sampleRate,
879  RtAudioFormat format, unsigned int *bufferSize,
880  RtAudio::StreamOptions *options );
881  static const char* getErrorCode( OSStatus code );
882 };
883 
884 #endif
885 
886 #if defined(__UNIX_JACK__)
887 
888 class RtApiJack: public RtApi
889 {
890 public:
891 
892  RtApiJack();
893  ~RtApiJack();
894  RtAudio::Api getCurrentApi( void ) { return RtAudio::UNIX_JACK; }
895  unsigned int getDeviceCount( void );
896  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
897  void closeStream( void );
898  void startStream( void );
899  void stopStream( void );
900  void abortStream( void );
901  long getStreamLatency( void );
902 
903  // This function is intended for internal use only. It must be
904  // public because it is called by the internal callback handler,
905  // which is not a member of RtAudio. External use of this function
906  // will most likely produce highly undesireable results!
907  bool callbackEvent( unsigned long nframes );
908 
909  private:
910 
911  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
912  unsigned int firstChannel, unsigned int sampleRate,
913  RtAudioFormat format, unsigned int *bufferSize,
914  RtAudio::StreamOptions *options );
915 };
916 
917 #endif
918 
919 #if defined(__WINDOWS_ASIO__)
920 
921 class RtApiAsio: public RtApi
922 {
923 public:
924 
925  RtApiAsio();
926  ~RtApiAsio();
928  unsigned int getDeviceCount( void );
929  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
930  void closeStream( void );
931  void startStream( void );
932  void stopStream( void );
933  void abortStream( void );
934  long getStreamLatency( void );
935 
936  // This function is intended for internal use only. It must be
937  // public because it is called by the internal callback handler,
938  // which is not a member of RtAudio. External use of this function
939  // will most likely produce highly undesireable results!
940  bool callbackEvent( long bufferIndex );
941 
942  private:
943 
944  std::vector<RtAudio::DeviceInfo> devices_;
945  void saveDeviceInfo( void );
946  bool coInitialized_;
947  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
948  unsigned int firstChannel, unsigned int sampleRate,
949  RtAudioFormat format, unsigned int *bufferSize,
950  RtAudio::StreamOptions *options );
951 };
952 
953 #endif
954 
955 #if defined(__WINDOWS_DS__)
956 
957 class RtApiDs: public RtApi
958 {
959 public:
960 
961  RtApiDs();
962  ~RtApiDs();
964  unsigned int getDeviceCount( void );
965  unsigned int getDefaultOutputDevice( void );
966  unsigned int getDefaultInputDevice( void );
967  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
968  void closeStream( void );
969  void startStream( void );
970  void stopStream( void );
971  void abortStream( void );
972  long getStreamLatency( void );
973 
974  // This function is intended for internal use only. It must be
975  // public because it is called by the internal callback handler,
976  // which is not a member of RtAudio. External use of this function
977  // will most likely produce highly undesireable results!
978  void callbackEvent( void );
979 
980  private:
981 
982  bool coInitialized_;
983  bool buffersRolling;
984  long duplexPrerollBytes;
985  std::vector<struct DsDevice> dsDevices;
986  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
987  unsigned int firstChannel, unsigned int sampleRate,
988  RtAudioFormat format, unsigned int *bufferSize,
989  RtAudio::StreamOptions *options );
990 };
991 
992 #endif
993 
994 #if defined(__WINDOWS_WASAPI__)
995 
996 struct IMMDeviceEnumerator;
997 
998 class RtApiWasapi : public RtApi
999 {
1000 public:
1001  RtApiWasapi();
1002  ~RtApiWasapi();
1003 
1005  unsigned int getDeviceCount( void );
1006  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
1007  unsigned int getDefaultOutputDevice( void );
1008  unsigned int getDefaultInputDevice( void );
1009  void closeStream( void );
1010  void startStream( void );
1011  void stopStream( void );
1012  void abortStream( void );
1013 
1014 private:
1015  bool coInitialized_;
1016  IMMDeviceEnumerator* deviceEnumerator_;
1017 
1018  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
1019  unsigned int firstChannel, unsigned int sampleRate,
1020  RtAudioFormat format, unsigned int* bufferSize,
1021  RtAudio::StreamOptions* options );
1022 
1023  static DWORD WINAPI runWasapiThread( void* wasapiPtr );
1024  static DWORD WINAPI stopWasapiThread( void* wasapiPtr );
1025  static DWORD WINAPI abortWasapiThread( void* wasapiPtr );
1026  void wasapiThread();
1027 };
1028 
1029 #endif
1030 
1031 #if defined(__LINUX_ALSA__)
1032 
1033 class RtApiAlsa: public RtApi
1034 {
1035 public:
1036 
1037  RtApiAlsa();
1038  ~RtApiAlsa();
1040  unsigned int getDeviceCount( void );
1041  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
1042  void closeStream( void );
1043  void startStream( void );
1044  void stopStream( void );
1045  void abortStream( void );
1046 
1047  // This function is intended for internal use only. It must be
1048  // public because it is called by the internal callback handler,
1049  // which is not a member of RtAudio. External use of this function
1050  // will most likely produce highly undesireable results!
1051  void callbackEvent( void );
1052 
1053  private:
1054 
1055  std::vector<RtAudio::DeviceInfo> devices_;
1056  void saveDeviceInfo( void );
1057  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
1058  unsigned int firstChannel, unsigned int sampleRate,
1059  RtAudioFormat format, unsigned int *bufferSize,
1060  RtAudio::StreamOptions *options );
1061 };
1062 
1063 #endif
1064 
1065 #if defined(__LINUX_PULSE__)
1066 
1067 class RtApiPulse: public RtApi
1068 {
1069 public:
1070  ~RtApiPulse();
1072  unsigned int getDeviceCount( void );
1073  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
1074  void closeStream( void );
1075  void startStream( void );
1076  void stopStream( void );
1077  void abortStream( void );
1078 
1079  // This function is intended for internal use only. It must be
1080  // public because it is called by the internal callback handler,
1081  // which is not a member of RtAudio. External use of this function
1082  // will most likely produce highly undesireable results!
1083  void callbackEvent( void );
1084 
1085  private:
1086 
1087  std::vector<RtAudio::DeviceInfo> devices_;
1088  void saveDeviceInfo( void );
1089  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
1090  unsigned int firstChannel, unsigned int sampleRate,
1091  RtAudioFormat format, unsigned int *bufferSize,
1092  RtAudio::StreamOptions *options );
1093 };
1094 
1095 #endif
1096 
1097 #if defined(__LINUX_OSS__)
1098 
1099 class RtApiOss: public RtApi
1100 {
1101 public:
1102 
1103  RtApiOss();
1104  ~RtApiOss();
1106  unsigned int getDeviceCount( void );
1107  RtAudio::DeviceInfo getDeviceInfo( unsigned int device );
1108  void closeStream( void );
1109  void startStream( void );
1110  void stopStream( void );
1111  void abortStream( void );
1112 
1113  // This function is intended for internal use only. It must be
1114  // public because it is called by the internal callback handler,
1115  // which is not a member of RtAudio. External use of this function
1116  // will most likely produce highly undesireable results!
1117  void callbackEvent( void );
1118 
1119  private:
1120 
1121  bool probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
1122  unsigned int firstChannel, unsigned int sampleRate,
1123  RtAudioFormat format, unsigned int *bufferSize,
1124  RtAudio::StreamOptions *options );
1125 };
1126 
1127 #endif
1128 
1129 #if defined(__RTAUDIO_DUMMY__)
1130 
1131 class RtApiDummy: public RtApi
1132 {
1133 public:
1134 
1135  RtApiDummy() { errorText_ = "RtApiDummy: This class provides no functionality."; error( RtAudioError::WARNING ); }
1137  unsigned int getDeviceCount( void ) { return 0; }
1138  RtAudio::DeviceInfo getDeviceInfo( unsigned int /*device*/ ) { RtAudio::DeviceInfo info; return info; }
1139  void closeStream( void ) {}
1140  void startStream( void ) {}
1141  void stopStream( void ) {}
1142  void abortStream( void ) {}
1143 
1144  private:
1145 
1146  bool probeDeviceOpen( unsigned int /*device*/, StreamMode /*mode*/, unsigned int /*channels*/,
1147  unsigned int /*firstChannel*/, unsigned int /*sampleRate*/,
1148  RtAudioFormat /*format*/, unsigned int * /*bufferSize*/,
1149  RtAudio::StreamOptions * /*options*/ ) { return false; }
1150 };
1151 
1152 #endif
1153 
1154 #endif
1155 
1156 // Indentation settings for Vim and Emacs
1157 //
1158 // Local Variables:
1159 // c-basic-offset: 2
1160 // indent-tabs-mode: nil
1161 // End:
1162 //
1163 // vim: et sts=2 sw=2

The Synthesis ToolKit in C++ (STK)
©1995--2016 Perry R. Cook and Gary P. Scavone. All Rights Reserved.