summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Scavone <gary@music.mcgill.ca>2019-07-30 17:23:28 -0400
committerGary Scavone <gary@music.mcgill.ca>2019-07-30 17:23:28 -0400
commitba23fd33d7cf5d372d487b5c8a91f569875a001c (patch)
tree54fb6841a7d996f231982383c6da1a7da95d2042
parent6c7651fd65e2d6d423836cee77a48d1b238b2595 (diff)
Removed RtAudioError class and created a new enum for error types. Only implemented for RtApiCore and RtApiDummy, not rtaudio_c.
-rw-r--r--Makefile.am4
-rw-r--r--RtAudio.cpp156
-rw-r--r--RtAudio.h214
-rw-r--r--configure.ac2
-rw-r--r--tests/playsaw.cpp2
5 files changed, 174 insertions, 204 deletions
diff --git a/Makefile.am b/Makefile.am
index 05eab64..6b7aca7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,8 +9,8 @@ lib_LTLIBRARIES = %D%/librtaudio.la
%C%_librtaudio_la_CXXFLAGS = -DRTAUDIO_EXPORT
%C%_librtaudio_la_LDFLAGS = -no-undefined -export-dynamic -version-info @SO_VERSION@
%C%_librtaudio_la_SOURCES = \
- %D%/RtAudio.cpp \
- %D%/rtaudio_c.cpp
+ %D%/RtAudio.cpp
+# %D%/rtaudio_c.cpp
if ASIO
%C%_librtaudio_la_SOURCES += \
diff --git a/RtAudio.cpp b/RtAudio.cpp
index e147b36..5d1b5b8 100644
--- a/RtAudio.cpp
+++ b/RtAudio.cpp
@@ -39,7 +39,7 @@
*/
/************************************************************************/
-// RtAudio: Version 5.1.0
+// RtAudio: Version 6.0.0beta1
#include "RtAudio.h"
#include <iostream>
@@ -264,9 +264,9 @@ RtAudio :: RtAudio( RtAudio::Api api )
// It should not be possible to get here because the preprocessor
// definition __RTAUDIO_DUMMY__ is automatically defined in RtAudio.h
// 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()
@@ -275,17 +275,16 @@ RtAudio :: ~RtAudio()
delete rtapi_;
}
-//void RtAudio :: openStream( RtAudio::StreamParameters *outputParameters,
-RtAudioError::Type RtAudio :: openStream( RtAudio::StreamParameters *outputParameters,
+RtAudioErrorType RtAudio :: openStream( RtAudio::StreamParameters *outputParameters,
RtAudio::StreamParameters *inputParameters,
RtAudioFormat format, unsigned int sampleRate,
unsigned int *bufferFrames,
RtAudioCallback callback, void *userData,
- RtAudio::StreamOptions *options ) //, RtAudioErrorCallback errorCallback )
+ RtAudio::StreamOptions *options )
{
return rtapi_->openStream( outputParameters, inputParameters, format,
sampleRate, bufferFrames, callback,
- userData, options ); //, errorCallback );
+ userData, options );
}
// *************************************************** //
@@ -301,7 +300,6 @@ RtApi :: RtApi()
MUTEX_INITIALIZE( &stream_.mutex );
errorCallback_ = 0;
showWarnings_ = true;
- //firstErrorOccurred_ = false;
}
RtApi :: ~RtApi()
@@ -309,19 +307,16 @@ RtApi :: ~RtApi()
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,
RtAudioFormat format, unsigned int sampleRate,
unsigned int *bufferFrames,
RtAudioCallback callback, void *userData,
- RtAudio::StreamOptions *options ) //, RtAudioErrorCallback errorCallback )
+ RtAudio::StreamOptions *options )
{
- //RtAudioError::Type type = RtAudioError::NO_ERROR;
if ( stream_.state != STREAM_CLOSED ) {
- //type = RtAudioError::INVALID_USE;
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.
@@ -329,26 +324,22 @@ RtAudioError::Type RtApi :: openStream( RtAudio::StreamParameters *oParams,
if ( oParams && oParams->nChannels < 1 ) {
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 ) {
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 ) {
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 ) {
errorText_ = "RtApi::openStream: 'format' parameter value is undefined.";
- return error( RtAudioError::INVALID_USE );
- //return;
+ return error( RTAUDIO_INVALID_USE );
}
unsigned int nDevices = getDeviceCount();
@@ -357,8 +348,7 @@ RtAudioError::Type RtApi :: openStream( RtAudio::StreamParameters *oParams,
oChannels = oParams->nChannels;
if ( oParams->deviceId >= nDevices ) {
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;
if ( iParams->deviceId >= nDevices ) {
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,
sampleRate, format, bufferFrames, options );
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 );
if ( result == false ) {
if ( oChannels > 0 ) closeStream();
- return error( RtAudioError::SYSTEM_ERROR );
- //return;
+ return error( RTAUDIO_SYSTEM_ERROR );
}
}
stream_.callbackInfo.callback = (void *) callback;
stream_.callbackInfo.userData = userData;
- //stream_.callbackInfo.errorCallback = (void *) errorCallback;
if ( options ) options->numberOfBuffers = stream_.nBuffers;
stream_.state = STREAM_STOPPED;
- return RtAudioError::NO_ERROR;
+ return RTAUDIO_NO_ERROR;
}
unsigned int RtApi :: getDefaultInputDevice( void )
@@ -482,8 +468,6 @@ double RtApi :: getStreamTime( void )
void RtApi :: setStreamTime( double time )
{
- // verifyStream();
-
if ( time >= 0.0 )
stream_.streamTime = time;
/*
@@ -495,7 +479,6 @@ void RtApi :: setStreamTime( double time )
unsigned int RtApi :: getStreamSampleRate( void )
{
- //verifyStream();
if ( isStreamOpen() ) return stream_.sampleRate;
else return 0;
}
@@ -557,7 +540,7 @@ RtApiCore:: RtApiCore()
OSStatus result = AudioObjectSetPropertyData( kAudioObjectSystemObject, &property, 0, NULL, sizeof(CFRunLoopRef), &theRunLoop);
if ( result != noErr ) {
errorText_ = "RtApiCore::RtApiCore: error setting run loop property!";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_SYSTEM_ERROR );
}
#endif
}
@@ -578,7 +561,7 @@ unsigned int RtApiCore :: getDeviceCount( void )
OSStatus result = AudioObjectGetPropertyDataSize( kAudioObjectSystemObject, &propertyAddress, 0, NULL, &dataSize );
if ( result != noErr ) {
errorText_ = "RtApiCore::getDeviceCount: OS-X error getting device info!";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_SYSTEM_ERROR );
return 0;
}
@@ -596,7 +579,7 @@ unsigned int RtApiCore :: getDefaultInputDevice( void )
OSStatus result = AudioObjectGetPropertyData( kAudioObjectSystemObject, &property, 0, NULL, &dataSize, &id );
if ( result != noErr ) {
errorText_ = "RtApiCore::getDefaultInputDevice: OS-X system error getting device.";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_SYSTEM_ERROR );
return 0;
}
@@ -606,7 +589,7 @@ unsigned int RtApiCore :: getDefaultInputDevice( void )
result = AudioObjectGetPropertyData( kAudioObjectSystemObject, &property, 0, NULL, &dataSize, (void *) &deviceList );
if ( result != noErr ) {
errorText_ = "RtApiCore::getDefaultInputDevice: OS-X system error getting device IDs.";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_SYSTEM_ERROR );
return 0;
}
@@ -614,7 +597,7 @@ unsigned int RtApiCore :: getDefaultInputDevice( void )
if ( id == deviceList[i] ) return i;
errorText_ = "RtApiCore::getDefaultInputDevice: No default device found!";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return 0;
}
@@ -629,7 +612,7 @@ unsigned int RtApiCore :: getDefaultOutputDevice( void )
OSStatus result = AudioObjectGetPropertyData( kAudioObjectSystemObject, &property, 0, NULL, &dataSize, &id );
if ( result != noErr ) {
errorText_ = "RtApiCore::getDefaultOutputDevice: OS-X system error getting device.";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_SYSTEM_ERROR );
return 0;
}
@@ -639,7 +622,7 @@ unsigned int RtApiCore :: getDefaultOutputDevice( void )
result = AudioObjectGetPropertyData( kAudioObjectSystemObject, &property, 0, NULL, &dataSize, (void *) &deviceList );
if ( result != noErr ) {
errorText_ = "RtApiCore::getDefaultOutputDevice: OS-X system error getting device IDs.";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_SYSTEM_ERROR );
return 0;
}
@@ -647,7 +630,7 @@ unsigned int RtApiCore :: getDefaultOutputDevice( void )
if ( id == deviceList[i] ) return i;
errorText_ = "RtApiCore::getDefaultOutputDevice: No default device found!";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return 0;
}
@@ -660,13 +643,13 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
unsigned int nDevices = getDeviceCount();
if ( nDevices == 0 ) {
errorText_ = "RtApiCore::getDeviceInfo: no devices found!";
- error( RtAudioError::INVALID_USE );
+ error( RTAUDIO_INVALID_USE );
return info;
}
if ( device >= nDevices ) {
errorText_ = "RtApiCore::getDeviceInfo: device ID is invalid!";
- error( RtAudioError::INVALID_USE );
+ error( RTAUDIO_INVALID_USE );
return info;
}
@@ -679,7 +662,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
0, NULL, &dataSize, (void *) &deviceList );
if ( result != noErr ) {
errorText_ = "RtApiCore::getDeviceInfo: OS-X system error getting device IDs.";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return info;
}
@@ -694,7 +677,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
if ( result != noErr ) {
errorStream_ << "RtApiCore::probeDeviceInfo: system error (" << getErrorCode( result ) << ") getting device manufacturer.";
errorText_ = errorStream_.str();
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return info;
}
@@ -716,7 +699,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
if ( result != noErr ) {
errorStream_ << "RtApiCore::probeDeviceInfo: system error (" << getErrorCode( result ) << ") getting device name.";
errorText_ = errorStream_.str();
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return info;
}
@@ -742,7 +725,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
if ( result != noErr || dataSize == 0 ) {
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting output stream configuration info for device (" << device << ").";
errorText_ = errorStream_.str();
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return info;
}
@@ -750,7 +733,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
bufferList = (AudioBufferList *) malloc( dataSize );
if ( bufferList == NULL ) {
errorText_ = "RtApiCore::getDeviceInfo: memory error allocating output AudioBufferList.";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return info;
}
@@ -759,7 +742,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
free( bufferList );
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting output stream configuration for device (" << device << ").";
errorText_ = errorStream_.str();
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return info;
}
@@ -775,7 +758,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
if ( result != noErr || dataSize == 0 ) {
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting input stream configuration info for device (" << device << ").";
errorText_ = errorStream_.str();
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return info;
}
@@ -783,7 +766,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
bufferList = (AudioBufferList *) malloc( dataSize );
if ( bufferList == NULL ) {
errorText_ = "RtApiCore::getDeviceInfo: memory error allocating input AudioBufferList.";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return info;
}
@@ -792,7 +775,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
free( bufferList );
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting input stream configuration for device (" << device << ").";
errorText_ = errorStream_.str();
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return info;
}
@@ -817,7 +800,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
if ( result != kAudioHardwareNoError || dataSize == 0 ) {
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting sample rate info.";
errorText_ = errorStream_.str();
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return info;
}
@@ -827,7 +810,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
if ( result != kAudioHardwareNoError ) {
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting sample rates.";
errorText_ = errorStream_.str();
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return info;
}
@@ -874,7 +857,7 @@ RtAudio::DeviceInfo RtApiCore :: getDeviceInfo( unsigned int device )
if ( info.sampleRates.size() == 0 ) {
errorStream_ << "RtApiCore::probeDeviceInfo: No supported sample rates found for device (" << device << ").";
errorText_ = errorStream_.str();
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return info;
}
@@ -1299,7 +1282,7 @@ bool RtApiCore :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigne
else {
errorStream_ << "RtApiCore::probeDeviceOpen: system error (" << getErrorCode( result ) << ") getting device latency for device (" << device << ").";
errorText_ = errorStream_.str();
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
}
}
@@ -1477,7 +1460,7 @@ void RtApiCore :: closeStream( void )
{
if ( stream_.state == STREAM_CLOSED ) {
errorText_ = "RtApiCore::closeStream(): no open stream to close!";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return;
}
@@ -1491,12 +1474,12 @@ void RtApiCore :: closeStream( void )
property.mSelector = kAudioDeviceProcessorOverload;
if (AudioObjectRemovePropertyListener( handle->id[0], &property, xrunListener, (void *) handle ) != noErr) {
errorText_ = "RtApiCore::closeStream(): error removing xrun property listener!";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
}
property.mSelector = kAudioDevicePropertyDeviceIsAlive;
if (AudioObjectRemovePropertyListener( handle->id[0], &property, disconnectListener, (void *) &stream_.callbackInfo ) != noErr) {
errorText_ = "RtApiCore::closeStream(): error removing disconnect property listener!";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
}
}
if ( stream_.state == STREAM_RUNNING )
@@ -1518,12 +1501,12 @@ void RtApiCore :: closeStream( void )
property.mSelector = kAudioDeviceProcessorOverload;
if (AudioObjectRemovePropertyListener( handle->id[1], &property, xrunListener, (void *) handle ) != noErr) {
errorText_ = "RtApiCore::closeStream(): error removing xrun property listener!";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
}
property.mSelector = kAudioDevicePropertyDeviceIsAlive;
if (AudioObjectRemovePropertyListener( handle->id[1], &property, disconnectListener, (void *) &stream_.callbackInfo ) != noErr) {
errorText_ = "RtApiCore::closeStream(): error removing disconnect property listener!";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
}
}
if ( stream_.state == STREAM_RUNNING )
@@ -1557,7 +1540,7 @@ void RtApiCore :: closeStream( void )
CallbackInfo *info = (CallbackInfo *) &stream_.callbackInfo;
if ( info->deviceDisconnected ) {
errorText_ = "RtApiCore: the stream device was disconnected (and closed)!";
- error( RtAudioError::DEVICE_DISCONNECT );
+ error( RTAUDIO_DEVICE_DISCONNECT );
}
clearStreamInfo();
@@ -1565,17 +1548,14 @@ void RtApiCore :: closeStream( void )
//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_RUNNING )
errorText_ = "RtApiCore::startStream(): the stream is already running!";
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_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->internalDrain = false;
stream_.state = STREAM_RUNNING;
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_STOPPED )
errorText_ = "RtApiCore::stopStream(): the stream is already stopped!";
else if ( stream_.state == STREAM_CLOSED )
errorText_ = "RtApiCore::stopStream(): the stream is closed!";
- return error( RtAudioError::WARNING );
- //return;
+ return error( RTAUDIO_WARNING );
}
OSStatus result = noErr;
@@ -1665,20 +1641,18 @@ RtAudioError::Type RtApiCore :: stopStream( void )
stream_.state = STREAM_STOPPED;
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_STOPPED )
errorText_ = "RtApiCore::abortStream(): the stream is already stopped!";
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED )
errorText_ = "RtApiCore::abortStream(): the stream is stopping or closed!";
- return error( RtAudioError::WARNING );
+ return error( RTAUDIO_WARNING );
//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_CLOSED ) {
errorText_ = "RtApiCore::callbackEvent(): the stream is closed ... this shouldn't happen!";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return FAILURE;
}
@@ -2119,7 +2093,7 @@ RtAudio::DeviceInfo RtApiJack :: getDeviceInfo( unsigned int device )
jack_client_t *client = jack_client_open( "RtApiJackInfo", options, status );
if ( client == 0 ) {
errorText_ = "RtApiJack::getDeviceInfo: Jack server not found or connection error!";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return info;
}
@@ -2623,7 +2597,7 @@ void RtApiJack :: startStream( void )
unlock:
if ( result == 0 ) return;
- error( RtAudioError::SYSTEM_ERROR );
+ error( RtAudioError::RTAUDIO_SYSTEM_ERROR );
}
void RtApiJack :: stopStream( void )
@@ -9987,13 +9961,12 @@ static void *ossCallbackHandler( void *ptr )
// This method can be modified to control the behavior of error
// 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
// 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_ ) {
const std::string errorMessage = errorText_;
@@ -10029,7 +10002,6 @@ void RtApi :: clearStreamInfo()
stream_.callbackInfo.callback = 0;
stream_.callbackInfo.userData = 0;
stream_.callbackInfo.isRunning = false;
- //stream_.callbackInfo.errorCallback = 0;
for ( int i=0; i<2; i++ ) {
stream_.device[i] = 11111;
stream_.doConvertBuffer[i] = false;
@@ -10065,7 +10037,7 @@ unsigned int RtApi :: formatBytes( RtAudioFormat format )
return 1;
errorText_ = "RtApi::formatBytes: undefined format.";
- error( RtAudioError::WARNING );
+ error( RTAUDIO_WARNING );
return 0;
}
diff --git a/RtAudio.h b/RtAudio.h
index 9e02ed6..ca08bc4 100644
--- a/RtAudio.h
+++ b/RtAudio.h
@@ -46,7 +46,7 @@
#ifndef __RTAUDIO_H
#define __RTAUDIO_H
-#define RTAUDIO_VERSION "5.1.0"
+#define RTAUDIO_VERSION "6.0.0beta1"
#if defined _WIN32 || defined __CYGWIN__
#if defined(RTAUDIO_EXPORT)
@@ -64,7 +64,7 @@
#include <string>
#include <vector>
-#include <stdexcept>
+//#include <stdexcept>
#include <iostream>
/*! \typedef typedef unsigned long RtAudioFormat;
@@ -208,51 +208,65 @@ typedef int (*RtAudioCallback)( void *outputBuffer, void *inputBuffer,
/************************************************************************/
/*! \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
- "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.
@@ -260,7 +274,7 @@ class RTAUDIO_DLL_PUBLIC RtAudioError : public std::runtime_error
\param type Type of error.
\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.
/*!
-
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 );
@@ -493,10 +509,10 @@ class RTAUDIO_DLL_PUBLIC RtAudio
//! 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
- 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
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
lowest allowable value is used. The actual value used is
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,
RtAudioFormat format, unsigned int sampleRate,
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.
/*!
- 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 );
//! 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.
*/
- //void startStream( void );
- RtAudioError::Type startStream( void );
+ RtAudioErrorType startStream( void );
//! 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.
*/
- //void stopStream( void );
- RtAudioError::Type stopStream( void );
+ RtAudioErrorType stopStream( void );
//! 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.
*/
- //void abortStream( void );
- RtAudioError::Type abortStream( void );
+ RtAudioErrorType abortStream( void );
//! Returns true if a stream is open and false if not.
bool isStreamOpen( void ) const;
@@ -580,14 +591,11 @@ class RTAUDIO_DLL_PUBLIC RtAudio
//! 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 );
//! 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 );
//! 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
caused by internal buffering by the audio system and/or hardware.
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 );
@@ -662,7 +670,6 @@ struct CallbackInfo {
ThreadHandle thread;
void *callback;
void *userData;
- // void *errorCallback;
void *apiInfo; // void pointer for API specific callback information
bool isRunning;
bool doRealtime;
@@ -671,7 +678,7 @@ struct CallbackInfo {
// Default constructor.
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 unsigned int getDefaultInputDevice( 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,
RtAudioFormat format, unsigned int sampleRate,
unsigned int *bufferFrames, RtAudioCallback callback,
- void *userData, RtAudio::StreamOptions *options ); //, RtAudioErrorCallback errorCallback );
+ void *userData, RtAudio::StreamOptions *options );
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 );
- unsigned int getStreamSampleRate( void ); // const { return stream_.sampleRate; }
+ unsigned int getStreamSampleRate( void );
virtual double getStreamTime( void ) const { return stream_.streamTime; }
virtual void setStreamTime( double time );
bool isStreamOpen( void ) const { return stream_.state != STREAM_CLOSED; }
@@ -832,7 +835,6 @@ protected:
RtAudioErrorCallback errorCallback_;
bool showWarnings_;
RtApiStream stream_;
- //bool firstErrorOccurred_;
/*!
Protected, api-specific method that attempts to open a device
@@ -856,11 +858,10 @@ protected:
Protected common method that throws an RtAudioError (type =
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.
- //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
@@ -891,11 +892,11 @@ inline unsigned int RtAudio :: getDefaultInputDevice( void ) { return rtapi_->ge
inline unsigned int RtAudio :: getDefaultOutputDevice( void ) { return rtapi_->getDefaultOutputDevice(); }
inline void RtAudio :: closeStream( void ) { return rtapi_->closeStream(); }
//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 :: 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 :: isStreamRunning( void ) const { return rtapi_->isStreamRunning(); }
inline long RtAudio :: getStreamLatency( void ) { return rtapi_->getStreamLatency(); }
@@ -923,12 +924,9 @@ public:
unsigned int getDefaultOutputDevice( void );
unsigned int getDefaultInputDevice( 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
// public because it is called by the internal callback handler,
@@ -1197,14 +1195,14 @@ class RtApiDummy: public RtApi
{
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; }
unsigned int getDeviceCount( void ) { return 0; }
RtAudio::DeviceInfo getDeviceInfo( unsigned int /*device*/ ) { RtAudio::DeviceInfo info; return info; }
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:
diff --git a/configure.ac b/configure.ac
index 43c054a..f667fe1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
# 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_SRCDIR(RtAudio.cpp)
AC_CONFIG_FILES([rtaudio.pc Makefile tests/Makefile doc/Makefile doc/doxygen/Doxyfile])
diff --git a/tests/playsaw.cpp b/tests/playsaw.cpp
index e875313..56e693f 100644
--- a/tests/playsaw.cpp
+++ b/tests/playsaw.cpp
@@ -64,7 +64,7 @@ void usage( void ) {
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.
std::cerr << "\nerrorCallback: " << errorText << "\n\n";