Browse Source

Removed RtAudioError class and created a new enum for error types. Only implemented for RtApiCore and RtApiDummy, not rtaudio_c.

noexceptions
Gary Scavone 5 years ago
parent
commit
ba23fd33d7
5 changed files with 174 additions and 204 deletions
  1. +2
    -2
      Makefile.am
  2. +64
    -92
      RtAudio.cpp
  3. +106
    -108
      RtAudio.h
  4. +1
    -1
      configure.ac
  5. +1
    -1
      tests/playsaw.cpp

+ 2
- 2
Makefile.am View File

@@ -9,8 +9,8 @@ lib_LTLIBRARIES = %D%/librtaudio.la
%C%_librtaudio_la_CXXFLAGS = -DRTAUDIO_EXPORT %C%_librtaudio_la_CXXFLAGS = -DRTAUDIO_EXPORT
%C%_librtaudio_la_LDFLAGS = -no-undefined -export-dynamic -version-info @SO_VERSION@ %C%_librtaudio_la_LDFLAGS = -no-undefined -export-dynamic -version-info @SO_VERSION@
%C%_librtaudio_la_SOURCES = \ %C%_librtaudio_la_SOURCES = \
%D%/RtAudio.cpp \
%D%/rtaudio_c.cpp
%D%/RtAudio.cpp
# %D%/rtaudio_c.cpp


if ASIO if ASIO
%C%_librtaudio_la_SOURCES += \ %C%_librtaudio_la_SOURCES += \


+ 64
- 92
RtAudio.cpp View File

@@ -39,7 +39,7 @@
*/ */
/************************************************************************/ /************************************************************************/


// RtAudio: Version 5.1.0
// RtAudio: Version 6.0.0beta1


#include "RtAudio.h" #include "RtAudio.h"
#include <iostream> #include <iostream>
@@ -264,9 +264,9 @@ RtAudio :: RtAudio( RtAudio::Api api )
// It should not be possible to get here because the preprocessor // It should not be possible to get here because the preprocessor
// definition __RTAUDIO_DUMMY__ is automatically defined in RtAudio.h // definition __RTAUDIO_DUMMY__ is automatically defined in RtAudio.h
// if no API-specific definitions are passed to the compiler. But just // if no API-specific definitions are passed to the compiler. But just
// in case something weird happens, we'll throw an error.
std::string errorText = "\nRtAudio: no compiled API support found ... critical error!!\n\n";
throw( RtAudioError( errorText, RtAudioError::UNSPECIFIED ) );
// in case something weird happens, issue an error message and abort.
std::cerr << "\nRtAudio: no compiled API support found ... critical error!\n" << std::endl;
abort();
} }


RtAudio :: ~RtAudio() RtAudio :: ~RtAudio()
@@ -275,17 +275,16 @@ RtAudio :: ~RtAudio()
delete rtapi_; delete rtapi_;
} }


//void RtAudio :: openStream( RtAudio::StreamParameters *outputParameters,
RtAudioError::Type RtAudio :: openStream( RtAudio::StreamParameters *outputParameters,
RtAudioErrorType RtAudio :: openStream( RtAudio::StreamParameters *outputParameters,
RtAudio::StreamParameters *inputParameters, RtAudio::StreamParameters *inputParameters,
RtAudioFormat format, unsigned int sampleRate, RtAudioFormat format, unsigned int sampleRate,
unsigned int *bufferFrames, unsigned int *bufferFrames,
RtAudioCallback callback, void *userData, RtAudioCallback callback, void *userData,
RtAudio::StreamOptions *options ) //, RtAudioErrorCallback errorCallback )
RtAudio::StreamOptions *options )
{ {
return rtapi_->openStream( outputParameters, inputParameters, format, return rtapi_->openStream( outputParameters, inputParameters, format,
sampleRate, bufferFrames, callback, sampleRate, bufferFrames, callback,
userData, options ); //, errorCallback );
userData, options );
} }


// *************************************************** // // *************************************************** //
@@ -301,7 +300,6 @@ RtApi :: RtApi()
MUTEX_INITIALIZE( &stream_.mutex ); MUTEX_INITIALIZE( &stream_.mutex );
errorCallback_ = 0; errorCallback_ = 0;
showWarnings_ = true; showWarnings_ = true;
//firstErrorOccurred_ = false;
} }


RtApi :: ~RtApi() RtApi :: ~RtApi()
@@ -309,19 +307,16 @@ RtApi :: ~RtApi()
MUTEX_DESTROY( &stream_.mutex ); MUTEX_DESTROY( &stream_.mutex );
} }


//void RtApi :: openStream( RtAudio::StreamParameters *oParams,
RtAudioError::Type RtApi :: openStream( RtAudio::StreamParameters *oParams,
RtAudioErrorType RtApi :: openStream( RtAudio::StreamParameters *oParams,
RtAudio::StreamParameters *iParams, RtAudio::StreamParameters *iParams,
RtAudioFormat format, unsigned int sampleRate, RtAudioFormat format, unsigned int sampleRate,
unsigned int *bufferFrames, unsigned int *bufferFrames,
RtAudioCallback callback, void *userData, RtAudioCallback callback, void *userData,
RtAudio::StreamOptions *options ) //, RtAudioErrorCallback errorCallback )
RtAudio::StreamOptions *options )
{ {
//RtAudioError::Type type = RtAudioError::NO_ERROR;
if ( stream_.state != STREAM_CLOSED ) { if ( stream_.state != STREAM_CLOSED ) {
//type = RtAudioError::INVALID_USE;
errorText_ = "RtApi::openStream: a stream is already open!"; errorText_ = "RtApi::openStream: a stream is already open!";
return error( RtAudioError::INVALID_USE );
return error( RTAUDIO_INVALID_USE );
} }


// Clear stream information potentially left from a previously open stream. // Clear stream information potentially left from a previously open stream.
@@ -329,26 +324,22 @@ RtAudioError::Type RtApi :: openStream( RtAudio::StreamParameters *oParams,


if ( oParams && oParams->nChannels < 1 ) { if ( oParams && oParams->nChannels < 1 ) {
errorText_ = "RtApi::openStream: a non-NULL output StreamParameters structure cannot have an nChannels value less than one."; errorText_ = "RtApi::openStream: a non-NULL output StreamParameters structure cannot have an nChannels value less than one.";
return error( RtAudioError::INVALID_USE );
//return;
return error( RTAUDIO_INVALID_USE );
} }


if ( iParams && iParams->nChannels < 1 ) { if ( iParams && iParams->nChannels < 1 ) {
errorText_ = "RtApi::openStream: a non-NULL input StreamParameters structure cannot have an nChannels value less than one."; errorText_ = "RtApi::openStream: a non-NULL input StreamParameters structure cannot have an nChannels value less than one.";
return error( RtAudioError::INVALID_USE );
//return;
return error( RTAUDIO_INVALID_USE );
} }


if ( oParams == NULL && iParams == NULL ) { if ( oParams == NULL && iParams == NULL ) {
errorText_ = "RtApi::openStream: input and output StreamParameters structures are both NULL!"; errorText_ = "RtApi::openStream: input and output StreamParameters structures are both NULL!";
return error( RtAudioError::INVALID_USE );
//return;
return error( RTAUDIO_INVALID_USE );
} }


if ( formatBytes(format) == 0 ) { if ( formatBytes(format) == 0 ) {
errorText_ = "RtApi::openStream: 'format' parameter value is undefined."; errorText_ = "RtApi::openStream: 'format' parameter value is undefined.";
return error( RtAudioError::INVALID_USE );
//return;
return error( RTAUDIO_INVALID_USE );
} }


unsigned int nDevices = getDeviceCount(); unsigned int nDevices = getDeviceCount();
@@ -357,8 +348,7 @@ RtAudioError::Type RtApi :: openStream( RtAudio::StreamParameters *oParams,
oChannels = oParams->nChannels; oChannels = oParams->nChannels;
if ( oParams->deviceId >= nDevices ) { if ( oParams->deviceId >= nDevices ) {
errorText_ = "RtApi::openStream: output device parameter value is invalid."; errorText_ = "RtApi::openStream: output device parameter value is invalid.";
return error( RtAudioError::INVALID_USE );
//return;
return error( RTAUDIO_INVALID_USE );
} }
} }


@@ -367,8 +357,7 @@ RtAudioError::Type RtApi :: openStream( RtAudio::StreamParameters *oParams,
iChannels = iParams->nChannels; iChannels = iParams->nChannels;
if ( iParams->deviceId >= nDevices ) { if ( iParams->deviceId >= nDevices ) {
errorText_ = "RtApi::openStream: input device parameter value is invalid."; errorText_ = "RtApi::openStream: input device parameter value is invalid.";
return error( RtAudioError::INVALID_USE );
//return;
return error( RTAUDIO_INVALID_USE );
} }
} }


@@ -379,8 +368,7 @@ RtAudioError::Type RtApi :: openStream( RtAudio::StreamParameters *oParams,
result = probeDeviceOpen( oParams->deviceId, OUTPUT, oChannels, oParams->firstChannel, result = probeDeviceOpen( oParams->deviceId, OUTPUT, oChannels, oParams->firstChannel,
sampleRate, format, bufferFrames, options ); sampleRate, format, bufferFrames, options );
if ( result == false ) { if ( result == false ) {
return error( RtAudioError::SYSTEM_ERROR );
//return;
return error( RTAUDIO_SYSTEM_ERROR );
} }
} }


@@ -390,18 +378,16 @@ RtAudioError::Type RtApi :: openStream( RtAudio::StreamParameters *oParams,
sampleRate, format, bufferFrames, options ); sampleRate, format, bufferFrames, options );
if ( result == false ) { if ( result == false ) {
if ( oChannels > 0 ) closeStream(); if ( oChannels > 0 ) closeStream();
return error( RtAudioError::SYSTEM_ERROR );
//return;
return error( RTAUDIO_SYSTEM_ERROR );
} }
} }


stream_.callbackInfo.callback = (void *) callback; stream_.callbackInfo.callback = (void *) callback;
stream_.callbackInfo.userData = userData; stream_.callbackInfo.userData = userData;
//stream_.callbackInfo.errorCallback = (void *) errorCallback;


if ( options ) options->numberOfBuffers = stream_.nBuffers; if ( options ) options->numberOfBuffers = stream_.nBuffers;
stream_.state = STREAM_STOPPED; stream_.state = STREAM_STOPPED;
return RtAudioError::NO_ERROR;
return RTAUDIO_NO_ERROR;
} }


unsigned int RtApi :: getDefaultInputDevice( void ) unsigned int RtApi :: getDefaultInputDevice( void )
@@ -482,8 +468,6 @@ double RtApi :: getStreamTime( void )


void RtApi :: setStreamTime( double time ) void RtApi :: setStreamTime( double time )
{ {
// verifyStream();

if ( time >= 0.0 ) if ( time >= 0.0 )
stream_.streamTime = time; stream_.streamTime = time;
/* /*
@@ -495,7 +479,6 @@ void RtApi :: setStreamTime( double time )


unsigned int RtApi :: getStreamSampleRate( void ) unsigned int RtApi :: getStreamSampleRate( void )
{ {
//verifyStream();
if ( isStreamOpen() ) return stream_.sampleRate; if ( isStreamOpen() ) return stream_.sampleRate;
else return 0; else return 0;
} }
@@ -557,7 +540,7 @@ RtApiCore:: RtApiCore()
OSStatus result = AudioObjectSetPropertyData( kAudioObjectSystemObject, &property, 0, NULL, sizeof(CFRunLoopRef), &theRunLoop); OSStatus result = AudioObjectSetPropertyData( kAudioObjectSystemObject, &property, 0, NULL, sizeof(CFRunLoopRef), &theRunLoop);
if ( result != noErr ) { if ( result != noErr ) {
errorText_ = "RtApiCore::RtApiCore: error setting run loop property!"; errorText_ = "RtApiCore::RtApiCore: error setting run loop property!";
error( RtAudioError::WARNING );
error( RTAUDIO_SYSTEM_ERROR );
} }
#endif #endif
} }
@@ -578,7 +561,7 @@ unsigned int RtApiCore :: getDeviceCount( void )
OSStatus result = AudioObjectGetPropertyDataSize( kAudioObjectSystemObject, &propertyAddress, 0, NULL, &dataSize ); OSStatus result = AudioObjectGetPropertyDataSize( kAudioObjectSystemObject, &propertyAddress, 0, NULL, &dataSize );
if ( result != noErr ) { if ( result != noErr ) {
errorText_ = "RtApiCore::getDeviceCount: OS-X error getting device info!"; errorText_ = "RtApiCore::getDeviceCount: OS-X error getting device info!";
error( RtAudioError::WARNING );
error( RTAUDIO_SYSTEM_ERROR );
return 0; return 0;
} }


@@ -596,7 +579,7 @@ unsigned int RtApiCore :: getDefaultInputDevice( void )
OSStatus result = AudioObjectGetPropertyData( kAudioObjectSystemObject, &property, 0, NULL, &dataSize, &id ); OSStatus result = AudioObjectGetPropertyData( kAudioObjectSystemObject, &property, 0, NULL, &dataSize, &id );
if ( result != noErr ) { if ( result != noErr ) {
errorText_ = "RtApiCore::getDefaultInputDevice: OS-X system error getting device."; errorText_ = "RtApiCore::getDefaultInputDevice: OS-X system error getting device.";
error( RtAudioError::WARNING );
error( RTAUDIO_SYSTEM_ERROR );
return 0; return 0;
} }


@@ -606,7 +589,7 @@ unsigned int RtApiCore :: getDefaultInputDevice( void )
result = AudioObjectGetPropertyData( kAudioObjectSystemObject, &property, 0, NULL, &dataSize, (void *) &deviceList ); result = AudioObjectGetPropertyData( kAudioObjectSystemObject, &property, 0, NULL, &dataSize, (void *) &deviceList );
if ( result != noErr ) { if ( result != noErr ) {
errorText_ = "RtApiCore::getDefaultInputDevice: OS-X system error getting device IDs."; errorText_ = "RtApiCore::getDefaultInputDevice: OS-X system error getting device IDs.";
error( RtAudioError::WARNING );
error( RTAUDIO_SYSTEM_ERROR );
return 0; return 0;
} }


@@ -614,7 +597,7 @@ unsigned int RtApiCore :: getDefaultInputDevice( void )
if ( id == deviceList[i] ) return i; if ( id == deviceList[i] ) return i;


errorText_ = "RtApiCore::getDefaultInputDevice: No default device found!"; errorText_ = "RtApiCore::getDefaultInputDevice: No default device found!";
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
return 0; return 0;
} }


@@ -629,7 +612,7 @@ unsigned int RtApiCore :: getDefaultOutputDevice( void )
OSStatus result = AudioObjectGetPropertyData( kAudioObjectSystemObject, &property, 0, NULL, &dataSize, &id ); OSStatus result = AudioObjectGetPropertyData( kAudioObjectSystemObject, &property, 0, NULL, &dataSize, &id );
if ( result != noErr ) { if ( result != noErr ) {
errorText_ = "RtApiCore::getDefaultOutputDevice: OS-X system error getting device."; errorText_ = "RtApiCore::getDefaultOutputDevice: OS-X system error getting device.";
error( RtAudioError::WARNING );
error( RTAUDIO_SYSTEM_ERROR );
return 0; return 0;
} }


@@ -639,7 +622,7 @@ unsigned int RtApiCore :: getDefaultOutputDevice( void )
result = AudioObjectGetPropertyData( kAudioObjectSystemObject, &property, 0, NULL, &dataSize, (void *) &deviceList ); result = AudioObjectGetPropertyData( kAudioObjectSystemObject, &property, 0, NULL, &dataSize, (void *) &deviceList );
if ( result != noErr ) { if ( result != noErr ) {
errorText_ = "RtApiCore::getDefaultOutputDevice: OS-X system error getting device IDs."; errorText_ = "RtApiCore::getDefaultOutputDevice: OS-X system error getting device IDs.";
error( RtAudioError::WARNING );
error( RTAUDIO_SYSTEM_ERROR );
return 0; return 0;
} }


@@ -647,7 +630,7 @@ unsigned int RtApiCore :: getDefaultOutputDevice( void )
if ( id == deviceList[i] ) return i; if ( id == deviceList[i] ) return i;


errorText_ = "RtApiCore::getDefaultOutputDevice: No default device found!"; errorText_ = "RtApiCore::getDefaultOutputDevice: No default device found!";
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
return 0; return 0;
} }


@@ -660,13 +643,13 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
unsigned int nDevices = getDeviceCount(); unsigned int nDevices = getDeviceCount();
if ( nDevices == 0 ) { if ( nDevices == 0 ) {
errorText_ = "RtApiCore::getDeviceInfo: no devices found!"; errorText_ = "RtApiCore::getDeviceInfo: no devices found!";
error( RtAudioError::INVALID_USE );
error( RTAUDIO_INVALID_USE );
return info; return info;
} }


if ( device >= nDevices ) { if ( device >= nDevices ) {
errorText_ = "RtApiCore::getDeviceInfo: device ID is invalid!"; errorText_ = "RtApiCore::getDeviceInfo: device ID is invalid!";
error( RtAudioError::INVALID_USE );
error( RTAUDIO_INVALID_USE );
return info; return info;
} }


@@ -679,7 +662,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
0, NULL, &dataSize, (void *) &deviceList ); 0, NULL, &dataSize, (void *) &deviceList );
if ( result != noErr ) { if ( result != noErr ) {
errorText_ = "RtApiCore::getDeviceInfo: OS-X system error getting device IDs."; errorText_ = "RtApiCore::getDeviceInfo: OS-X system error getting device IDs.";
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
return info; return info;
} }


@@ -694,7 +677,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
if ( result != noErr ) { if ( result != noErr ) {
errorStream_ << "RtApiCore::probeDeviceInfo: system error (" << getErrorCode( result ) << ") getting device manufacturer."; errorStream_ << "RtApiCore::probeDeviceInfo: system error (" << getErrorCode( result ) << ") getting device manufacturer.";
errorText_ = errorStream_.str(); errorText_ = errorStream_.str();
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
return info; return info;
} }


@@ -716,7 +699,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
if ( result != noErr ) { if ( result != noErr ) {
errorStream_ << "RtApiCore::probeDeviceInfo: system error (" << getErrorCode( result ) << ") getting device name."; errorStream_ << "RtApiCore::probeDeviceInfo: system error (" << getErrorCode( result ) << ") getting device name.";
errorText_ = errorStream_.str(); errorText_ = errorStream_.str();
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
return info; return info;
} }


@@ -742,7 +725,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
if ( result != noErr || dataSize == 0 ) { if ( result != noErr || dataSize == 0 ) {
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting output stream configuration info for device (" << device << ")."; errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting output stream configuration info for device (" << device << ").";
errorText_ = errorStream_.str(); errorText_ = errorStream_.str();
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
return info; return info;
} }


@@ -750,7 +733,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
bufferList = (AudioBufferList *) malloc( dataSize ); bufferList = (AudioBufferList *) malloc( dataSize );
if ( bufferList == NULL ) { if ( bufferList == NULL ) {
errorText_ = "RtApiCore::getDeviceInfo: memory error allocating output AudioBufferList."; errorText_ = "RtApiCore::getDeviceInfo: memory error allocating output AudioBufferList.";
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
return info; return info;
} }


@@ -759,7 +742,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
free( bufferList ); free( bufferList );
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting output stream configuration for device (" << device << ")."; errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting output stream configuration for device (" << device << ").";
errorText_ = errorStream_.str(); errorText_ = errorStream_.str();
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
return info; return info;
} }


@@ -775,7 +758,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
if ( result != noErr || dataSize == 0 ) { if ( result != noErr || dataSize == 0 ) {
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting input stream configuration info for device (" << device << ")."; errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting input stream configuration info for device (" << device << ").";
errorText_ = errorStream_.str(); errorText_ = errorStream_.str();
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
return info; return info;
} }


@@ -783,7 +766,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
bufferList = (AudioBufferList *) malloc( dataSize ); bufferList = (AudioBufferList *) malloc( dataSize );
if ( bufferList == NULL ) { if ( bufferList == NULL ) {
errorText_ = "RtApiCore::getDeviceInfo: memory error allocating input AudioBufferList."; errorText_ = "RtApiCore::getDeviceInfo: memory error allocating input AudioBufferList.";
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
return info; return info;
} }


@@ -792,7 +775,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
free( bufferList ); free( bufferList );
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting input stream configuration for device (" << device << ")."; errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting input stream configuration for device (" << device << ").";
errorText_ = errorStream_.str(); errorText_ = errorStream_.str();
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
return info; return info;
} }


@@ -817,7 +800,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
if ( result != kAudioHardwareNoError || dataSize == 0 ) { if ( result != kAudioHardwareNoError || dataSize == 0 ) {
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting sample rate info."; errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting sample rate info.";
errorText_ = errorStream_.str(); errorText_ = errorStream_.str();
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
return info; return info;
} }


@@ -827,7 +810,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
if ( result != kAudioHardwareNoError ) { if ( result != kAudioHardwareNoError ) {
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting sample rates."; errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting sample rates.";
errorText_ = errorStream_.str(); errorText_ = errorStream_.str();
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
return info; return info;
} }


@@ -874,7 +857,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
if ( info.sampleRates.size() == 0 ) { if ( info.sampleRates.size() == 0 ) {
errorStream_ << "RtApiCore::probeDeviceInfo: No supported sample rates found for device (" << device << ")."; errorStream_ << "RtApiCore::probeDeviceInfo: No supported sample rates found for device (" << device << ").";
errorText_ = errorStream_.str(); errorText_ = errorStream_.str();
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
return info; return info;
} }


@@ -1299,7 +1282,7 @@ bool RtApiCore :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
else { else {
errorStream_ << "RtApiCore::probeDeviceOpen: system error (" << getErrorCode( result ) << ") getting device latency for device (" << device << ")."; errorStream_ << "RtApiCore::probeDeviceOpen: system error (" << getErrorCode( result ) << ") getting device latency for device (" << device << ").";
errorText_ = errorStream_.str(); errorText_ = errorStream_.str();
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
} }
} }


@@ -1477,7 +1460,7 @@ void RtApiCore :: closeStream( void )
{ {
if ( stream_.state == STREAM_CLOSED ) { if ( stream_.state == STREAM_CLOSED ) {
errorText_ = "RtApiCore::closeStream(): no open stream to close!"; errorText_ = "RtApiCore::closeStream(): no open stream to close!";
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
return; return;
} }


@@ -1491,12 +1474,12 @@ void RtApiCore :: closeStream( void )
property.mSelector = kAudioDeviceProcessorOverload; property.mSelector = kAudioDeviceProcessorOverload;
if (AudioObjectRemovePropertyListener( handle->id[0], &property, xrunListener, (void *) handle ) != noErr) { if (AudioObjectRemovePropertyListener( handle->id[0], &property, xrunListener, (void *) handle ) != noErr) {
errorText_ = "RtApiCore::closeStream(): error removing xrun property listener!"; errorText_ = "RtApiCore::closeStream(): error removing xrun property listener!";
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
} }
property.mSelector = kAudioDevicePropertyDeviceIsAlive; property.mSelector = kAudioDevicePropertyDeviceIsAlive;
if (AudioObjectRemovePropertyListener( handle->id[0], &property, disconnectListener, (void *) &stream_.callbackInfo ) != noErr) { if (AudioObjectRemovePropertyListener( handle->id[0], &property, disconnectListener, (void *) &stream_.callbackInfo ) != noErr) {
errorText_ = "RtApiCore::closeStream(): error removing disconnect property listener!"; errorText_ = "RtApiCore::closeStream(): error removing disconnect property listener!";
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
} }
} }
if ( stream_.state == STREAM_RUNNING ) if ( stream_.state == STREAM_RUNNING )
@@ -1518,12 +1501,12 @@ void RtApiCore :: closeStream( void )
property.mSelector = kAudioDeviceProcessorOverload; property.mSelector = kAudioDeviceProcessorOverload;
if (AudioObjectRemovePropertyListener( handle->id[1], &property, xrunListener, (void *) handle ) != noErr) { if (AudioObjectRemovePropertyListener( handle->id[1], &property, xrunListener, (void *) handle ) != noErr) {
errorText_ = "RtApiCore::closeStream(): error removing xrun property listener!"; errorText_ = "RtApiCore::closeStream(): error removing xrun property listener!";
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
} }
property.mSelector = kAudioDevicePropertyDeviceIsAlive; property.mSelector = kAudioDevicePropertyDeviceIsAlive;
if (AudioObjectRemovePropertyListener( handle->id[1], &property, disconnectListener, (void *) &stream_.callbackInfo ) != noErr) { if (AudioObjectRemovePropertyListener( handle->id[1], &property, disconnectListener, (void *) &stream_.callbackInfo ) != noErr) {
errorText_ = "RtApiCore::closeStream(): error removing disconnect property listener!"; errorText_ = "RtApiCore::closeStream(): error removing disconnect property listener!";
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
} }
} }
if ( stream_.state == STREAM_RUNNING ) if ( stream_.state == STREAM_RUNNING )
@@ -1557,7 +1540,7 @@ void RtApiCore :: closeStream( void )
CallbackInfo *info = (CallbackInfo *) &stream_.callbackInfo; CallbackInfo *info = (CallbackInfo *) &stream_.callbackInfo;
if ( info->deviceDisconnected ) { if ( info->deviceDisconnected ) {
errorText_ = "RtApiCore: the stream device was disconnected (and closed)!"; errorText_ = "RtApiCore: the stream device was disconnected (and closed)!";
error( RtAudioError::DEVICE_DISCONNECT );
error( RTAUDIO_DEVICE_DISCONNECT );
} }
clearStreamInfo(); clearStreamInfo();
@@ -1565,17 +1548,14 @@ void RtApiCore :: closeStream( void )
//stream_.state = STREAM_CLOSED; //stream_.state = STREAM_CLOSED;
} }


//void RtApiCore :: startStream( void )
RtAudioError::Type RtApiCore :: startStream( void )
RtAudioErrorType RtApiCore :: startStream( void )
{ {
//verifyStream();
if ( stream_.state != STREAM_STOPPED ) { if ( stream_.state != STREAM_STOPPED ) {
if ( stream_.state == STREAM_RUNNING ) if ( stream_.state == STREAM_RUNNING )
errorText_ = "RtApiCore::startStream(): the stream is already running!"; errorText_ = "RtApiCore::startStream(): the stream is already running!";
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED ) else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED )
errorText_ = "RtApiCore::startStream(): the stream is stopping or closed!"; errorText_ = "RtApiCore::startStream(): the stream is stopping or closed!";
return error( RtAudioError::WARNING );
//return;
return error( RTAUDIO_WARNING );
} }


/* /*
@@ -1612,27 +1592,23 @@ RtAudioError::Type RtApiCore :: startStream( void )
} }
} }


// set stream time to zero?
handle->drainCounter = 0; handle->drainCounter = 0;
handle->internalDrain = false; handle->internalDrain = false;
stream_.state = STREAM_RUNNING; stream_.state = STREAM_RUNNING;


unlock: unlock:
if ( result == noErr ) return RtAudioError::NO_ERROR;
return error( RtAudioError::SYSTEM_ERROR );
if ( result == noErr ) return RTAUDIO_NO_ERROR;
return error( RTAUDIO_SYSTEM_ERROR );
} }


//void RtApiCore :: stopStream( void )
RtAudioError::Type RtApiCore :: stopStream( void )
RtAudioErrorType RtApiCore :: stopStream( void )
{ {
//verifyStream();
if ( stream_.state != STREAM_RUNNING && stream_.state != STREAM_STOPPING ) { if ( stream_.state != STREAM_RUNNING && stream_.state != STREAM_STOPPING ) {
if ( stream_.state == STREAM_STOPPED ) if ( stream_.state == STREAM_STOPPED )
errorText_ = "RtApiCore::stopStream(): the stream is already stopped!"; errorText_ = "RtApiCore::stopStream(): the stream is already stopped!";
else if ( stream_.state == STREAM_CLOSED ) else if ( stream_.state == STREAM_CLOSED )
errorText_ = "RtApiCore::stopStream(): the stream is closed!"; errorText_ = "RtApiCore::stopStream(): the stream is closed!";
return error( RtAudioError::WARNING );
//return;
return error( RTAUDIO_WARNING );
} }


OSStatus result = noErr; OSStatus result = noErr;
@@ -1665,20 +1641,18 @@ RtAudioError::Type RtApiCore :: stopStream( void )
stream_.state = STREAM_STOPPED; stream_.state = STREAM_STOPPED;


unlock: unlock:
if ( result == noErr ) return RtAudioError::NO_ERROR;
return error( RtAudioError::SYSTEM_ERROR );
if ( result == noErr ) return RTAUDIO_NO_ERROR;
return error( RTAUDIO_SYSTEM_ERROR );
} }


//void RtApiCore :: abortStream( void )
RtAudioError::Type RtApiCore :: abortStream( void )
RtAudioErrorType RtApiCore :: abortStream( void )
{ {
//verifyStream();
if ( stream_.state != STREAM_RUNNING ) { if ( stream_.state != STREAM_RUNNING ) {
if ( stream_.state == STREAM_STOPPED ) if ( stream_.state == STREAM_STOPPED )
errorText_ = "RtApiCore::abortStream(): the stream is already stopped!"; errorText_ = "RtApiCore::abortStream(): the stream is already stopped!";
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED ) else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED )
errorText_ = "RtApiCore::abortStream(): the stream is stopping or closed!"; errorText_ = "RtApiCore::abortStream(): the stream is stopping or closed!";
return error( RtAudioError::WARNING );
return error( RTAUDIO_WARNING );
//return; //return;
} }


@@ -1710,7 +1684,7 @@ bool RtApiCore :: callbackEvent( AudioDeviceID deviceId,
if ( stream_.state == STREAM_STOPPED || stream_.state == STREAM_STOPPING ) return SUCCESS; if ( stream_.state == STREAM_STOPPED || stream_.state == STREAM_STOPPING ) return SUCCESS;
if ( stream_.state == STREAM_CLOSED ) { if ( stream_.state == STREAM_CLOSED ) {
errorText_ = "RtApiCore::callbackEvent(): the stream is closed ... this shouldn't happen!"; errorText_ = "RtApiCore::callbackEvent(): the stream is closed ... this shouldn't happen!";
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
return FAILURE; return FAILURE;
} }


@@ -2119,7 +2093,7 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device )
jack_client_t *client = jack_client_open( "RtApiJackInfo", options, status ); jack_client_t *client = jack_client_open( "RtApiJackInfo", options, status );
if ( client == 0 ) { if ( client == 0 ) {
errorText_ = "RtApiJack::getDeviceInfo: Jack server not found or connection error!"; errorText_ = "RtApiJack::getDeviceInfo: Jack server not found or connection error!";
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );
return info; return info;
} }


@@ -2623,7 +2597,7 @@ void RtApiJack :: startStream( void )


unlock: unlock:
if ( result == 0 ) return; if ( result == 0 ) return;
error( RtAudioError::SYSTEM_ERROR );
error( RtAudioError::RTAUDIO_SYSTEM_ERROR );
} }


void RtApiJack :: stopStream( void ) void RtApiJack :: stopStream( void )
@@ -9987,13 +9961,12 @@ static void *ossCallbackHandler( void *ptr )


// This method can be modified to control the behavior of error // This method can be modified to control the behavior of error
// message printing. // message printing.
//void RtApi :: error( RtAudioError::Type type )
RtAudioError::Type RtApi :: error( RtAudioError::Type type )
RtAudioErrorType RtApi :: error( RtAudioErrorType type )
{ {
errorStream_.str(""); // clear the ostringstream to avoid repeated messages errorStream_.str(""); // clear the ostringstream to avoid repeated messages


// Don't output warnings if showWarnings_ is false // Don't output warnings if showWarnings_ is false
if ( type == RtAudioError::WARNING && showWarnings_ == false ) return type;
if ( type == RTAUDIO_WARNING && showWarnings_ == false ) return type;
if ( errorCallback_ ) { if ( errorCallback_ ) {
const std::string errorMessage = errorText_; const std::string errorMessage = errorText_;
@@ -10029,7 +10002,6 @@ void RtApi :: clearStreamInfo()
stream_.callbackInfo.callback = 0; stream_.callbackInfo.callback = 0;
stream_.callbackInfo.userData = 0; stream_.callbackInfo.userData = 0;
stream_.callbackInfo.isRunning = false; stream_.callbackInfo.isRunning = false;
//stream_.callbackInfo.errorCallback = 0;
for ( int i=0; i<2; i++ ) { for ( int i=0; i<2; i++ ) {
stream_.device[i] = 11111; stream_.device[i] = 11111;
stream_.doConvertBuffer[i] = false; stream_.doConvertBuffer[i] = false;
@@ -10065,7 +10037,7 @@ unsigned int RtApi :: formatBytes( RtAudioFormat format )
return 1; return 1;


errorText_ = "RtApi::formatBytes: undefined format."; errorText_ = "RtApi::formatBytes: undefined format.";
error( RtAudioError::WARNING );
error( RTAUDIO_WARNING );


return 0; return 0;
} }


+ 106
- 108
RtAudio.h View File

@@ -46,7 +46,7 @@
#ifndef __RTAUDIO_H #ifndef __RTAUDIO_H
#define __RTAUDIO_H #define __RTAUDIO_H


#define RTAUDIO_VERSION "5.1.0"
#define RTAUDIO_VERSION "6.0.0beta1"


#if defined _WIN32 || defined __CYGWIN__ #if defined _WIN32 || defined __CYGWIN__
#if defined(RTAUDIO_EXPORT) #if defined(RTAUDIO_EXPORT)
@@ -64,7 +64,7 @@


#include <string> #include <string>
#include <vector> #include <vector>
#include <stdexcept>
//#include <stdexcept>
#include <iostream> #include <iostream>


/*! \typedef typedef unsigned long RtAudioFormat; /*! \typedef typedef unsigned long RtAudioFormat;
@@ -208,51 +208,65 @@ typedef int (*RtAudioCallback)( void *outputBuffer, void *inputBuffer,


/************************************************************************/ /************************************************************************/
/*! \class RtAudioError /*! \class RtAudioError
\brief Exception handling class for RtAudio.
\brief Error handling class for RtAudio.


The RtAudioError class is quite simple but it does allow errors to be The RtAudioError class is quite simple but it does allow errors to be
"caught" by RtAudioError::Type. See the RtAudio documentation to know
which methods can throw an RtAudioError.
identified by RtAudioError::Type.
*/ */
/************************************************************************/ /************************************************************************/


class RTAUDIO_DLL_PUBLIC RtAudioError : public std::runtime_error
{
public:
//! Defined RtAudioError types.
enum Type {
NO_ERROR, /*!< No error. */
WARNING, /*!< A non-critical error. */
UNSPECIFIED, /*!< The default, unspecified error type. */
NO_DEVICES_FOUND, /*!< No devices found on system. */
INVALID_DEVICE, /*!< An invalid device ID was specified. */
DEVICE_DISCONNECT, /*!< A device in use was disconnected. */
MEMORY_ERROR, /*!< An error occured during memory allocation. */
INVALID_PARAMETER, /*!< An invalid parameter was specified to a function. */
INVALID_USE, /*!< The function was called incorrectly. */
DRIVER_ERROR, /*!< A system driver error occured. */
SYSTEM_ERROR, /*!< A system error occured. */
THREAD_ERROR /*!< A thread error occured. */
};

//! The constructor.
RtAudioError( const std::string& message,
Type type = RtAudioError::UNSPECIFIED )
: std::runtime_error(message), type_(type) {}

//! Prints thrown error message to stderr.
virtual void printMessage( void ) const
{ std::cerr << '\n' << what() << "\n\n"; }

//! Returns the thrown error message type.
virtual const Type& getType(void) const { return type_; }

//! Returns the thrown error message string.
virtual const std::string getMessage(void) const
{ return std::string(what()); }

protected:
Type type_;
/* class RTAUDIO_DLL_PUBLIC RtAudioError : public std::runtime_error */
/* { */
/* public: */
/* //! Defined RtAudioError types. */
/* enum Type { */
/* NO_ERROR, /\*!< No error. *\/ */
/* WARNING, /\*!< A non-critical error. *\/ */
/* UNSPECIFIED, /\*!< The default, unspecified error type. *\/ */
/* NO_DEVICES_FOUND, /\*!< No devices found on system. *\/ */
/* INVALID_DEVICE, /\*!< An invalid device ID was specified. *\/ */
/* DEVICE_DISCONNECT, /\*!< A device in use was disconnected. *\/ */
/* MEMORY_ERROR, /\*!< An error occured during memory allocation. *\/ */
/* INVALID_PARAMETER, /\*!< An invalid parameter was specified to a function. *\/ */
/* INVALID_USE, /\*!< The function was called incorrectly. *\/ */
/* DRIVER_ERROR, /\*!< A system driver error occured. *\/ */
/* SYSTEM_ERROR, /\*!< A system error occured. *\/ */
/* THREAD_ERROR /\*!< A thread error occured. *\/ */
/* }; */

/* //! The constructor. */
/* RtAudioError( const std::string& message, */
/* Type type = RtAudioError::UNSPECIFIED ) */
/* : std::runtime_error(message), type_(type) {} */

/* //! Prints error message to stderr. */
/* virtual void printMessage( void ) const */
/* { std::cerr << '\n' << what() << "\n\n"; } */

/* //! Returns the error message type. */
/* virtual const Type& getType(void) const { return type_; } */

/* //! Returns the error message string. */
/* virtual const std::string getMessage(void) const */
/* { return std::string(what()); } */

/* protected: */
/* Type type_; */
/* }; */

enum RtAudioErrorType {
RTAUDIO_NO_ERROR, /*!< No error. */
RTAUDIO_WARNING, /*!< A non-critical error. */
RTAUDIO_UNKNOWN_ERROR, /*!< An unspecified error type. */
RTAUDIO_NO_DEVICES_FOUND, /*!< No devices found on system. */
RTAUDIO_INVALID_DEVICE, /*!< An invalid device ID was specified. */
RTAUDIO_DEVICE_DISCONNECT, /*!< A device in use was disconnected. */
RTAUDIO_MEMORY_ERROR, /*!< An error occured during memory allocation. */
RTAUDIO_INVALID_PARAMETER, /*!< An invalid parameter was specified to a function. */
RTAUDIO_INVALID_USE, /*!< The function was called incorrectly. */
RTAUDIO_DRIVER_ERROR, /*!< A system driver error occurred. */
RTAUDIO_SYSTEM_ERROR, /*!< A system error occurred. */
RTAUDIO_THREAD_ERROR /*!< A thread error occurred. */
}; };


//! RtAudio error callback function prototype. //! RtAudio error callback function prototype.
@@ -260,7 +274,7 @@ class RTAUDIO_DLL_PUBLIC RtAudioError : public std::runtime_error
\param type Type of error. \param type Type of error.
\param errorText Error description. \param errorText Error description.
*/ */
typedef void (*RtAudioErrorCallback)( RtAudioError::Type type, const std::string &errorText );
typedef void (*RtAudioErrorCallback)( RtAudioErrorType type, const std::string &errorText );


// **************************************************************** // // **************************************************************** //
// //
@@ -460,14 +474,16 @@ class RTAUDIO_DLL_PUBLIC RtAudio


//! Return an RtAudio::DeviceInfo structure for a specified device number. //! Return an RtAudio::DeviceInfo structure for a specified device number.
/*! /*!

Any device integer between 0 and getDeviceCount() - 1 is valid. Any device integer between 0 and getDeviceCount() - 1 is valid.
If an invalid argument is provided, an RtAudioError (type = INVALID_USE)
will be thrown. If a device is busy or otherwise unavailable, the
structure member "probed" will have a value of "false" and all
other members are undefined. If the specified device is the
current default input or output device, the corresponding
"isDefault" member will have a value of "true".
If an invalid argument is provided, an RTAUDIO_INVALID_USE
will be passed to the user-provided errorCallback function (or
otherwise printed to stderr), the structure member "probed" will
have a value of "false" and all other members will be undefined.
If a device is busy or otherwise unavailable, the structure member
"probed" will have a value of "false" and all other members will
be undefined. If the specified device is the current default
input or output device, the corresponding "isDefault" member will
have a value of "true".
*/ */
RtAudio::DeviceInfo getDeviceInfo( unsigned int device ); RtAudio::DeviceInfo getDeviceInfo( unsigned int device );


@@ -493,10 +509,10 @@ class RTAUDIO_DLL_PUBLIC RtAudio


//! A public function for opening a stream with the specified parameters. //! A public function for opening a stream with the specified parameters.
/*! /*!
An RtAudioError (type = SYSTEM_ERROR) is thrown if a stream cannot be
An RTAUDIO_SYSTEM_ERROR is returned if a stream cannot be
opened with the specified parameters or an error occurs during opened with the specified parameters or an error occurs during
processing. An RtAudioError (type = INVALID_USE) is thrown if any
invalid device ID or channel number parameters are specified.
processing. An RTAUDIO_INVALID_USE is returned if a stream
is already open or any invalid stream parameters are specified.


\param outputParameters Specifies output stream parameters to use \param outputParameters Specifies output stream parameters to use
when opening a stream, including a device ID, number of channels, when opening a stream, including a device ID, number of channels,
@@ -528,49 +544,44 @@ class RTAUDIO_DLL_PUBLIC RtAudio
chosen. If the RTAUDIO_MINIMIZE_LATENCY flag bit is set, the chosen. If the RTAUDIO_MINIMIZE_LATENCY flag bit is set, the
lowest allowable value is used. The actual value used is lowest allowable value is used. The actual value used is
returned via the structure argument. The parameter is API dependent. returned via the structure argument. The parameter is API dependent.
\param errorCallback A client-defined function that will be invoked
when an error has occured.
*/ */
//void openStream( RtAudio::StreamParameters *outputParameters,
RtAudioError::Type openStream( RtAudio::StreamParameters *outputParameters,
RtAudioErrorType openStream( RtAudio::StreamParameters *outputParameters,
RtAudio::StreamParameters *inputParameters, RtAudio::StreamParameters *inputParameters,
RtAudioFormat format, unsigned int sampleRate, RtAudioFormat format, unsigned int sampleRate,
unsigned int *bufferFrames, RtAudioCallback callback, unsigned int *bufferFrames, RtAudioCallback callback,
void *userData = NULL, RtAudio::StreamOptions *options = NULL ); //, RtAudioErrorCallback errorCallback = NULL );
void *userData = NULL, RtAudio::StreamOptions *options = NULL );


//! A function that closes a stream and frees any associated stream memory. //! A function that closes a stream and frees any associated stream memory.
/*! /*!
If a stream is not open, this function issues a warning and
returns (no exception is thrown).
If a stream is not open, an RTAUDIO_WARNING will be
passed to the user-provided errorCallback function (or otherwise
printed to stderr).
*/ */
void closeStream( void ); void closeStream( void );


//! A function that starts a stream. //! A function that starts a stream.
/*! /*!
An RtAudioError::SYSTEM_ERROR is returned if an error occurs
during processing. An RtAudioError:WARNING is returned if a
An RTAUDIO_SYSTEM_ERROR is returned if an error occurs
during processing. An RTAUDIO_WARNING is returned if a
stream is not open or is already running. stream is not open or is already running.
*/ */
//void startStream( void );
RtAudioError::Type startStream( void );
RtAudioErrorType startStream( void );


//! Stop a stream, allowing any samples remaining in the output queue to be played. //! Stop a stream, allowing any samples remaining in the output queue to be played.
/*! /*!
An RtAudioError::SYSTEM_ERROR is returned if an error occurs
during processing. An RtAudioError::WARNING is returned if a
An RTAUDIO_SYSTEM_ERROR is returned if an error occurs
during processing. An RTAUDIO_WARNING is returned if a
stream is not open or is already stopped. stream is not open or is already stopped.
*/ */
//void stopStream( void );
RtAudioError::Type stopStream( void );
RtAudioErrorType stopStream( void );


//! Stop a stream, discarding any samples remaining in the input/output queue. //! Stop a stream, discarding any samples remaining in the input/output queue.
/*! /*!
An RtAudioError::SYSTEM_ERROR is returned if an error occurs
during processing. An RtAudioError::WARNING is returned if a
An RTAUDIO_SYSTEM_ERROR is returned if an error occurs
during processing. An RTAUDIO_WARNING is returned if a
stream is not open or is already stopped. stream is not open or is already stopped.
*/ */
//void abortStream( void );
RtAudioError::Type abortStream( void );
RtAudioErrorType abortStream( void );


//! Returns true if a stream is open and false if not. //! Returns true if a stream is open and false if not.
bool isStreamOpen( void ) const; bool isStreamOpen( void ) const;
@@ -580,14 +591,11 @@ class RTAUDIO_DLL_PUBLIC RtAudio


//! Returns the number of elapsed seconds since the stream was started. //! Returns the number of elapsed seconds since the stream was started.
/*! /*!
If a stream is not open, an RtAudioError (type = INVALID_USE) will be thrown.
If a stream is not open, the returned value may not be valid.
*/ */
double getStreamTime( void ); double getStreamTime( void );


//! Set the stream time to a time in seconds greater than or equal to 0.0. //! Set the stream time to a time in seconds greater than or equal to 0.0.
/*!
If a stream is not open, an RtAudioError (type = INVALID_USE) will be thrown.
*/
void setStreamTime( double time ); void setStreamTime( double time );


//! Returns the internal stream latency in sample frames. //! Returns the internal stream latency in sample frames.
@@ -595,9 +603,9 @@ class RTAUDIO_DLL_PUBLIC RtAudio
The stream latency refers to delay in audio input and/or output The stream latency refers to delay in audio input and/or output
caused by internal buffering by the audio system and/or hardware. caused by internal buffering by the audio system and/or hardware.
For duplex streams, the returned value will represent the sum of For duplex streams, the returned value will represent the sum of
the input and output latencies. If a stream is not open, an
RtAudioError (type = INVALID_USE) will be thrown. If the API does not
report latency, the return value will be zero.
the input and output latencies. If a stream is not open, the
returned value will be invalid. If the API does not report
latency, the return value will be zero.
*/ */
long getStreamLatency( void ); long getStreamLatency( void );


@@ -662,7 +670,6 @@ struct CallbackInfo {
ThreadHandle thread; ThreadHandle thread;
void *callback; void *callback;
void *userData; void *userData;
// void *errorCallback;
void *apiInfo; // void pointer for API specific callback information void *apiInfo; // void pointer for API specific callback information
bool isRunning; bool isRunning;
bool doRealtime; bool doRealtime;
@@ -671,7 +678,7 @@ struct CallbackInfo {


// Default constructor. // Default constructor.
CallbackInfo() CallbackInfo()
:object(0), callback(0), userData(0), apiInfo(0), isRunning(false), doRealtime(false), priority(0), deviceDisconnected(false) {} // errorCallback(0),
:object(0), callback(0), userData(0), apiInfo(0), isRunning(false), doRealtime(false), priority(0), deviceDisconnected(false) {}
}; };


// **************************************************************** // // **************************************************************** //
@@ -734,21 +741,17 @@ public:
virtual RtAudio::DeviceInfo getDeviceInfo( unsigned int device ) = 0; virtual RtAudio::DeviceInfo getDeviceInfo( unsigned int device ) = 0;
virtual unsigned int getDefaultInputDevice( void ); virtual unsigned int getDefaultInputDevice( void );
virtual unsigned int getDefaultOutputDevice( void ); virtual unsigned int getDefaultOutputDevice( void );
//void openStream( RtAudio::StreamParameters *outputParameters,
RtAudioError::Type openStream( RtAudio::StreamParameters *outputParameters,
RtAudioErrorType openStream( RtAudio::StreamParameters *outputParameters,
RtAudio::StreamParameters *inputParameters, RtAudio::StreamParameters *inputParameters,
RtAudioFormat format, unsigned int sampleRate, RtAudioFormat format, unsigned int sampleRate,
unsigned int *bufferFrames, RtAudioCallback callback, unsigned int *bufferFrames, RtAudioCallback callback,
void *userData, RtAudio::StreamOptions *options ); //, RtAudioErrorCallback errorCallback );
void *userData, RtAudio::StreamOptions *options );
virtual void closeStream( void ); virtual void closeStream( void );
//virtual void startStream( void ) = 0;
virtual RtAudioError::Type startStream( void ) = 0;
//virtual void stopStream( void ) = 0;
//virtual void abortStream( void ) = 0;
virtual RtAudioError::Type stopStream( void ) = 0;
virtual RtAudioError::Type abortStream( void ) = 0;
virtual RtAudioErrorType startStream( void ) = 0;
virtual RtAudioErrorType stopStream( void ) = 0;
virtual RtAudioErrorType abortStream( void ) = 0;
long getStreamLatency( void ); long getStreamLatency( void );
unsigned int getStreamSampleRate( void ); // const { return stream_.sampleRate; }
unsigned int getStreamSampleRate( void );
virtual double getStreamTime( void ) const { return stream_.streamTime; } virtual double getStreamTime( void ) const { return stream_.streamTime; }
virtual void setStreamTime( double time ); virtual void setStreamTime( double time );
bool isStreamOpen( void ) const { return stream_.state != STREAM_CLOSED; } bool isStreamOpen( void ) const { return stream_.state != STREAM_CLOSED; }
@@ -832,7 +835,6 @@ protected:
RtAudioErrorCallback errorCallback_; RtAudioErrorCallback errorCallback_;
bool showWarnings_; bool showWarnings_;
RtApiStream stream_; RtApiStream stream_;
//bool firstErrorOccurred_;


/*! /*!
Protected, api-specific method that attempts to open a device Protected, api-specific method that attempts to open a device
@@ -856,11 +858,10 @@ protected:
Protected common method that throws an RtAudioError (type = Protected common method that throws an RtAudioError (type =
INVALID_USE) if a stream is not open. INVALID_USE) if a stream is not open.
*/ */
void verifyStream( void );
//void verifyStream( void );


//! Protected common error method to allow global control over error handling. //! Protected common error method to allow global control over error handling.
//void error( RtAudioError::Type type );
RtAudioError::Type error( RtAudioError::Type type );
RtAudioErrorType error( RtAudioErrorType type );


/*! /*!
Protected method used to perform format, channel number, and/or interleaving Protected method used to perform format, channel number, and/or interleaving
@@ -891,11 +892,11 @@ inline unsigned int RtAudio :: getDefaultInputDevice( void ) { return rtapi_->ge
inline unsigned int RtAudio :: getDefaultOutputDevice( void ) { return rtapi_->getDefaultOutputDevice(); } inline unsigned int RtAudio :: getDefaultOutputDevice( void ) { return rtapi_->getDefaultOutputDevice(); }
inline void RtAudio :: closeStream( void ) { return rtapi_->closeStream(); } inline void RtAudio :: closeStream( void ) { return rtapi_->closeStream(); }
//inline void RtAudio :: startStream( void ) { return rtapi_->startStream(); } //inline void RtAudio :: startStream( void ) { return rtapi_->startStream(); }
inline RtAudioError::Type RtAudio :: startStream( void ) { return rtapi_->startStream(); }
inline RtAudioErrorType RtAudio :: startStream( void ) { return rtapi_->startStream(); }
//inline void RtAudio :: stopStream( void ) { return rtapi_->stopStream(); } //inline void RtAudio :: stopStream( void ) { return rtapi_->stopStream(); }
//inline void RtAudio :: abortStream( void ) { return rtapi_->abortStream(); } //inline void RtAudio :: abortStream( void ) { return rtapi_->abortStream(); }
inline RtAudioError::Type RtAudio :: stopStream( void ) { return rtapi_->stopStream(); }
inline RtAudioError::Type RtAudio :: abortStream( void ) { return rtapi_->abortStream(); }
inline RtAudioErrorType RtAudio :: stopStream( void ) { return rtapi_->stopStream(); }
inline RtAudioErrorType RtAudio :: abortStream( void ) { return rtapi_->abortStream(); }
inline bool RtAudio :: isStreamOpen( void ) const { return rtapi_->isStreamOpen(); } inline bool RtAudio :: isStreamOpen( void ) const { return rtapi_->isStreamOpen(); }
inline bool RtAudio :: isStreamRunning( void ) const { return rtapi_->isStreamRunning(); } inline bool RtAudio :: isStreamRunning( void ) const { return rtapi_->isStreamRunning(); }
inline long RtAudio :: getStreamLatency( void ) { return rtapi_->getStreamLatency(); } inline long RtAudio :: getStreamLatency( void ) { return rtapi_->getStreamLatency(); }
@@ -923,12 +924,9 @@ public:
unsigned int getDefaultOutputDevice( void ); unsigned int getDefaultOutputDevice( void );
unsigned int getDefaultInputDevice( void ); unsigned int getDefaultInputDevice( void );
void closeStream( void ); void closeStream( void );
//void startStream( void );
RtAudioError::Type startStream( void );
//void stopStream( void ;)
RtAudioError::Type stopStream( void );
//void abortStream( void );
RtAudioError::Type abortStream( void );
RtAudioErrorType startStream( void );
RtAudioErrorType stopStream( void );
RtAudioErrorType abortStream( void );


// This function is intended for internal use only. It must be // This function is intended for internal use only. It must be
// public because it is called by the internal callback handler, // public because it is called by the internal callback handler,
@@ -1197,14 +1195,14 @@ class RtApiDummy: public RtApi
{ {
public: public:


RtApiDummy() { errorText_ = "RtApiDummy: This class provides no functionality."; error( RtAudioError::WARNING ); }
RtApiDummy() { errorText_ = "RtApiDummy: This class provides no functionality."; error( RTAUDIO_WARNING ); }
RtAudio::Api getCurrentApi( void ) { return RtAudio::RTAUDIO_DUMMY; } RtAudio::Api getCurrentApi( void ) { return RtAudio::RTAUDIO_DUMMY; }
unsigned int getDeviceCount( void ) { return 0; } unsigned int getDeviceCount( void ) { return 0; }
RtAudio::DeviceInfo getDeviceInfo( unsigned int /*device*/ ) { RtAudio::DeviceInfo info; return info; } RtAudio::DeviceInfo getDeviceInfo( unsigned int /*device*/ ) { RtAudio::DeviceInfo info; return info; }
void closeStream( void ) {} void closeStream( void ) {}
void startStream( void ) {}
void stopStream( void ) {}
void abortStream( void ) {}
RtAudioErrorType startStream( void ) { return RTAUDIO_NO_ERROR; }
RtAudioErrorType stopStream( void ) { return RTAUDIO_NO_ERROR; }
RtAudioErrorType abortStream( void ) { return RTAUDIO_NO_ERROR; }


private: private:




+ 1
- 1
configure.ac View File

@@ -1,5 +1,5 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
AC_INIT(RtAudio, 5.1.0, gary@music.mcgill.ca, rtaudio)
AC_INIT(RtAudio, 6.0.0beta1, gary@music.mcgill.ca, rtaudio)
AC_CONFIG_AUX_DIR(config) AC_CONFIG_AUX_DIR(config)
AC_CONFIG_SRCDIR(RtAudio.cpp) AC_CONFIG_SRCDIR(RtAudio.cpp)
AC_CONFIG_FILES([rtaudio.pc Makefile tests/Makefile doc/Makefile doc/doxygen/Doxyfile]) AC_CONFIG_FILES([rtaudio.pc Makefile tests/Makefile doc/Makefile doc/doxygen/Doxyfile])


+ 1
- 1
tests/playsaw.cpp View File

@@ -64,7 +64,7 @@ void usage( void ) {
exit( 0 ); exit( 0 );
} }


void errorCallback( RtAudioError::Type /*type*/, const std::string &errorText )
void errorCallback( RtAudioErrorType /*type*/, const std::string &errorText )
{ {
// This example error handling function simply outputs the error message to stderr. // This example error handling function simply outputs the error message to stderr.
std::cerr << "\nerrorCallback: " << errorText << "\n\n"; std::cerr << "\nerrorCallback: " << errorText << "\n\n";


Loading…
Cancel
Save