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 {
211 UNSPECIFIED,
212 LINUX_ALSA,
213 LINUX_PULSE,
214 LINUX_OSS,
215 UNIX_JACK,
216 MACOSX_CORE,
217 WINDOWS_ASIO,
218 WINDOWS_DS,
219 RTAUDIO_DUMMY
220 };
221
223 struct DeviceInfo {
224 bool probed;
225 std::string name;
226 unsigned int outputChannels;
227 unsigned int inputChannels;
228 unsigned int duplexChannels;
229 bool isDefaultOutput;
230 bool isDefaultInput;
231 std::vector<unsigned int> sampleRates;
232 RtAudioFormat nativeFormats;
234 // Default constructor.
235 DeviceInfo()
236 :probed(false), outputChannels(0), inputChannels(0), duplexChannels(0),
237 isDefaultOutput(false), isDefaultInput(false), nativeFormats(0) {}
238 };
239
241 struct StreamParameters {
242 unsigned int deviceId;
243 unsigned int nChannels;
244 unsigned int firstChannel;
246 // Default constructor.
247 StreamParameters()
248 : deviceId(0), nChannels(0), firstChannel(0) {}
249 };
250
252
308 struct StreamOptions {
309 RtAudioStreamFlags flags;
310 unsigned int numberOfBuffers;
311 std::string streamName;
312 int priority;
314 // Default constructor.
315 StreamOptions()
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 );
504 RtApi *rtapi_;
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.
535 ThreadHandle thread;
536 void *callback;
537 void *userData;
538 void *apiInfo; // void pointer for API specific callback information
539 bool isRunning;
540
541 // Default constructor.
542 CallbackInfo()
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 {
602 STREAM_STOPPED,
603 STREAM_STOPPING,
604 STREAM_RUNNING,
605 STREAM_CLOSED = -50
606 };
607
608 enum StreamMode {
609 OUTPUT,
610 INPUT,
611 DUPLEX,
612 UNINITIALIZED = -75
613 };
614
615 // A protected structure used for buffer conversion.
616 struct ConvertInfo {
617 int channels;
618 int inJump, outJump;
619 RtAudioFormat inFormat, outFormat;
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.
631 char *deviceBuffer;
632 bool doConvertBuffer[2]; // Playback and record, respectively.
633 bool userInterleaved;
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.
643 RtAudioFormat userFormat;
644 RtAudioFormat deviceFormat[2]; // Playback and record, respectively.
645 StreamMutex mutex;
646 CallbackInfo callbackInfo;
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
654 RtApiStream()
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_;
665 bool showWarnings_;
666 RtApiStream stream_;
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();
816 RtAudio::Api getCurrentApi( void ) { return RtAudio::WINDOWS_ASIO; };
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();
890 RtAudio::Api getCurrentApi() { return RtAudio::LINUX_ALSA; };
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();
922 RtAudio::Api getCurrentApi() { return RtAudio::LINUX_PULSE; };
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();
956 RtAudio::Api getCurrentApi() { return RtAudio::LINUX_OSS; };
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 ); };
987 RtAudio::Api getCurrentApi( void ) { return RtAudio::RTAUDIO_DUMMY; };
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
RtAudio::StreamParameters::firstChannel
unsigned int firstChannel
Definition: RtAudio.h:244
RtApi::ConvertInfo::inOffset
std::vector< int > inOffset
Definition: RtAudio.h:620
RtAudio::stopStream
void stopStream(void)
Stop a stream, allowing any samples remaining in the output queue to be played.
Definition: RtAudio.h:724
RtApi::getDefaultOutputDevice
virtual unsigned int getDefaultOutputDevice(void)
Definition: RtAudio.cpp:306
RtAudio::LINUX_PULSE
Definition: RtAudio.h:213
RtError.h
RtApi::RtApiStream::userInterleaved
bool userInterleaved
Definition: RtAudio.h:633
RtAudio::DeviceInfo::name
std::string name
Definition: RtAudio.h:225
RtApi::stopStream
virtual void stopStream(void)=0
RtApi::ConvertInfo::outJump
int outJump
Definition: RtAudio.h:618
CallbackInfo::apiInfo
void * apiInfo
Definition: RtAudio.h:538
CallbackInfo::CallbackInfo
CallbackInfo()
Definition: RtAudio.h:542
RtAudio::DeviceInfo::sampleRates
std::vector< unsigned int > sampleRates
Definition: RtAudio.h:231
RtApi::RtApiStream::nBuffers
unsigned int nBuffers
Definition: RtAudio.h:638
RtAudio::RtAudio
RtAudio(RtAudio::Api api=UNSPECIFIED)
The class constructor.
Definition: RtAudio.cpp:150
RtAudio::openStream
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
RtAudioStreamFlags
unsigned int RtAudioStreamFlags
RtAudio stream option flags.
Definition: RtAudio.h:122
RtAudio::RTAUDIO_DUMMY
Definition: RtAudio.h:219
RtApi::isStreamRunning
bool isStreamRunning(void) const
Definition: RtAudio.h:590
CallbackInfo::callback
void * callback
Definition: RtAudio.h:536
RtApi::RtApiStream::state
StreamState state
Definition: RtAudio.h:629
RtAudio
Realtime audio i/o C++ classes.
Definition: RtAudio.h:205
RtAudio::DeviceInfo::inputChannels
unsigned int inputChannels
Definition: RtAudio.h:227
RtApiDummy::startStream
void startStream(void)
Definition: RtAudio.h:991
RtAudio::DeviceInfo::duplexChannels
unsigned int duplexChannels
Definition: RtAudio.h:228
RtAudio::DeviceInfo::isDefaultOutput
bool isDefaultOutput
Definition: RtAudio.h:229
RtApi::getDeviceCount
virtual unsigned int getDeviceCount(void)=0
RtApi::RtApiStream::apiHandle
void * apiHandle
Definition: RtAudio.h:627
RtAudio::showWarnings
void showWarnings(bool value=true)
Specify whether warning messages should be printed to stderr.
Definition: RtAudio.h:731
RtAudio::isStreamRunning
bool isStreamRunning(void) const
Returns true if the stream is running and false if it is stopped or not open.
Definition: RtAudio.h:727
RtAudioFormat
unsigned long RtAudioFormat
RtAudio data format type.
Definition: RtAudio.h:72
CallbackInfo::thread
ThreadHandle thread
Definition: RtAudio.h:535
RtAudio::WINDOWS_DS
Definition: RtAudio.h:218
RtAudioCallback
int(* RtAudioCallback)(void *outputBuffer, void *inputBuffer, unsigned int nFrames, double streamTime, RtAudioStreamStatus status, void *userData)
RtAudio callback function prototype.
Definition: RtAudio.h:183
RtApiDummy::abortStream
void abortStream(void)
Definition: RtAudio.h:993
CallbackInfo::isRunning
bool isRunning
Definition: RtAudio.h:539
RtAudio::openRtApi
void openRtApi(RtAudio::Api api)
Definition: RtAudio.cpp:110
RtApi::isStreamOpen
bool isStreamOpen(void) const
Definition: RtAudio.h:589
RtError::WARNING
Definition: RtError.h:24
RtAudio::getStreamSampleRate
unsigned int getStreamSampleRate(void)
Returns actual sample rate in use by the stream.
Definition: RtAudio.h:729
RtApi::STREAM_STOPPED
Definition: RtAudio.h:602
RtApi::Int16
signed short Int16
Definition: RtAudio.h:658
RtAudio::~RtAudio
~RtAudio()
The destructor.
Definition: RtAudio.cpp:182
RtAudio::StreamParameters
The structure for specifying input or ouput stream parameters.
Definition: RtAudio.h:241
RtAudio::getDeviceInfo
RtAudio::DeviceInfo getDeviceInfo(unsigned int device)
Return an RtAudio::DeviceInfo structure for a specified device number.
Definition: RtAudio.h:719
RtAudio::DeviceInfo::outputChannels
unsigned int outputChannels
Definition: RtAudio.h:226
RtApi::RtApiStream::sampleRate
unsigned int sampleRate
Definition: RtAudio.h:636
RtApi::RtApiStream::streamTime
double streamTime
Definition: RtAudio.h:648
RtAudio::StreamParameters::StreamParameters
StreamParameters()
Definition: RtAudio.h:247
RtApiDummy::RtApiDummy
RtApiDummy()
Definition: RtAudio.h:986
RtApi::getStreamLatency
long getStreamLatency(void)
Definition: RtAudio.cpp:340
RtApi::ConvertInfo
Definition: RtAudio.h:616
RtApi::errorStream_
std::ostringstream errorStream_
Definition: RtAudio.h:663
RtApi::stream_
RtApiStream stream_
Definition: RtAudio.h:666
RtApi::RtApiStream::bufferSize
unsigned int bufferSize
Definition: RtAudio.h:637
RtApi::Int32
signed int Int32
Definition: RtAudio.h:659
RtApi::abortStream
virtual void abortStream(void)=0
RtAudio::StreamParameters::deviceId
unsigned int deviceId
Definition: RtAudio.h:242
StreamMutex
int StreamMutex
Definition: RtAudio.h:526
RtApi::ConvertInfo::outFormat
RtAudioFormat outFormat
Definition: RtAudio.h:619
CallbackInfo
Definition: RtAudio.h:533
RtApiDummy::stopStream
void stopStream(void)
Definition: RtAudio.h:992
RtApi::getStreamTime
virtual double getStreamTime(void)
Definition: RtAudio.cpp:353
RtAudio::getCompiledApi
static void getCompiledApi(std::vector< RtAudio::Api > &apis)
A static function to determine the available compiled audio APIs.
Definition: RtAudio.cpp:78
RtApi::RtApiStream::userFormat
RtAudioFormat userFormat
Definition: RtAudio.h:643
RtApi::getDeviceInfo
virtual RtAudio::DeviceInfo getDeviceInfo(unsigned int device)=0
RtAudio::DeviceInfo::DeviceInfo
DeviceInfo()
Definition: RtAudio.h:235
RtAudio::StreamOptions::streamName
std::string streamName
Definition: RtAudio.h:311
RtAudioStreamStatus
unsigned int RtAudioStreamStatus
RtAudio stream status (over- or underflow) flags.
Definition: RtAudio.h:140
RtAudio::closeStream
void closeStream(void)
A function that closes a stream and frees any associated stream memory.
Definition: RtAudio.h:722
RtApi::RtApiStream::RtApiStream
RtApiStream()
Definition: RtAudio.h:654
RtError::Type
Type
Defined RtError types.
Definition: RtError.h:23
RtApi::closeStream
virtual void closeStream(void)
Definition: RtAudio.cpp:312
CallbackInfo::object
void * object
Definition: RtAudio.h:534
RtAudio::LINUX_ALSA
Definition: RtAudio.h:212
RtAudio::Api
Api
Audio API specifier arguments.
Definition: RtAudio.h:210
RtApi::Float32
float Float32
Definition: RtAudio.h:660
RtAudio::getStreamTime
double getStreamTime(void)
Returns the number of elapsed seconds since the stream was started.
Definition: RtAudio.h:730
RtApiDummy::getCurrentApi
RtAudio::Api getCurrentApi(void)
Definition: RtAudio.h:987
RtAudio::rtapi_
RtApi * rtapi_
Definition: RtAudio.h:504
RtApi::showWarnings_
bool showWarnings_
Definition: RtAudio.h:665
RtAudio::getDefaultInputDevice
unsigned int getDefaultInputDevice(void)
A function that returns the index of the default input device.
Definition: RtAudio.h:720
RtApi::ConvertInfo::channels
int channels
Definition: RtAudio.h:617
RtAudio::isStreamOpen
bool isStreamOpen(void) const
Returns true if a stream is open and false if not.
Definition: RtAudio.h:726
RtApi::STREAM_RUNNING
Definition: RtAudio.h:604
RtAudio::DeviceInfo::probed
bool probed
Definition: RtAudio.h:224
RtAudio::UNIX_JACK
Definition: RtAudio.h:215
RtApi::INPUT
Definition: RtAudio.h:610
RtAudio::StreamOptions::flags
RtAudioStreamFlags flags
Definition: RtAudio.h:309
RtAudio::StreamOptions::priority
int priority
Definition: RtAudio.h:312
RtApi::Float64
double Float64
Definition: RtAudio.h:661
RtApi::RtApiStream::callbackInfo
CallbackInfo callbackInfo
Definition: RtAudio.h:646
RtAudio::abortStream
void abortStream(void)
Stop a stream, discarding any samples remaining in the input/output queue.
Definition: RtAudio.h:725
ThreadHandle
int ThreadHandle
Definition: RtAudio.h:525
RtAudio::startStream
void startStream(void)
A function that starts a stream.
Definition: RtAudio.h:723
RtAudio::getDeviceCount
unsigned int getDeviceCount(void)
A public function that queries for the number of audio devices available.
Definition: RtAudio.h:718
RtAudio::DeviceInfo::nativeFormats
RtAudioFormat nativeFormats
Definition: RtAudio.h:232
RtApi::RtApiStream::mutex
StreamMutex mutex
Definition: RtAudio.h:645
RtAudio::DeviceInfo
The public device information structure for returning queried values.
Definition: RtAudio.h:223
RtApi::RtApiStream
Definition: RtAudio.h:625
RtAudio::LINUX_OSS
Definition: RtAudio.h:214
RtAudio::StreamOptions::StreamOptions
StreamOptions()
Definition: RtAudio.h:315
RtAudio::StreamOptions
The structure for specifying stream options.
Definition: RtAudio.h:308
RtApi
Definition: RtAudio.h:566
RtApi::getDefaultInputDevice
virtual unsigned int getDefaultInputDevice(void)
Definition: RtAudio.cpp:300
RtApi::StreamState
StreamState
Definition: RtAudio.h:601
RtApi::showWarnings
void showWarnings(bool value)
Definition: RtAudio.h:591
RtAudio::WINDOWS_ASIO
Definition: RtAudio.h:217
RtApi::startStream
virtual void startStream(void)=0
RtAudio::DeviceInfo::isDefaultInput
bool isDefaultInput
Definition: RtAudio.h:230
RtAudio::StreamParameters::nChannels
unsigned int nChannels
Definition: RtAudio.h:243
RtApi::RtApiStream::mode
StreamMode mode
Definition: RtAudio.h:628
RtApi::ConvertInfo::outOffset
std::vector< int > outOffset
Definition: RtAudio.h:621
RtApi::StreamMode
StreamMode
Definition: RtAudio.h:608
RtApiDummy::closeStream
void closeStream(void)
Definition: RtAudio.h:990
RtApi::getCurrentApi
virtual RtAudio::Api getCurrentApi(void)=0
RtApi::STREAM_STOPPING
Definition: RtAudio.h:603
RtApiDummy
Definition: RtAudio.h:982
RtAudio::MACOSX_CORE
Definition: RtAudio.h:216
RtApi::DUPLEX
Definition: RtAudio.h:611
RtAudio::UNSPECIFIED
Definition: RtAudio.h:211
RtAudio::getCurrentApi
RtAudio::Api getCurrentApi(void)
Returns the audio API specifier for the current instance of RtAudio.
Definition: RtAudio.h:717
RtApiDummy::getDeviceInfo
RtAudio::DeviceInfo getDeviceInfo(unsigned int device)
Definition: RtAudio.h:989
RtApi::OUTPUT
Definition: RtAudio.h:609
RtApi::errorText_
std::string errorText_
Definition: RtAudio.h:664
RtAudio::StreamOptions::numberOfBuffers
unsigned int numberOfBuffers
Definition: RtAudio.h:310
RtAudio::getStreamLatency
long getStreamLatency(void)
Returns the internal stream latency in sample frames.
Definition: RtAudio.h:728
RtApi::RtApiStream::deviceBuffer
char * deviceBuffer
Definition: RtAudio.h:631
RtApi::getStreamSampleRate
unsigned int getStreamSampleRate(void)
Definition: RtAudio.cpp:376
RtApiDummy::getDeviceCount
unsigned int getDeviceCount(void)
Definition: RtAudio.h:988
CallbackInfo::userData
void * userData
Definition: RtAudio.h:537
RtAudio::getDefaultOutputDevice
unsigned int getDefaultOutputDevice(void)
A function that returns the index of the default output device.
Definition: RtAudio.h:721