*/
/************************************************************************/
-// RtAudio: Version 4.0
+// RtAudio: Version 4.0.3
#include "RtAudio.h"
#include <iostream>
{
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 );
+ info.name.append( (const char *)name, strlen(name) );
info.name.append( ": " );
dataSize = 256;
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 );
+ info.name.append( (const char *)name, strlen(name) );
// Get the output stream "configuration".
AudioBufferList *bufferList = nil;
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;
}
// on information found in
// http://www.cs.wustl.edu/~schmidt/win32-cv-1.html.
-#include "asio/asiosys.h"
-#include "asio/asio.h"
-#include "asio/iasiothiscallresolver.h"
-#include "asio/asiodrivers.h"
+#include "asiosys.h"
+#include "asio.h"
+#include "iasiothiscallresolver.h"
+#include "asiodrivers.h"
#include <cmath>
AsioDrivers drivers;
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 a stream is already open, we cannot probe other devices. Thus, use the saved results.
if ( stream_.state != STREAM_CLOSED ) {
- errorText_ = "RtApiAsio::getDeviceInfo: unable to probe driver while a stream is open.";
- error( WARNING );
- return info;
+ if ( device >= devices_.size() ) {
+ errorText_ = "RtApiAsio::getDeviceInfo: device ID was not present before stream was opened.";
+ error( RtError::WARNING );
+ return info;
+ }
+ return devices_[ device ];
}
char driverName[32];
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;
}
object->callbackEvent( index );
}
+void RtApiAsio :: saveDeviceInfo( void )
+{
+ devices_.clear();
+
+ unsigned int nDevices = getDeviceCount();
+ devices_.resize( nDevices );
+ for ( unsigned int i=0; i<nDevices; i++ )
+ devices_[i] = getDeviceInfo( i );
+}
+
bool RtApiAsio :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned int channels,
unsigned int firstChannel, unsigned int sampleRate,
RtAudioFormat format, unsigned int *bufferSize,
return FAILURE;
}
+ // The getDeviceInfo() function will not work when a stream is open
+ // because ASIO does not allow multiple devices to run at the same
+ // time. Thus, we'll probe the system before opening a stream and
+ // save the results for use by getDeviceInfo().
+ this->saveDeviceInfo();
+
// Only load the driver once for duplex stream.
if ( mode != INPUT || stream_.mode != OUTPUT ) {
if ( !drivers.loadDriver( driverName ) ) {
return FAILURE;
}
- // Set the sample rate.
- result = ASIOSetSampleRate( (ASIOSampleRate) sampleRate );
+ // Get the current sample rate
+ ASIOSampleRate currentRate;
+ result = ASIOGetSampleRate( ¤tRate );
if ( result != ASE_OK ) {
drivers.removeCurrentDriver();
- errorStream_ << "RtApiAsio::probeDeviceOpen: driver (" << driverName << ") error setting sample rate (" << sampleRate << ").";
+ errorStream_ << "RtApiAsio::probeDeviceOpen: driver (" << driverName << ") error getting sample rate.";
errorText_ = errorStream_.str();
return FAILURE;
}
+ // Set the sample rate only if necessary
+ if ( currentRate != sampleRate ) {
+ result = ASIOSetSampleRate( (ASIOSampleRate) sampleRate );
+ if ( result != ASE_OK ) {
+ drivers.removeCurrentDriver();
+ errorStream_ << "RtApiAsio::probeDeviceOpen: driver (" << driverName << ") error setting sample rate (" << sampleRate << ").";
+ errorText_ = errorStream_.str();
+ return FAILURE;
+ }
+ }
+
// Determine the driver data type.
ASIOChannelInfo channelInfo;
channelInfo.channel = 0;
stream_.doConvertBuffer[mode] = true;
// Allocate necessary internal buffers
- unsigned long bufferBytes = stream_.nUserChannels[mode] * *bufferSize * formatBytes( stream_.userFormat );
+ unsigned long bufferBytes;
+ bufferBytes = stream_.nUserChannels[mode] * *bufferSize * formatBytes( stream_.userFormat );
stream_.userBuffer[mode] = (char *) calloc( bufferBytes, 1 );
if ( stream_.userBuffer[mode] == NULL ) {
errorText_ = "RtApiAsio::probeDeviceOpen: error allocating user buffer memory.";
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;
}
handle->internalDrain = true;
}
- unsigned int bufferBytes, i, j;
- unsigned int nChannels = stream_.nDeviceChannels[0] + stream_.nDeviceChannels[1];
+ unsigned int nChannels, bufferBytes, i, j;
+ nChannels = stream_.nDeviceChannels[0] + stream_.nDeviceChannels[1];
if ( stream_.mode == OUTPUT || stream_.mode == DUPLEX ) {
bufferBytes = stream_.bufferSize * formatBytes( stream_.deviceFormat[0] );
#include <dsound.h>
#include <assert.h>
+#if defined(__MINGW32__)
+// missing from latest mingw winapi
+#define WAVE_FORMAT_96M08 0x00010000 /* 96 kHz, Mono, 8-bit */
+#define WAVE_FORMAT_96S08 0x00020000 /* 96 kHz, Stereo, 8-bit */
+#define WAVE_FORMAT_96M16 0x00040000 /* 96 kHz, Mono, 16-bit */
+#define WAVE_FORMAT_96S16 0x00080000 /* 96 kHz, Stereo, 16-bit */
+#endif
+
#define MINIMUM_DEVICE_BUFFER_SIZE 32768
#ifdef _MSC_VER // if Microsoft Visual C++
HANDLE condition;
DsHandle()
- :drainCounter(0), internalDrain(false) { id[0] = 0, id[1] = 0; xrun[0] = false; xrun[1] = false; bufferPointer[0] = 0; bufferPointer[1] = 0; }
+ :drainCounter(0), internalDrain(false) { id[0] = 0; id[1] = 0; buffer[0] = 0; buffer[1] = 0; xrun[0] = false; xrun[1] = false; bufferPointer[0] = 0; bufferPointer[1] = 0; }
};
/*
// Declarations for utility functions, callbacks, and structures
// specific to the DirectSound implementation.
-static bool CALLBACK deviceCountCallback( LPGUID lpguid,
+static BOOL CALLBACK deviceQueryCallback( LPGUID lpguid,
LPCTSTR description,
LPCTSTR module,
LPVOID lpContext );
{
// Count output devices.
EnumInfo info;
- HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &info );
+ HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &info );
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::getDefaultOutputDevice: error (" << getErrorString( result ) << ") counting output devices!";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return 0;
}
// Now enumerate input devices until we find the id = NULL.
info.isInput = true;
info.getDefault = true;
- result = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &info );
+ result = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &info );
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::getDefaultInputDevice: error (" << getErrorString( result ) << ") enumerating input devices!";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return 0;
}
// Enumerate output devices until we find the id = NULL.
EnumInfo info;
info.getDefault = true;
- HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &info );
+ HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &info );
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::getDefaultOutputDevice: error (" << getErrorString( result ) << ") enumerating output devices!";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
return 0;
}
{
// Count DirectSound devices.
EnumInfo info;
- HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &info );
+ HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &info );
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::getDeviceCount: error (" << getErrorString( result ) << ") enumerating output devices!";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
}
// Count DirectSoundCapture devices.
info.isInput = true;
- result = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &info );
+ result = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &info );
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::getDeviceCount: error (" << getErrorString( result ) << ") enumerating input devices!";
errorText_ = errorStream_.str();
- error( WARNING );
+ error( RtError::WARNING );
}
return info.counter;
EnumInfo dsinfo;
dsinfo.findIndex = true;
dsinfo.index = device;
- HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &dsinfo );
+ HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &dsinfo );
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;
}
probeInput:
dsinfo.isInput = true;
- result = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &dsinfo );
+ result = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &dsinfo );
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;
}
EnumInfo dsinfo;
dsinfo.findIndex = true;
dsinfo.index = device;
- HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &dsinfo );
+ HRESULT result = DirectSoundEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &dsinfo );
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::probeDeviceOpen: error (" << getErrorString( result ) << ") enumerating output devices!";
errorText_ = errorStream_.str();
}
else { // mode == INPUT
dsinfo.isInput = true;
- HRESULT result = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK) deviceCountCallback, &dsinfo );
+ HRESULT result = DirectSoundCaptureEnumerate( (LPDSENUMCALLBACK) deviceQueryCallback, &dsinfo );
if ( FAILED( result ) ) {
errorStream_ << "RtApiDs::probeDeviceOpen: error (" << getErrorString( result ) << ") enumerating input devices!";
errorText_ = errorStream_.str();
}
// Set various stream parameters
+ DsHandle *handle = 0;
stream_.nDeviceChannels[mode] = channels + firstChannel;
stream_.nUserChannels[mode] = channels;
stream_.bufferSize = *bufferSize;
}
// Allocate our DsHandle structures for the stream.
- DsHandle *handle;
if ( stream_.apiHandle == 0 ) {
try {
handle = new DsHandle;
{
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;
}
duplexPrerollBytes = (int) ( 0.5 * stream_.sampleRate * formatBytes( stream_.deviceFormat[1] ) * stream_.nDeviceChannels[1] );
}
- HRESULT result;
+ HRESULT result = 0;
if ( stream_.mode == OUTPUT || stream_.mode == DUPLEX ) {
//statistics.outputFrameSize = formatBytes( stream_.deviceFormat[0] ) * stream_.nDeviceChannels[0];
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;
}
MUTEX_LOCK( &stream_.mutex );
- HRESULT result;
+ HRESULT result = 0;
LPVOID audioPtr;
DWORD dataLen;
DsHandle *handle = (DsHandle *) stream_.apiHandle;
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;
return s;
}
-static bool CALLBACK deviceCountCallback( LPGUID lpguid,
+static BOOL CALLBACK deviceQueryCallback( LPGUID lpguid,
LPCTSTR description,
LPCTSTR module,
LPVOID lpContext )
LPDIRECTSOUNDCAPTURE object;
hr = DirectSoundCaptureCreate( lpguid, &object, NULL );
- if ( hr != DS_OK ) return true;
+ if ( hr != DS_OK ) return TRUE;
caps.dwSize = sizeof(caps);
hr = object->GetCaps( &caps );
DSCAPS caps;
LPDIRECTSOUND object;
hr = DirectSoundCreate( lpguid, &object, NULL );
- if ( hr != DS_OK ) return true;
+ if ( hr != DS_OK ) return TRUE;
caps.dwSize = sizeof(caps);
hr = object->GetCaps( &caps );
object->Release();
}
- if ( info->getDefault && lpguid == NULL ) return false;
+ if ( info->getDefault && lpguid == NULL ) return FALSE;
if ( info->findIndex && info->counter > info->index ) {
info->id = lpguid;
info->name = convertTChar( description );
- return false;
+ return FALSE;
}
- return true;
+ return TRUE;
}
static char* getErrorString( int code )
{
- switch (code) {
+ switch ( code ) {
case DSERR_ALLOCATED:
return "Already allocated";
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;
}
#ifdef SCHED_RR
// Set a higher scheduler priority (P.J. Leonard)
struct sched_param param;
- param.sched_priority = 39; // Is this the best number?
+ int min = sched_get_priority_min( SCHED_RR );
+ int max = sched_get_priority_max( SCHED_RR );
+ param.sched_priority = min + ( max - min ) / 2; // Is this the best number?
sched_setscheduler( 0, SCHED_RR, ¶m );
#endif
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
-#include "oss/soundcard.h"
+#include "soundcard.h"
#include <errno.h>
#include <math.h>
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::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;
}