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

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