//! the applications.
//!
//! \param pManager : The managing device manager - simply passed on to the base class.
-//!
-//!
+//!
+//!
//**********************************************************************************************
WCMRNativeAudioNoneDevice::WCMRNativeAudioNoneDevice (WCMRAudioDeviceManager *pManager)
: WCMRNativeAudioDevice (pManager, false /*useMultiThreading*/)
+#ifndef PTW32_VERSION
+ , m_SilenceThread(0)
+#endif
#if defined (PLATFORM_WINDOWS)
, _waitableTimerForUsleep (CreateWaitableTimer(NULL, TRUE, NULL))
#endif
}
_m_inputBuffer = new float[__m_NumInputChannels * m_BufferSizes.back()];
_m_outputBuffer = new float[__m_NumOutputChannels * m_BufferSizes.back()];
- m_DefaultBufferSize = m_BufferSizes.back();
m_CurrentBufferSize = m_BufferSizes.back();
}
//same size, nothing to do.
if (oldSize == newSize)
return eNoErr;
-
+
//see if this is one of our supported rates...
std::vector<int>::iterator intIter = find(m_BufferSizes.begin(), m_BufferSizes.end(), newSize);
if (intIter == m_BufferSizes.end())
//Can't change, perhaps use an "invalid param" type of error
return eCommandLineParameter;
}
-
+
if (Streaming())
{
//Can't change, perhaps use an "in use" type of error
return eGenericErr;
}
-
+
return WCMRAudioDevice::SetCurrentBufferSize(newSize);
}
std::cerr << "WCMRNativeAudioNoneDevice::SetStreaming (): pthread_attr_init () failed!" << std::endl;
return eGenericErr;
}
-
+
if (pthread_attr_setstacksize (&attributes, stack_size)) {
std::cerr << "WCMRNativeAudioNoneDevice::SetStreaming (): pthread_attr_setstacksize () failed!" << std::endl;
return eGenericErr;
(const float*)theInpBuffers,
_m_outputBuffer,
buffer_size,
- 0,
+ 0,
0
};
audioCallbackData.acdCycleStartTimeNanos =__get_time_nanos();
- // VERY ROUGH IMPLEMENTATION:
+ // VERY ROUGH IMPLEMENTATION:
while(Streaming()) {
-
+
uint64_t cycleEndTimeNanos = audioCallbackData.acdCycleStartTimeNanos + cyclePeriodNanos;
m_pMyManager->NotifyClient (WCMRAudioDeviceManagerClient::AudioCallback, (void *)&audioCallbackData);
-
+
audioCallbackData.acdSampleTime += buffer_size;
-
+
int64_t timeToSleepUsecs = ((int64_t)cycleEndTimeNanos - (int64_t)__get_time_nanos())/1000;
-
+
if (timeToSleepUsecs > 0) {
_usleep (timeToSleepUsecs);
}
#if defined(PLATFORM_WINDOWS)
void WCMRNativeAudioNoneDevice::_usleep(uint64_t duration_usec)
-{
- LARGE_INTEGER ft;
+{
+ LARGE_INTEGER ft;
ft.QuadPart = -(10*duration_usec); // Convert to 100 nanosecond interval, negative value indicates relative time
SetWaitableTimer(_waitableTimerForUsleep, &ft, 0, NULL, NULL, 0);
- WaitForSingleObject(_waitableTimerForUsleep, INFINITE);
+ WaitForSingleObject(_waitableTimerForUsleep, INFINITE);
}
#endif
// the API should be a part of WCMRCoreAudioDeviceManager to give a chance of being tied to the
// audio device transport time�.
return AudioConvertHostTimeToNanos (AudioGetCurrentHostTime ());
-
+
#elif PLATFORM_WINDOWS
-
+
LARGE_INTEGER Frequency, Count ;
QueryPerformanceFrequency (&Frequency) ;