{
if ( stream_.state != STREAM_CLOSED ) {
errorText_ = "RtApi::openStream: a stream is already open!";
- error( INVALID_CALL );
+ error( RtError::INVALID_USE );
}
if ( oParams && oParams->nChannels < 1 ) {
errorText_ = "RtApi::openStream: a non-NULL output StreamParameters structure cannot have an nChannels value less than one.";
- error( INVALID_CALL );
+ error( RtError::INVALID_USE );
}
if ( iParams && iParams->nChannels < 1 ) {
errorText_ = "RtApi::openStream: a non-NULL input StreamParameters structure cannot have an nChannels value less than one.";
- error( INVALID_CALL );
+ error( RtError::INVALID_USE );
}
if ( oParams == NULL && iParams == NULL ) {
errorText_ = "RtApi::openStream: input and output StreamParameters structures are both NULL!";
- error( INVALID_CALL );
+ error( RtError::INVALID_USE );
}
if ( formatBytes(format) == 0 ) {
errorText_ = "RtApi::openStream: 'format' parameter value is undefined.";
- error( INVALID_CALL );
+ error( RtError::INVALID_USE );
}
unsigned int nDevices = getDeviceCount();
oChannels = oParams->nChannels;
if ( oParams->deviceId >= nDevices ) {
errorText_ = "RtApi::openStream: output device parameter value is invalid.";
- error( INVALID_CALL );
+ error( RtError::INVALID_USE );
}
}
iChannels = iParams->nChannels;
if ( iParams->deviceId >= nDevices ) {
errorText_ = "RtApi::openStream: input device parameter value is invalid.";
- error( INVALID_CALL );
+ error( RtError::INVALID_USE );
}
}
result = probeDeviceOpen( oParams->deviceId, OUTPUT, oChannels, oParams->firstChannel,
sampleRate, format, bufferFrames, options );
- if ( result == false ) error( SYSTEM );
+ if ( result == false ) error( RtError::SYSTEM_ERROR );
}
if ( iChannels > 0 ) {
sampleRate, format, bufferFrames, options );
if ( result == false ) {
if ( oChannels > 0 ) closeStream();
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
}
OSStatus result = AudioHardwareGetPropertyInfo( kAudioHardwarePropertyDevices, &dataSize, NULL );
if ( result != noErr ) {
errorText_ = "RtApiCore::getDeviceCount: OS-X error getting device info!";
- error( WARNING );
+ error( RtError::WARNING );
return 0;
}
if ( result != noErr ) {
errorText_ = "RtApiCore::getDefaultInputDevice: OS-X system error getting device.";
- error( WARNING );
+ error( RtError::WARNING );
return 0;
}
result = AudioHardwareGetProperty( kAudioHardwarePropertyDevices, &dataSize, (void *) &deviceList );
if ( result != noErr ) {
errorText_ = "RtApiCore::getDefaultInputDevice: OS-X system error getting device IDs.";
- error( WARNING );
+ error( RtError::WARNING );
return 0;
}
if ( id == deviceList[i] ) return i;
errorText_ = "RtApiCore::getDefaultInputDevice: No default device found!";
- error( WARNING );
+ error( RtError::WARNING );
return 0;
}
if ( result != noErr ) {
errorText_ = "RtApiCore::getDefaultOutputDevice: OS-X system error getting device.";
- error( WARNING );
+ error( RtError::WARNING );
return 0;
}
result = AudioHardwareGetProperty( kAudioHardwarePropertyDevices, &dataSize, (void *) &deviceList );
if ( result != noErr ) {
errorText_ = "RtApiCore::getDefaultOutputDevice: OS-X system error getting device IDs.";
- error( WARNING );
+ error( RtError::WARNING );
return 0;
}
if ( id == deviceList[i] ) return i;
errorText_ = "RtApiCore::getDefaultOutputDevice: No default device found!";
- error( WARNING );
+ error( RtError::WARNING );
return 0;
}
unsigned int nDevices = getDeviceCount();
if ( nDevices == 0 ) {
errorText_ = "RtApiCore::getDeviceInfo: no devices found!";
- error( INVALID_CALL );
+ error( RtError::INVALID_USE );
}
if ( device >= nDevices ) {
errorText_ = "RtApiCore::getDeviceInfo: device ID is invalid!";
- error( INVALID_CALL );
+ error( RtError::INVALID_USE );
}
AudioDeviceID deviceList[ nDevices ];
OSStatus result = AudioHardwareGetProperty( kAudioHardwarePropertyDevices, &dataSize, (void *) &deviceList );
if ( result != noErr ) {
errorText_ = "RtApiCore::getDeviceInfo: OS-X system error getting device IDs.";
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
if ( result != noErr ) {
errorStream_ << "RtApiCore::probeDeviceInfo: system error (" << getErrorCode( result ) << ") getting device manufacturer.";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
info.name.append( (const char *)name, strlen(name) + 1 );
if ( result != noErr ) {
errorStream_ << "RtApiCore::probeDeviceInfo: system error (" << getErrorCode( result ) << ") getting device name.";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
info.name.append( (const char *)name, strlen(name) + 1 );
if (result != noErr || dataSize == 0) {
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting output stream configuration info for device (" << device << ").";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
bufferList = (AudioBufferList *) malloc( dataSize );
if ( bufferList == NULL ) {
errorText_ = "RtApiCore::getDeviceInfo: memory error allocating output AudioBufferList.";
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
free( bufferList );
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting output stream configuration for device (" << device << ").";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
if (result != noErr || dataSize == 0) {
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting input stream configuration info for device (" << device << ").";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
bufferList = (AudioBufferList *) malloc( dataSize );
if ( bufferList == NULL ) {
errorText_ = "RtApiCore::getDeviceInfo: memory error allocating input AudioBufferList.";
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
free( bufferList );
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting input stream configuration for device (" << device << ").";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
if ( result != kAudioHardwareNoError || dataSize == 0 ) {
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting sample rate info.";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
if ( result != kAudioHardwareNoError ) {
errorStream_ << "RtApiCore::getDeviceInfo: system error (" << getErrorCode( result ) << ") getting sample rates.";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
if ( info.sampleRates.size() == 0 ) {
errorStream_ << "RtApiCore::probeDeviceInfo: No supported sample rates found for device (" << device << ").";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
else {
errorStream_ << "RtApiCore::probeDeviceOpen: system error (" << getErrorCode( result ) << ") getting device latency for device (" << device << ").";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
}
}
else {
errorStream_ << "RtApiCore::probeDeviceOpen: system error (" << getErrorCode( result ) << ") getting stream latency for device (" << device << ").";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
}
// Byte-swapping: According to AudioHardware.h, the stream data will
{
if ( stream_.state == STREAM_CLOSED ) {
errorText_ = "RtApiCore::closeStream(): no open stream to close!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
verifyStream();
if ( stream_.state == STREAM_RUNNING ) {
errorText_ = "RtApiCore::startStream(): the stream is already running!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
MUTEX_UNLOCK( &stream_.mutex );
if ( result == noErr ) return;
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
void RtApiCore :: stopStream( void )
verifyStream();
if ( stream_.state == STREAM_STOPPED ) {
errorText_ = "RtApiCore::stopStream(): the stream is already stopped!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
stream_.state = STREAM_STOPPED;
if ( result == noErr ) return;
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
void RtApiCore :: abortStream( void )
verifyStream();
if ( stream_.state == STREAM_STOPPED ) {
errorText_ = "RtApiCore::abortStream(): the stream is already stopped!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
if ( stream_.state == STREAM_STOPPED ) return SUCCESS;
if ( stream_.state == STREAM_CLOSED ) {
errorText_ = "RtApiCore::callbackEvent(): the stream is closed ... this shouldn't happen!";
- error( WARNING );
+ error( RtError::WARNING );
return FAILURE;
}
jack_client_t *client = jack_client_new( "RtApiJackInfo" );
if ( client == 0 ) {
errorText_ = "RtApiJack::getDeviceInfo: Jack server not found or connection error!";
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
if ( device >= nDevices ) {
errorText_ = "RtApiJack::getDeviceInfo: device ID is invalid!";
- error( INVALID_CALL );
+ error( RtError::INVALID_USE );
}
// Get the current jack server sample rate.
if ( info.outputChannels == 0 && info.inputChannels == 0 ) {
jack_client_close(client);
errorText_ = "RtApiJack::getDeviceInfo: error determining Jack input/output channels!";
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
client = jack_client_new( "RtApiJack" );
if ( client == 0 ) {
errorText_ = "RtApiJack::probeDeviceOpen: Jack server not found or connection error!";
- error( WARNING );
+ error( RtError::WARNING );
return FAILURE;
}
}
{
if ( stream_.state == STREAM_CLOSED ) {
errorText_ = "RtApiJack::closeStream(): no open stream to close!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
verifyStream();
if ( stream_.state == STREAM_RUNNING ) {
errorText_ = "RtApiJack::startStream(): the stream is already running!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
MUTEX_UNLOCK(&stream_.mutex);
if ( result == 0 ) return;
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
void RtApiJack :: stopStream( void )
verifyStream();
if ( stream_.state == STREAM_STOPPED ) {
errorText_ = "RtApiJack::stopStream(): the stream is already stopped!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
verifyStream();
if ( stream_.state == STREAM_STOPPED ) {
errorText_ = "RtApiJack::abortStream(): the stream is already stopped!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
if ( stream_.state == STREAM_STOPPED ) return SUCCESS;
if ( stream_.state == STREAM_CLOSED ) {
errorText_ = "RtApiCore::callbackEvent(): the stream is closed ... this shouldn't happen!";
- error( WARNING );
+ error( RtError::WARNING );
return FAILURE;
}
if ( stream_.bufferSize != nframes ) {
errorText_ = "RtApiCore::callbackEvent(): the JACK buffer size has changed ... cannot process!";
- error( WARNING );
+ error( RtError::WARNING );
return FAILURE;
}
HRESULT hr = CoInitialize( NULL );
if ( FAILED(hr) ) {
errorText_ = "RtApiAsio::ASIO requires a single-threaded appartment. Call CoInitializeEx(0,COINIT_APARTMENTTHREADED)";
- error( WARNING );
+ error( RtError::WARNING );
}
coInitialized_ = true;
unsigned int nDevices = getDeviceCount();
if ( nDevices == 0 ) {
errorText_ = "RtApiAsio::getDeviceInfo: no devices found!";
- error( INVALID_CALL );
+ error( RtError::INVALID_USE );
}
if ( device >= nDevices ) {
errorText_ = "RtApiAsio::getDeviceInfo: device ID is invalid!";
- error( INVALID_CALL );
+ error( RtError::INVALID_USE );
}
// Don't probe if a stream is already open.
if ( stream_.state != STREAM_CLOSED ) {
errorText_ = "RtApiAsio::getDeviceInfo: unable to probe driver while a stream is open.";
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
if ( result != ASE_OK ) {
errorStream_ << "RtApiAsio::getDeviceInfo: unable to get driver name (" << getAsioErrorString( result ) << ").";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
if ( !drivers.loadDriver( driverName ) ) {
errorStream_ << "RtApiAsio::getDeviceInfo: unable to load driver (" << driverName << ").";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
if ( result != ASE_OK ) {
errorStream_ << "RtApiAsio::getDeviceInfo: error (" << getAsioErrorString( result ) << ") initializing driver (" << driverName << ").";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
drivers.removeCurrentDriver();
errorStream_ << "RtApiAsio::getDeviceInfo: error (" << getAsioErrorString( result ) << ") getting channel count (" << driverName << ").";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
drivers.removeCurrentDriver();
errorStream_ << "RtApiAsio::getDeviceInfo: error (" << getAsioErrorString( result ) << ") getting driver channel info (" << driverName << ").";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
if ( result != ASE_OK ) {
errorStream_ << "RtApiAsio::probeDeviceOpen: driver (" << driverName << ") error (" << getAsioErrorString( result ) << ") getting latency.";
errorText_ = errorStream_.str();
- error( WARNING); // warn but don't fail
+ error( RtError::WARNING); // warn but don't fail
}
else {
stream_.latency[0] = outputLatency;
{
if ( stream_.state == STREAM_CLOSED ) {
errorText_ = "RtApiAsio::closeStream(): no open stream to close!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
verifyStream();
if ( stream_.state == STREAM_RUNNING ) {
errorText_ = "RtApiAsio::startStream(): the stream is already running!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
MUTEX_UNLOCK( &stream_.mutex );
if ( result == ASE_OK ) return;
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
void RtApiAsio :: stopStream()
verifyStream();
if ( stream_.state == STREAM_STOPPED ) {
errorText_ = "RtApiAsio::stopStream(): the stream is already stopped!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
MUTEX_UNLOCK( &stream_.mutex );
if ( result == ASE_OK ) return;
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
void RtApiAsio :: abortStream()
verifyStream();
if ( stream_.state == STREAM_STOPPED ) {
errorText_ = "RtApiAsio::abortStream(): the stream is already stopped!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
if ( stream_.state == STREAM_STOPPED ) return SUCCESS;
if ( stream_.state == STREAM_CLOSED ) {
errorText_ = "RtApiAsio::callbackEvent(): the stream is closed ... this shouldn't happen!";
- error( WARNING );
+ error( RtError::WARNING );
return FAILURE;
}
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::getDefaultOutputDevice: error (" << getErrorString( result ) << ") counting output devices!";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return 0;
}
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::getDefaultInputDevice: error (" << getErrorString( result ) << ") enumerating input devices!";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return 0;
}
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::getDefaultOutputDevice: error (" << getErrorString( result ) << ") enumerating output devices!";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return 0;
}
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::getDeviceCount: error (" << getErrorString( result ) << ") enumerating output devices!";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
}
// Count DirectSoundCapture devices.
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::getDeviceCount: error (" << getErrorString( result ) << ") enumerating input devices!";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
}
return info.counter;
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::getDeviceInfo: error (" << getErrorString( result ) << ") enumerating output devices!";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
}
if ( dsinfo.name.empty() ) goto probeInput;
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::getDeviceInfo: error (" << getErrorString( result ) << ") opening output device (" << dsinfo.name << ")!";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
output->Release();
errorStream_ << "RtApiDs::getDeviceInfo: error (" << getErrorString( result ) << ") getting capabilities!";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::getDeviceInfo: error (" << getErrorString( result ) << ") enumerating input devices!";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
}
if ( dsinfo.name.empty() ) return info;
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::getDeviceInfo: error (" << getErrorString( result ) << ") opening input device (" << dsinfo.name << ")!";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
input->Release();
errorStream_ << "RtApiDs::getDeviceInfo: error (" << getErrorString( result ) << ") getting object capabilities (" << dsinfo.name << ")!";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
{
if ( stream_.state == STREAM_CLOSED ) {
errorText_ = "RtApiDs::closeStream(): no open stream to close!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
verifyStream();
if ( stream_.state == STREAM_RUNNING ) {
errorText_ = "RtApiDs::startStream(): the stream is already running!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
unlock:
MUTEX_UNLOCK( &stream_.mutex );
- if ( FAILED( result ) ) error( SYSTEM );
+ if ( FAILED( result ) ) error( RtError::SYSTEM_ERROR );
}
void RtApiDs :: stopStream()
verifyStream();
if ( stream_.state == STREAM_STOPPED ) {
errorText_ = "RtApiDs::stopStream(): the stream is already stopped!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
timeEndPeriod( 1 ); // revert to normal scheduler frequency on lesser windows.
stream_.state = STREAM_STOPPED;
MUTEX_UNLOCK( &stream_.mutex );
- if ( FAILED( result ) ) error( SYSTEM );
+ if ( FAILED( result ) ) error( RtError::SYSTEM_ERROR );
}
void RtApiDs :: abortStream()
verifyStream();
if ( stream_.state == STREAM_STOPPED ) {
errorText_ = "RtApiDs::abortStream(): the stream is already stopped!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
if ( stream_.state == STREAM_CLOSED ) {
errorText_ = "RtApiDs::callbackEvent(): the stream is closed ... this shouldn't happen!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") getting current write position!";
errorText_ = errorStream_.str();
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
result = dsCaptureBuffer->GetCurrentPosition( &initialReadPos, &initialSafeReadPos );
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") getting current read position!";
errorText_ = errorStream_.str();
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
while ( true ) {
result = dsWriteBuffer->GetCurrentPosition( ¤tWritePos, &safeWritePos );
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") getting current write position!";
errorText_ = errorStream_.str();
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
result = dsCaptureBuffer->GetCurrentPosition( ¤tReadPos, &safeReadPos );
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") getting current read position!";
errorText_ = errorStream_.str();
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
if ( safeWritePos != initialSafeWritePos && safeReadPos != initialSafeReadPos ) break;
Sleep( 1 );
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") getting current write position!";
errorText_ = errorStream_.str();
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
leadPos = safeWritePos + handle->dsPointerLeadTime[0];
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") locking buffer during playback!";
errorText_ = errorStream_.str();
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
// Copy our buffer into the DS buffer
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") unlocking buffer during playback!";
errorText_ = errorStream_.str();
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
nextWritePos = ( nextWritePos + bufferSize1 + bufferSize2 ) % dsBufferSize;
handle->bufferPointer[0] = nextWritePos;
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") getting current read position!";
errorText_ = errorStream_.str();
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
if ( safeReadPos < (DWORD)nextReadPos ) safeReadPos += dsBufferSize; // unwrap offset
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") getting current read position!";
errorText_ = errorStream_.str();
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
if ( safeReadPos < (DWORD)nextReadPos ) safeReadPos += dsBufferSize; // unwrap offset
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") locking capture buffer!";
errorText_ = errorStream_.str();
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
if ( duplexPrerollBytes <= 0 ) {
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::callbackEvent: error (" << getErrorString( result ) << ") unlocking capture buffer!";
errorText_ = errorStream_.str();
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
handle->bufferPointer[1] = nextReadPos;
if ( result < 0 ) {
errorStream_ << "RtApiAlsa::getDeviceCount: control open, card = " << card << ", " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
goto nextcard;
}
subdevice = -1;
if ( result < 0 ) {
errorStream_ << "RtApiAlsa::getDeviceCount: control next device, card = " << card << ", " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
break;
}
if ( subdevice < 0 )
if ( result < 0 ) {
errorStream_ << "RtApiAlsa::getDeviceInfo: control open, card = " << card << ", " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
goto nextcard;
}
subdevice = -1;
if ( result < 0 ) {
errorStream_ << "RtApiAlsa::getDeviceInfo: control next device, card = " << card << ", " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
break;
}
if ( subdevice < 0 ) break;
if ( nDevices == 0 ) {
errorText_ = "RtApiAlsa::getDeviceInfo: no devices found!";
- error( INVALID_CALL );
+ error( RtError::INVALID_USE );
}
if ( device >= nDevices ) {
errorText_ = "RtApiAlsa::getDeviceInfo: device ID is invalid!";
- error( INVALID_CALL );
+ error( RtError::INVALID_USE );
}
foundDevice:
if ( result < 0 ) {
errorStream_ << "RtApiAlsa::getDeviceInfo: snd_pcm_open error for device (" << name << "), " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
goto captureProbe;
}
snd_pcm_close( phandle );
errorStream_ << "RtApiAlsa::getDeviceInfo: snd_pcm_hw_params error for device (" << name << "), " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
goto captureProbe;
}
snd_pcm_close( phandle );
errorStream_ << "RtApiAlsa::getDeviceInfo: error getting device (" << name << ") output channels, " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
goto captureProbe;
}
info.outputChannels = value;
if ( result < 0 ) {
errorStream_ << "RtApiAlsa::getDeviceInfo: snd_pcm_open error for device (" << name << "), " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
if ( info.outputChannels == 0 ) return info;
goto probeParameters;
}
snd_pcm_close( phandle );
errorStream_ << "RtApiAlsa::getDeviceInfo: snd_pcm_hw_params error for device (" << name << "), " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
if ( info.outputChannels == 0 ) return info;
goto probeParameters;
}
snd_pcm_close( phandle );
errorStream_ << "RtApiAlsa::getDeviceInfo: error getting device (" << name << ") input channels, " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
if ( info.outputChannels == 0 ) return info;
goto probeParameters;
}
if ( result < 0 ) {
errorStream_ << "RtApiAlsa::getDeviceInfo: snd_pcm_open error for device (" << name << "), " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
snd_pcm_close( phandle );
errorStream_ << "RtApiAlsa::getDeviceInfo: snd_pcm_hw_params error for device (" << name << "), " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
snd_pcm_close( phandle );
errorStream_ << "RtApiAlsa::getDeviceInfo: no supported sample rates found for device (" << name << ").";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
if ( info.nativeFormats == 0 ) {
errorStream_ << "RtApiAlsa::getDeviceInfo: pcm device (" << name << ") data format not supported by RtAudio.";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
apiInfo->synchronized = true;
else {
errorText_ = "RtApiAlsa::probeDeviceOpen: unable to synchronize input and output devices.";
- error( WARNING );
+ error( RtError::WARNING );
}
}
else {
{
if ( stream_.state == STREAM_CLOSED ) {
errorText_ = "RtApiAlsa::closeStream(): no open stream to close!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
verifyStream();
if ( stream_.state == STREAM_RUNNING ) {
errorText_ = "RtApiAlsa::startStream(): the stream is already running!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
MUTEX_UNLOCK( &stream_.mutex );
if ( result >= 0 ) return;
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
void RtApiAlsa :: stopStream()
verifyStream();
if ( stream_.state == STREAM_STOPPED ) {
errorText_ = "RtApiAlsa::stopStream(): the stream is already stopped!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
MUTEX_UNLOCK( &stream_.mutex );
if ( result >= 0 ) return;
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
void RtApiAlsa :: abortStream()
verifyStream();
if ( stream_.state == STREAM_STOPPED ) {
errorText_ = "RtApiAlsa::abortStream(): the stream is already stopped!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
stream_.state = STREAM_STOPPED;
if ( result >= 0 ) return;
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
void RtApiAlsa :: callbackEvent()
if ( stream_.state == STREAM_CLOSED ) {
errorText_ = "RtApiAlsa::callbackEvent(): the stream is closed ... this shouldn't happen!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
errorStream_ << "RtApiAlsa::callbackEvent: audio read error, " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
}
- error( WARNING );
+ error( RtError::WARNING );
goto unlock;
}
errorStream_ << "RtApiAlsa::callbackEvent: audio write error, " << snd_strerror( result ) << ".";
errorText_ = errorStream_.str();
}
- error( WARNING );
+ error( RtError::WARNING );
goto unlock;
}
int mixerfd = open( "/dev/mixer", O_RDWR, 0 );
if ( mixerfd == -1 ) {
errorText_ = "RtApiOss::getDeviceCount: error opening '/dev/mixer'.";
- error( WARNING );
+ error( RtError::WARNING );
return 0;
}
if ( ioctl( mixerfd, SNDCTL_SYSINFO, &sysinfo ) == -1 ) {
close( mixerfd );
errorText_ = "RtApiOss::getDeviceCount: error getting sysinfo, OSS version >= 4.0 is required.";
- error( WARNING );
+ error( RtError::WARNING );
return 0;
}
int mixerfd = open( "/dev/mixer", O_RDWR, 0 );
if ( mixerfd == -1 ) {
errorText_ = "RtApiOss::getDeviceInfo: error opening '/dev/mixer'.";
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
if ( result == -1 ) {
close( mixerfd );
errorText_ = "RtApiOss::getDeviceInfo: error getting sysinfo, OSS version >= 4.0 is required.";
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
if ( nDevices == 0 ) {
close( mixerfd );
errorText_ = "RtApiOss::getDeviceInfo: no devices found!";
- error( INVALID_CALL );
+ error( RtError::INVALID_USE );
}
if ( device >= nDevices ) {
close( mixerfd );
errorText_ = "RtApiOss::getDeviceInfo: device ID is invalid!";
- error( INVALID_CALL );
+ error( RtError::INVALID_USE );
}
oss_audioinfo ainfo;
if ( result == -1 ) {
errorStream_ << "RtApiOss::getDeviceInfo: error getting device (" << ainfo.name << ") info.";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
if ( info.nativeFormats == 0 ) {
errorStream_ << "RtApiOss::getDeviceInfo: device (" << ainfo.name << ") data format not supported by RtAudio.";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return info;
}
if ( info.sampleRates.size() == 0 ) {
errorStream_ << "RtApiOss::getDeviceInfo: no supported sample rates found for device (" << ainfo.name << ").";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
}
else {
info.probed = true;
{
if ( stream_.state == STREAM_CLOSED ) {
errorText_ = "RtApiOss::closeStream(): no open stream to close!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
verifyStream();
if ( stream_.state == STREAM_RUNNING ) {
errorText_ = "RtApiOss::startStream(): the stream is already running!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
verifyStream();
if ( stream_.state == STREAM_STOPPED ) {
errorText_ = "RtApiOss::stopStream(): the stream is already stopped!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
result = write( handle->id[0], buffer, samples * formatBytes(format) );
if ( result == -1 ) {
errorText_ = "RtApiOss::stopStream: audio write error.";
- error( WARNING );
+ error( RtError::WARNING );
}
}
stream_.state = STREAM_STOPPED;
if ( result != -1 ) return;
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
void RtApiOss :: abortStream()
verifyStream();
if ( stream_.state == STREAM_STOPPED ) {
errorText_ = "RtApiOss::abortStream(): the stream is already stopped!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
stream_.state = STREAM_STOPPED;
if ( result != -1 ) return;
- error( SYSTEM );
+ error( RtError::SYSTEM_ERROR );
}
void RtApiOss :: callbackEvent()
if ( stream_.state == STREAM_CLOSED ) {
errorText_ = "RtApiOss::callbackEvent(): the stream is closed ... this shouldn't happen!";
- error( WARNING );
+ error( RtError::WARNING );
return;
}
// specific means for determining that.
handle->xrun[0] = true;
errorText_ = "RtApiOss::callbackEvent: audio write error.";
- error( WARNING );
+ error( RtError::WARNING );
goto unlock;
}
}
// specific means for determining that.
handle->xrun[1] = true;
errorText_ = "RtApiOss::callbackEvent: audio read error.";
- error( WARNING );
+ error( RtError::WARNING );
goto unlock;
}
// This method can be modified to control the behavior of error
// message printing.
-void RtApi :: error( ErrorType type )
+void RtApi :: error( RtError::Type type )
{
- if ( type == WARNING && showWarnings_ == true )
+ if ( type == RtError::RtError::WARNING && showWarnings_ == true )
std::cerr << '\n' << errorText_ << "\n\n";
- else if ( type == INVALID_CALL )
- throw( RtError( errorText_, RtError::INVALID_USE ) );
- else if ( type == SYSTEM )
- throw( RtError( errorText_, RtError::SYSTEM_ERROR ) );
+ else
+ throw( RtError( errorText_, type ) );
errorStream_.str(""); // clear the ostringstream
}
{
if ( stream_.state == STREAM_CLOSED ) {
errorText_ = "RtApi:: a stream is not open!";
- error( INVALID_CALL );
+ error( RtError::INVALID_USE );
}
}
return 1;
errorText_ = "RtApi::formatBytes: undefined format.";
- error( WARNING );
+ error( RtError::WARNING );
return 0;
}