{ "ds" , "DirectSound" },
{ "dummy" , "Dummy" },
};
-const unsigned int rtaudio_num_api_names =
+const unsigned int rtaudio_num_api_names =
sizeof(rtaudio_api_names)/sizeof(rtaudio_api_names[0]);
// The order here will control the order of RtAudio's API search in
then = stream_.lastTickTimestamp;
return stream_.streamTime +
((now.tv_sec + 0.000001 * now.tv_usec) -
- (then.tv_sec + 0.000001 * then.tv_usec));
+ (then.tv_sec + 0.000001 * then.tv_usec));
#else
return stream_.streamTime;
#endif
channelsLeft -= streamChannels;
}
}
-
+
if ( stream_.doConvertBuffer[1] ) { // convert from our internal "device" buffer
convertBuffer( stream_.userBuffer[1],
stream_.deviceBuffer,
// CoInitialize beforehand, but it must be for appartment threading
// (in which case, CoInitilialize will return S_FALSE here).
coInitialized_ = false;
- HRESULT hr = CoInitialize( NULL );
+ HRESULT hr = CoInitialize( NULL );
if ( FAILED(hr) ) {
errorText_ = "RtApiAsio::ASIO requires a single-threaded appartment. Call CoInitializeEx(0,COINIT_APARTMENTTHREADED)";
error( RtAudioError::WARNING );
errorText_ = errorStream_.str();
goto error;
}
- buffersAllocated = true;
+ buffersAllocated = true;
stream_.state = STREAM_STOPPED;
// Set flags for buffer conversion.
static const char* getAsioErrorString( ASIOError result )
{
- struct Messages
+ struct Messages
{
ASIOError value;
const char*message;
};
- static const Messages m[] =
+ static const Messages m[] =
{
{ ASE_NotPresent, "Hardware input or output is not present or available." },
{ ASE_HWMalfunction, "Hardware is malfunctioning." },
// In order to satisfy WASAPI's buffer requirements, we need a means of converting sample rate
// between HW and the user. The WasapiResampler class is used to perform this conversion between
-// HwIn->UserIn and UserOut->HwOut during the stream callback loop.
+// HwIn->UserIn and UserO ut->HwOut during the stream callback loop.
class WasapiResampler
{
public:
#if defined(__WINDOWS_DS__) // Windows DirectSound API
// Modified by Robin Davies, October 2005
-// - Improvements to DirectX pointer chasing.
+// - Improvements to DirectX pointer chasing.
// - Bug fix for non-power-of-two Asio granularity used by Edirol PCR-A30.
// - Auto-call CoInitialize for DSOUND and ASIO platforms.
// Various revisions for RtAudio 4.0 by Gary Scavone, April 2007
void *id[2];
void *buffer[2];
bool xrun[2];
- UINT bufferPointer[2];
+ UINT bufferPointer[2];
DWORD dsBufferSize[2];
DWORD dsPointerLeadTime[2]; // the number of bytes ahead of the safe pointer to lead by.
HANDLE condition;
// Increase scheduler frequency on lesser windows (a side-effect of
// increasing timer accuracy). On greater windows (Win2K or later),
// this is already in effect.
- timeBeginPeriod( 1 );
+ timeBeginPeriod( 1 );
buffersRolling = false;
duplexPrerollBytes = 0;
}
if ( stream_.mode == OUTPUT || stream_.mode == DUPLEX ) {
-
+
LPDIRECTSOUNDBUFFER dsBuffer = (LPDIRECTSOUNDBUFFER) handle->buffer[0];
if ( handle->drainCounter > 1 ) { // write zeros to the output stream
}
if ( dsPointerBetween( nextWritePointer, safeWritePointer, currentWritePointer, dsBufferSize )
- || dsPointerBetween( endWrite, safeWritePointer, currentWritePointer, dsBufferSize ) ) {
+ || dsPointerBetween( endWrite, safeWritePointer, currentWritePointer, dsBufferSize ) ) {
// We've strayed into the forbidden zone ... resync the read pointer.
handle->xrun[0] = true;
nextWritePointer = safeWritePointer + handle->dsPointerLeadTime[0] - bufferBytes;
if ( safeReadPointer < (DWORD)nextReadPointer ) safeReadPointer += dsBufferSize; // unwrap offset
DWORD endRead = nextReadPointer + bufferBytes;
- // Handling depends on whether we are INPUT or DUPLEX.
+ // Handling depends on whether we are INPUT or DUPLEX.
// If we're in INPUT mode then waiting is a good thing. If we're in DUPLEX mode,
// then a wait here will drag the write pointers into the forbidden zone.
- //
- // In DUPLEX mode, rather than wait, we will back off the read pointer until
- // it's in a safe position. This causes dropouts, but it seems to be the only
- // practical way to sync up the read and write pointers reliably, given the
- // the very complex relationship between phase and increment of the read and write
+ //
+ // In DUPLEX mode, rather than wait, we will back off the read pointer until
+ // it's in a safe position. This causes dropouts, but it seems to be the only
+ // practical way to sync up the read and write pointers reliably, given the
+ // the very complex relationship between phase and increment of the read and write
// pointers.
//
// In order to minimize audible dropouts in DUPLEX mode, we will
error( RtAudioError::SYSTEM_ERROR );
return;
}
-
+
if ( safeReadPointer < (DWORD)nextReadPointer ) safeReadPointer += dsBufferSize; // unwrap offset
}
}
AlsaHandle *apiInfo = (AlsaHandle *) stream_.apiHandle;
snd_pcm_t **handle = (snd_pcm_t **) apiInfo->handles;
if ( stream_.mode == OUTPUT || stream_.mode == DUPLEX ) {
- if ( apiInfo->synchronized )
+ if ( apiInfo->synchronized )
result = snd_pcm_drop( handle[0] );
else
result = snd_pcm_drain( handle[0] );
#ifdef SCHED_RR // Undefined with some OSes (e.g. NetBSD 1.6.x with GNU Pthread)
if ( info->doRealtime ) {
- std::cerr << "RtAudio alsa: " <<
- (sched_getscheduler(0) == SCHED_RR ? "" : "_NOT_ ") <<
+ std::cerr << "RtAudio alsa: " <<
+ (sched_getscheduler(0) == SCHED_RR ? "" : "_NOT_ ") <<
"running realtime scheduling" << std::endl;
}
#endif
mainloop_ = 0;
info.outputChannels = channels_;
-
+
return info;
}
CallbackInfo *cbi = static_cast<CallbackInfo *>( user );
RtApiPulse *context = static_cast<RtApiPulse *>( cbi->object );
volatile bool *isRunning = &cbi->isRunning;
-
+
#ifdef SCHED_RR // Undefined with some OSes (e.g. NetBSD 1.6.x with GNU Pthread)
if (cbi->doRealtime) {
- std::cerr << "RtAudio pulse: " <<
- (sched_getscheduler(0) == SCHED_RR ? "" : "_NOT_ ") <<
+ std::cerr << "RtAudio pulse: " <<
+ (sched_getscheduler(0) == SCHED_RR ? "" : "_NOT_ ") <<
"running realtime scheduling" << std::endl;
}
#endif
-
+
while ( *isRunning ) {
pthread_testcancel();
context->callbackEvent();
else
bytes = stream_.nUserChannels[INPUT] * stream_.bufferSize *
formatBytes( stream_.userFormat );
-
+
if ( pa_simple_read( pah->s_rec, pulse_in, bytes, &pa_error ) < 0 ) {
errorStream_ << "RtApiPulse::callbackEvent: audio read error, " <<
pa_strerror( pa_error ) << ".";
if ( !stream_.callbackInfo.isRunning ) {
stream_.callbackInfo.object = this;
-
+
stream_.state = STREAM_STOPPED;
// Set the thread attributes for joinable and realtime scheduling
// priority (optional). The higher priority will only take affect
if ( priority < min ) priority = min;
else if ( priority > max ) priority = max;
param.sched_priority = priority;
-
+
// Set the policy BEFORE the priority. Otherwise it fails.
pthread_attr_setschedpolicy(&attr, SCHED_RR);
pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
}
return SUCCESS;
-
+
error:
if ( pah && stream_.callbackInfo.isRunning ) {
pthread_cond_destroy( &pah->runnable_cv );
if ( priority < min ) priority = min;
else if ( priority > max ) priority = max;
param.sched_priority = priority;
-
+
// Set the policy BEFORE the priority. Otherwise it fails.
pthread_attr_setschedpolicy(&attr, SCHED_RR);
pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM);
#ifdef SCHED_RR // Undefined with some OSes (e.g. NetBSD 1.6.x with GNU Pthread)
if (info->doRealtime) {
- std::cerr << "RtAudio oss: " <<
- (sched_getscheduler(0) == SCHED_RR ? "" : "_NOT_ ") <<
+ std::cerr << "RtAudio oss: " <<
+ (sched_getscheduler(0) == SCHED_RR ? "" : "_NOT_ ") <<
"running realtime scheduling" << std::endl;
}
#endif
// End:
//
// vim: et sts=2 sw=2
-