bool AREngine::initHardware(IOService* inProvider) { bool theAnswer = false; if(IOAudioEngine::initHardware(inProvider)) { IOAudioSampleRate theInitialSampleRate = { 0, 0 }; UInt32 theNumberChannels = 0; // create the streams if(CreateStreams(&theInitialSampleRate, &theNumberChannels) && (theInitialSampleRate.whole != 0)) { CreateControls(theNumberChannels); // figure out how long each block is in microseconds mBlockTimeoutMicroseconds = 1000000 * mBlockSize / theInitialSampleRate.whole; setSampleRate(&theInitialSampleRate); // Set the number of sample frames in each buffer setNumSampleFramesPerBuffer(mBlockSize * mNumberBlocks); // set up the timer IOWorkLoop* theWorkLoop = getWorkLoop(); if(theWorkLoop != NULL) { mTimerEventSource = IOTimerEventSource::timerEventSource(this, TimerFired); if(mTimerEventSource != NULL) { theWorkLoop->addEventSource(mTimerEventSource); theAnswer = true; } } // set the safety offset // note that due to cache issues, it probably isn't wise to leave the safety offset at 0, // we set it to 4 here, just to be safe. setSampleOffset(4); // set up the time stamp generator mTimeStampGenerator.SetSampleRate(theInitialSampleRate.whole); mTimeStampGenerator.SetFramesPerRingBuffer(mBlockSize * mNumberBlocks); // nate that the rate scalar is a 4.28 fixed point number // this means that each incremnt is 1/2^28 mTimeStampGenerator.SetRateScalar(1UL << 28); // set the maximum jitter // AbsoluteTime theMaximumJitter = { 0, 0 }; // nanoseconds_to_absolutetime(5ULL * 1000ULL, &theMaximumJitter); // mTimeStampGenerator.SetMaximumJitter(theMaximumJitter.lo); } } return theAnswer; }
void ossimNitfRpcBase::setSampleOffset(ossim_uint32 sampleOffset) { ossimString os = ossimNitfCommon::convertToUIntString(sampleOffset, SAMPLE_OFFSET_SIZE); setSampleOffset(os); }