53 static const std::string VERSION(
"4.0.12" );
183 unsigned int nFrames,
333 static void getCompiledApi( std::vector<RtAudio::Api> &apis )
throw();
438 RtAudio::StreamParameters *inputParameters,
518 #if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)
522 typedef unsigned long ThreadHandle;
523 typedef CRITICAL_SECTION StreamMutex;
525 #elif defined(__LINUX_ALSA__) || defined(__LINUX_PULSE__) || defined(__UNIX_JACK__) || defined(__LINUX_OSS__) || defined(__MACOSX_CORE__)
529 typedef pthread_t ThreadHandle;
530 typedef pthread_mutex_t StreamMutex;
532 #else // Setup for "dummy" behavior
534 #define __RTAUDIO_DUMMY__
535 typedef int ThreadHandle;
536 typedef int StreamMutex;
543 struct CallbackInfo {
556 :object(0), callback(0), userData(0), errorCallback(0), apiInfo(0), isRunning(false), doRealtime(false) {}
573 #pragma pack(push, 1)
582 S24& operator = (
const int& i ) {
583 c3[0] = (i & 0x000000ff);
584 c3[1] = (i & 0x0000ff00) >> 8;
585 c3[2] = (i & 0x00ff0000) >> 16;
589 S24(
const S24& v ) { *
this = v; }
590 S24(
const double& d ) { *
this = (int) d; }
591 S24(
const float& f ) { *
this = (int) f; }
592 S24(
const signed short& s ) { *
this = (int) s; }
593 S24(
const char& c ) { *
this = (int) c; }
596 int i = c3[0] | (c3[1] << 8) | (c3[2] << 16);
597 if (i & 0x800000) i |= ~0xffffff;
603 #if defined( HAVE_GETTIMEOFDAY )
604 #include <sys/time.h>
633 bool isStreamOpen(
void )
const {
return stream_.state != STREAM_CLOSED; }
634 bool isStreamRunning(
void )
const {
return stream_.state == STREAM_RUNNING; }
635 void showWarnings(
bool value ) { showWarnings_ = value; }
640 static const unsigned int MAX_SAMPLE_RATES;
641 static const unsigned int SAMPLE_RATES[];
643 enum { FAILURE, SUCCESS };
664 std::vector<int> inOffset;
665 std::vector<int> outOffset;
670 unsigned int device[2];
676 bool doConvertBuffer[2];
677 bool userInterleaved;
678 bool deviceInterleaved[2];
680 unsigned int sampleRate;
681 unsigned int bufferSize;
682 unsigned int nBuffers;
683 unsigned int nUserChannels[2];
684 unsigned int nDeviceChannels[2];
685 unsigned int channelOffset[2];
686 unsigned long latency[2];
690 CallbackInfo callbackInfo;
691 ConvertInfo convertInfo[2];
694 #if defined(HAVE_GETTIMEOFDAY)
695 struct timeval lastTickTimestamp;
699 :apiHandle(0), deviceBuffer(0) { device[0] = 11111; device[1] = 11111; }
703 typedef signed short Int16;
704 typedef signed int Int32;
705 typedef float Float32;
706 typedef double Float64;
708 std::ostringstream errorStream_;
709 std::string errorText_;
720 virtual bool probeDeviceOpen(
unsigned int device, StreamMode mode,
unsigned int channels,
721 unsigned int firstChannel,
unsigned int sampleRate,
726 void tickStreamTime(
void );
729 void clearStreamInfo();
735 void verifyStream(
void );
744 void convertBuffer(
char *outBuffer,
char *inBuffer, ConvertInfo &info );
747 void byteSwapBuffer(
char *buffer,
unsigned int samples,
RtAudioFormat format );
753 void setConvertInfo( StreamMode mode,
unsigned int firstChannel );
780 #if defined(__MACOSX_CORE__)
782 #include <CoreAudio/AudioHardware.h>
784 class RtApiCore:
public RtApi
805 bool callbackEvent( AudioDeviceID deviceId,
806 const AudioBufferList *inBufferList,
807 const AudioBufferList *outBufferList );
811 bool probeDeviceOpen(
unsigned int device, StreamMode mode,
unsigned int channels,
812 unsigned int firstChannel,
unsigned int sampleRate,
815 static const char* getErrorCode( OSStatus code );
820 #if defined(__UNIX_JACK__)
822 class RtApiJack:
public RtApi
841 bool callbackEvent(
unsigned long nframes );
845 bool probeDeviceOpen(
unsigned int device, StreamMode mode,
unsigned int channels,
846 unsigned int firstChannel,
unsigned int sampleRate,
853 #if defined(__WINDOWS_ASIO__)
855 class RtApiAsio:
public RtApi
874 bool callbackEvent(
long bufferIndex );
878 std::vector<RtAudio::DeviceInfo> devices_;
879 void saveDeviceInfo(
void );
881 bool probeDeviceOpen(
unsigned int device, StreamMode mode,
unsigned int channels,
882 unsigned int firstChannel,
unsigned int sampleRate,
889 #if defined(__WINDOWS_DS__)
891 class RtApiDs:
public RtApi
912 void callbackEvent(
void );
918 long duplexPrerollBytes;
919 std::vector<struct DsDevice> dsDevices;
920 bool probeDeviceOpen(
unsigned int device, StreamMode mode,
unsigned int channels,
921 unsigned int firstChannel,
unsigned int sampleRate,
928 #if defined(__LINUX_ALSA__)
930 class RtApiAlsa:
public RtApi
948 void callbackEvent(
void );
952 std::vector<RtAudio::DeviceInfo> devices_;
953 void saveDeviceInfo(
void );
954 bool probeDeviceOpen(
unsigned int device, StreamMode mode,
unsigned int channels,
955 unsigned int firstChannel,
unsigned int sampleRate,
962 #if defined(__LINUX_PULSE__)
964 class RtApiPulse:
public RtApi
980 void callbackEvent(
void );
984 std::vector<RtAudio::DeviceInfo> devices_;
985 void saveDeviceInfo(
void );
986 bool probeDeviceOpen(
unsigned int device, StreamMode mode,
unsigned int channels,
987 unsigned int firstChannel,
unsigned int sampleRate,
994 #if defined(__LINUX_OSS__)
996 class RtApiOss:
public RtApi
1014 void callbackEvent(
void );
1018 bool probeDeviceOpen(
unsigned int device, StreamMode mode,
unsigned int channels,
1019 unsigned int firstChannel,
unsigned int sampleRate,
1026 #if defined(__RTAUDIO_DUMMY__)
1028 class RtApiDummy:
public RtApi
1032 RtApiDummy() { errorText_ =
"RtApiDummy: This class provides no functionality."; error(
RtError::WARNING ); }
1043 bool probeDeviceOpen(
unsigned int , StreamMode ,
unsigned int ,
1044 unsigned int ,
unsigned int ,