/** @brief fetches our pointer out of the props on the handle */ static Interact *retrieveInteractPointer(OfxInteractHandle handle) { Interact *instance; // get the prop set on the handle OfxPropertySetHandle propHandle; OfxStatus stat = OFX::Private::gInteractSuite->interactGetPropertySet(handle, &propHandle); throwSuiteStatusException(stat); // make our wrapper object PropertySet props(propHandle); // fetch the instance data out of the properties instance = (Interact *) props.propGetPointer(kOfxPropInstanceData); OFX::Log::error(instance == 0, "Instance data handle in effect instance properties is NULL!"); // need to throw something here if (!instance) { throwSuiteStatusException(kOfxStatErrBadHandle); } // and dance to the music return instance; }
/** @brief ctor */ Mutex::Mutex( int lockCount ) : _handle( 0 ) { OfxStatus stat = OFX::Private::gThreadSuite->mutexCreate( &_handle, lockCount ); throwSuiteStatusException( stat ); }
/** @brief The main entry for image effect overlays */ OfxStatus interactMainEntry( const char* actionRaw, const void* handleRaw, OfxPropertySetHandle inArgsRaw, OfxPropertySetHandle outArgsRaw, InteractDescriptor& desc ) { OFX::Log::print( "********************************************************************************" ); OFX::Log::print( "START overlayInteractMainEntry (%s)", actionRaw ); OFX::Log::indent(); OfxStatus stat = kOfxStatReplyDefault; try { // Cast the raw handle to be an image effect handle, because that is what it is OfxInteractHandle handle = (OfxInteractHandle) handleRaw; // Turn the arguments into wrapper objects to make our lives easier OFX::PropertySet inArgs( inArgsRaw ); OFX::PropertySet outArgs( outArgsRaw ); // turn the action into a std::string std::string action( actionRaw ); // figure the actions if( action == kOfxActionDescribe ) { OfxPropertySetHandle propHandle; OfxStatus stat = OFX::Private::gInteractSuite->interactGetPropertySet( handle, &propHandle ); throwSuiteStatusException( stat ); PropertySet interactProperties( propHandle ); desc.setPropertySet( &interactProperties ); desc.describe(); } else if( action == kOfxActionCreateInstance ) { // fetch the image effect we are being made for out of the interact's property handle ImageEffect* effect = retrieveEffectFromInteractHandle( handle ); /*OFX::Interact* interact = */ desc.createInstance( handle, effect ); // and all was well stat = kOfxStatOK; } else { stat = interactMainEntry( action, handle, inArgs, outArgs ); } } catch(... ) { stat = kOfxStatFailed; } OFX::Log::outdent(); OFX::Log::print( "STOP overlayInteractMainEntry (%s)", actionRaw ); return stat; }
/** @brief retrieves the image effect pointer from the interact handle */ static ImageEffect *retrieveEffectFromInteractHandle(OfxInteractHandle handle) { // get the properties set on this handle OfxPropertySetHandle propHandle; OfxStatus stat = OFX::Private::gInteractSuite->interactGetPropertySet(handle, &propHandle); throwSuiteStatusException(stat); PropertySet interactProperties(propHandle); // get the effect handle from this handle OfxImageEffectHandle effectHandle = (OfxImageEffectHandle) interactProperties.propGetPointer(kOfxPropEffectInstance); // get the effect properties return OFX::Private::retrieveImageEffectPointer(effectHandle); }
/** @brief ctor */ Interact::Interact(OfxInteractHandle handle) : _interactHandle(handle) , _effect(NULL) { // get the properties set on this handle OfxPropertySetHandle propHandle; OfxStatus stat = OFX::Private::gInteractSuite->interactGetPropertySet(handle, &propHandle); throwSuiteStatusException(stat); _interactProperties.propSetHandle(propHandle); // set othe instance data on the property handle to point to this interact _interactProperties.propSetPointer(kOfxPropInstanceData, (void *)this); // get the effect handle from this handle _effect = retrieveEffectFromInteractHandle(handle); }
/** @brief Function to pass to the multi thread suite */ void Processor::multiThread(unsigned int nCPUs) { // if 0, use all the CPUs we can if(nCPUs == 0) nCPUs = OFX::MultiThread::getNumCPUs(); // if 1 cpu, don't bother with the threading if(nCPUs == 1) { multiThreadFunction(0, 1); } else { // OK do it OfxStatus stat = OFX::Private::gThreadSuite->multiThread(staticMultiThreadFunction, nCPUs, (void *)this); // did we do it? throwSuiteStatusException(stat); } }
/** @brief Function to pass to the multi thread suite */ void Processor::multiThread( const unsigned int nCPUs ) { unsigned int realNbCPUs = nCPUs; // if 0, use all the CPUs we can if( realNbCPUs == 0 ) realNbCPUs = OFX::MultiThread::getNumCPUs(); if( realNbCPUs == 0 ) { TUTTLE_COUT_ERROR( "Run process on 0 cpus... it seems to be a problem." ); } else if( realNbCPUs == 1 ) // if 1 cpu, don't bother with the threading { multiThreadFunction( 0, 1 ); } else { // OK do it OfxStatus stat = OFX::Private::gThreadSuite->multiThread( staticMultiThreadFunction, realNbCPUs, (void*)this ); // did we do it? throwSuiteStatusException( stat ); } }
void throwPropertyException(OfxStatus stat, const std::string &propName) throw(std::bad_alloc, OFX::Exception::PropertyUnknownToHost, OFX::Exception::PropertyValueIllegalToHost, OFX::Exception::Suite) { switch (stat) { case kOfxStatOK : case kOfxStatReplyYes : case kOfxStatReplyNo : case kOfxStatReplyDefault : // Throw nothing! break; case kOfxStatErrUnknown : case kOfxStatErrUnsupported : // unsupported implies unknow here if(OFX::PropertySet::getThrowOnUnsupportedProperties()) // are we suppressing this? throw OFX::Exception::PropertyUnknownToHost(propName.c_str()); break; case kOfxStatErrMemory : throw std::bad_alloc(); break; case kOfxStatErrValue : throw OFX::Exception::PropertyValueIllegalToHost(propName.c_str()); break; case kOfxStatErrBadHandle : case kOfxStatErrBadIndex : default : throwSuiteStatusException(stat); break; } }
/** @brief unlock it */ void Mutex::unlock() { OfxStatus stat = OFX::Private::gThreadSuite->mutexUnLock( _handle ); throwSuiteStatusException( stat ); }
/** @brief Swap a buffer in the case of a double bufferred interact, this is possibly a silly one */ void Interact::swapBuffers(void) const { OfxStatus stat = OFX::Private::gInteractSuite->interactSwapBuffers(_interactHandle); throwSuiteStatusException(stat); }
/** @brief Request a redraw */ void Interact::requestRedraw(void) const { OfxStatus stat = OFX::Private::gInteractSuite->interactRedraw(_interactHandle); throwSuiteStatusException(stat); }