void UpdateThread::run() // virtual { SetCurrentThreadName( "UpdateRunLoop" ); ork::Timer timr; timr.Start(); int icounter = 0; OpqTest opqtest(&UpdateSerialOpQ()); while( false==mbEXITING ) { icounter++; float fsecs = timr.SecsSinceStart(); if( fsecs > 10.0f ) { printf( "ups<%f>\n", float(icounter)/fsecs ); timr.Start(); icounter=0; } //////////////////////////////////////////////// // process serial update opQ //////////////////////////////////////////////// while(UpdateSerialOpQ().Process()); //////////////////////////////////////////////// // update scene //////////////////////////////////////////////// switch( gUpdateStatus.meStatus ) { case EUPD_START: mpVP->NotInDrawSync(); gUpdateStatus.SetState(EUPD_RUNNING); break; case EUPD_RUNNING: { //ork::PerfMarkerPush( "ork.begin_update" ); ent::DrawableBuffer* dbuf = ork::ent::DrawableBuffer::LockWriteBuffer(7); { OrkAssert(dbuf); auto psi = (ent::SceneInst*) mpVP->GetSceneInst(); if( psi ) { auto cmci = psi->GetCMCI(); float frame_rate = cmci ? cmci->GetCurrentFrameRate() : 0.0f; bool externally_fixed_rate = (frame_rate!=0.0f); if( externally_fixed_rate ) { RenderSyncToken syntok; if( DrawableBuffer::mOfflineUpdateSynchro.try_pop(syntok) ) { syntok.mFrameIndex++; psi->Update(); DrawableBuffer::mOfflineRenderSynchro.push(syntok); } } else psi->Update(); } mpVP->QueueSceneInstToDb(dbuf); } ork::ent::DrawableBuffer::UnLockWriteBuffer(dbuf); //ork::PerfMarkerPush( "ork.end_update" ); break; } case EUPD_STOP: mpVP->NotInDrawSync(); gUpdateStatus.SetState(EUPD_STOPPED); break; case EUPD_STOPPED: mpVP->NotInDrawSync(); break; default: assert(false); break; } //////////////////////////////////////////////// ork::msleep(1); } }
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // GetPropertyData() //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- void FormatList::GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data) const { Float64* rates; AudioValueRange* rateRanges; UInt32 theNumberRates; UInt32 theNumberRateRanges; UInt32 theIndex; CMFormatDescriptionRef format = NULL; switch (address.mSelector) { case kCMIOStreamPropertyFormatDescription: ThrowIf(dataSize != sizeof(CMFormatDescriptionRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyFormatDescription"); if (NULL != GetCurrentFormat()) CFRetain(GetCurrentFormat()); *static_cast<CMFormatDescriptionRef*>(data) = GetCurrentFormat(); dataUsed = sizeof(CMFormatDescriptionRef); break; case kCMIOStreamPropertyFormatDescriptions: ThrowIf(dataSize != sizeof(CFArrayRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyFormatDescriptions"); *static_cast<CFArrayRef*>(data) = CFArrayCreateCopy(NULL, mDescriptions.GetCFArray()); dataUsed = sizeof(CFArrayRef); break; case kCMIOStreamPropertyStillImage: ThrowIf(dataSize != sizeof(CMSampleBufferRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyStillImage"); ThrowIf(qualifierDataSize != sizeof(CMFormatDescriptionRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong qualifier data size for kCMIOStreamPropertyStillImage"); *static_cast<CMSampleBufferRef*>(data) = GetStillImage(*static_cast<CMFormatDescriptionRef*>(const_cast<void*>(qualifierData))); dataUsed = sizeof(CMFormatDescriptionRef); break; case kCMIOStreamPropertyStillImageFormatDescriptions: ThrowIf(dataSize != sizeof(CFArrayRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyStillImageFormatDescriptions"); *static_cast<CFArrayRef*>(data) = CFArrayCreateCopy(NULL, mStillImageDescriptions.GetCFArray()); dataUsed = sizeof(CFArrayRef); break; case kCMIOStreamPropertyFrameRate: ThrowIf(dataSize != sizeof(Float64), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyFrameRate"); *(static_cast<Float64*>(data)) = GetCurrentFrameRate(); dataUsed = sizeof(Float64); break; case kCMIOStreamPropertyFrameRates: ThrowIf(qualifierDataSize != 0 and qualifierDataSize != sizeof(CMFormatDescriptionRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong qualifier data size for kCMIOStreamPropertyFrameRates"); format = (0 == qualifierDataSize) ? mCurrentFormat.Get() : *static_cast<CMFormatDescriptionRef*>(const_cast<void*>(qualifierData)); theNumberRates = std::min((UInt32)(dataSize / sizeof(Float64)), GetNumberFrameRates(format)); rates = static_cast<Float64*>(data); for(theIndex = 0; theIndex < theNumberRates; ++theIndex) { rates[theIndex] = GetFrameRateByIndex(format, theIndex); } dataUsed = theNumberRates * sizeof(Float64); break; case kCMIOStreamPropertyMinimumFrameRate: ThrowIf(dataSize != sizeof(Float64), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyMinimumFrameRate"); *(static_cast<Float64*>(data)) = GetMinimumFrameRate(); dataUsed = sizeof(Float64); break; case kCMIOStreamPropertyFrameRateRanges: ThrowIf(qualifierDataSize != 0 and qualifierDataSize != sizeof(CMFormatDescriptionRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong qualifier data size for kCMIOStreamPropertyFrameRateRanges"); format = (0 == qualifierDataSize) ? mCurrentFormat.Get() : *static_cast<CMFormatDescriptionRef*>(const_cast<void*>(qualifierData)); theNumberRateRanges = std::min((UInt32)(dataSize / sizeof(AudioValueRange)), GetNumberFrameRateRanges(format)); rateRanges = static_cast<AudioValueRange*>(data); for(theIndex = 0; theIndex < theNumberRateRanges; ++theIndex) { rateRanges[theIndex] = GetFrameRateRangeByIndex(format, theIndex); } dataUsed = theNumberRateRanges * sizeof(AudioValueRange); break; case kCMIOStreamPropertyPreferredFormatDescription: ThrowIf(dataSize != sizeof(CMFormatDescriptionRef), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyPreferredFormatDescription"); if (NULL != GetPreferredFormat()) CFRetain(GetPreferredFormat()); *static_cast<CMFormatDescriptionRef*>(data) = GetPreferredFormat(); dataUsed = sizeof(CMFormatDescriptionRef); break; case kCMIOStreamPropertyPreferredFrameRate: ThrowIf(dataSize != sizeof(Float64), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FormatList::GetPropertyData: wrong data size for kCMIOStreamPropertyPreferredFrameRate"); *(static_cast<Float64*>(data)) = GetPreferredFrameRate(); dataUsed = sizeof(Float64); break; }; }