示例#1
0
LONG InStream::Read(void *data, UInt32 size, UInt32 *processedSize)
{
    if (processedSize)
        *processedSize = 0;
    if (!ioDevice_->isReadable())
        return E_FAIL;
    char* buffer = reinterpret_cast<char*>(data);
    qint64 readBytes = ioDevice_->read(buffer, qint64(size));
    if (-1 == readBytes)
        return E_FAIL;
    if (processedSize)
        *processedSize = UInt32(readBytes);
    return S_OK;
}
void AttachmentContainer::addAttachment(
    AttachmentObj * const pAttachment,
    UInt16                binding)
{
    UInt32 key;

    if(pAttachment == NULL)
        return;

    key = (UInt32 (pAttachment->getGroupId()) << 16) | binding;

    if(this->isMTLocal())
    {
        RecordedRefCountPolicy::addRef(pAttachment);
    }
    else
    {
        UnrecordedRefCountPolicy::addRef(pAttachment);
    }

    pAttachment->linkParent(this, 
                            AttachmentsFieldId, 
                            Attachment::ParentsFieldId);

    Self::editSField(AttachmentsFieldMask);

    AttachmentObjPtrMapIt fcI = _sfAttachments.getValue().find(key);

    if(fcI != _sfAttachments.getValue().end())
    {
        (*fcI).second->unlinkParent(this, 
                                    Attachment::ParentsFieldId);

        if(this->isMTLocal())
        {
            RecordedRefCountPolicy::subRef((*fcI).second);
        }
        else
        {
            UnrecordedRefCountPolicy::subRef((*fcI).second);
        }

        (*fcI).second = pAttachment;
    }
    else
    {
        _sfAttachments.getValue()[key] = pAttachment;
    }
}
LightBase::LightBase(void) :
    Inherited(),
    _sfAmbient                (Color4f(0.f,0.f,0.f,1.f)),
    _sfDiffuse                (Color4f(1.f,1.f,1.f,1.f)),
    _sfSpecular               (Color4f(1.f,1.f,1.f,1.f)),
    _sfBeacon                 (NULL),
    _sfOn                     (bool(true)),
    _sfConstantAttenuation    (Real32(1.f)),
    _sfLinearAttenuation      (Real32(0.f)),
    _sfQuadraticAttenuation   (Real32(0.f)),
    _sfLightEngine            (NULL),
    _sfShadowIntensity        (Real32(0.f)),
    _sfShadowMode             (UInt32(0))
{
}
示例#4
0
const String
SocketAddress::toString() const
{
	OW_ASSERT(m_type != UNSET);
	String rval;
	if (m_type == INET)
	{
		rval = getAddress() + ":" + String(UInt32(getPort()));
	}
	else
	{
		rval = this->m_name;
	}
	return rval;
}
bool zoStreamBufferImplLZMA::init( void)
{
    XTRACE();
    _fstream << (Uint32) LZMASTREAM_MAGIC;

    _encoder= new NCompress::NLZMA::CEncoder;

    UInt32 algorithm = 2;               // max compression
    UInt32 dictionary = 1 << 23;        // 8 Meg dictionary
    bool eos = true;

    PROPID propIDs[] =
    {
	NCoderPropID::kDictionarySize,
	NCoderPropID::kAlgorithm,
	NCoderPropID::kEndMarker
    };
    const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
    PROPVARIANT properties[kNumProps];
    properties[0].vt = VT_UI4;
    properties[0].ulVal = UInt32(dictionary); properties[1].vt = VT_UI4;
    properties[1].ulVal = UInt32(algorithm);
    properties[2].vt = VT_BOOL;
    properties[2].boolVal = eos ? VARIANT_TRUE : VARIANT_FALSE;

    if (_encoder->SetCoderProperties(propIDs, properties, kNumProps) != S_OK)
    {
        LOG_ERROR << "Unable to set properties\n";
	return false;
    }

    _encoder->WriteCoderProperties(this);
    _encoder->SetStreams( this, this, 0, 0);

    return true;
}
GeoVectorBufferPropertyBase::GeoVectorBufferPropertyBase(void) :
    Inherited(),
    _sfStride                 (UInt32(0)),
    _sfFormat                 (UInt32(GL_FLOAT)),
    _sfFormatSize             (UInt32(4)),
    _sfDimension              (UInt32(3)),
    _sfVectorType             (UInt32(GeoProperty::VectorTypeVector)),
    _sfSize                   (UInt32(0))
{
}
FCDTestFCBase::FCDTestFCBase(void) :
    Inherited(),
    _sfFieldSFPub             (UInt32(0)),
    _sfFieldSFPro             (UInt32(0)),
    _sfFieldSFNo              (UInt32(0)),
    _mfFieldMFPub             (UInt32(0)),
    _mfFieldMFPro             (UInt32(0)),
    _mfFieldMFNo              (UInt32(0))
{
}
/*! Writes all fields to the stream, except for those whose name is in
    \a excludeFields. Optionally writes an end marker.

    The excludeFields string has the format: "'name1' 'name2' 'name3'",
    the spaces between the "'" are mandatory.

    \param[in] excludeFields String of field names that shall be skipped.
    \param[in] endMarker Write an end marker to the stream after all fields are
    processed.
 */
void
OSBCommonElement::writeFields(
    const std::string &excludeFields, const bool endMarker)
{
    OSG_OSB_LOG(("OSBCommonElement::writeFields: "
            "excludeFields: [%s]\n", excludeFields.c_str()));

    FieldContainer *fc         = getContainer();
    UInt32          fieldCount = fc->getType().getNumFieldDescs();

    // go through all fields and write them.
    for(UInt32 fieldId = 1; fieldId <= fieldCount; ++fieldId)
    {
        const FieldDescriptionBase *fieldDesc =
            fc->getFieldDescription(fieldId);
        const std::string          &fieldName = fieldDesc->getName();

        // skip internal fields
        if(fieldDesc->isInternal())
        {
            OSG_OSB_LOG(("OSBCommonElement::writeFields: "
                    "Skipping internal field: [%s]\n", fieldName.c_str()));
            continue;
        }

        // skip excluded fields
        if((!excludeFields.empty()                                        ) &&
           (excludeFields.find("'" + fieldName + "'") != std::string::npos)   )
        {
            OSG_OSB_LOG(("OSBCommonElement::writeFields: "
                    "Skipping excluded field: [%s]\n", fieldName.c_str()));
            continue;
        }

        const FieldType   &fieldType     = fieldDesc->getFieldType();
        const std::string &fieldTypeName = fieldType .getName     ();
        BitVector          fieldMask     = fieldDesc->getFieldMask();
        UInt32             fieldSize     = UInt32(fc->getBinSize(fieldMask));

        writeFieldHeader (fieldName, fieldTypeName, fieldSize);
        writeFieldContent(fieldId                            );
    }

    if(endMarker)
    {
        writeEndMarker();
    }
}
示例#9
0
void DrawEnv::updateChunk(State         *pState,
                          StateOverride *pOverride)
{
    StateChunk *c = pState->getChunk(State::UpdateChunk);

    if(pOverride->size()         >  0                  &&
       pOverride->begin()->first == State::UpdateChunk  )
    {
        c = pOverride->begin()->second;
    }

    if(c != NULL && (c)->getIgnore() == false)
    {
        (c)->changeFrom(this, c, UInt32(0));
    }
}
示例#10
0
void State::deactivate(DrawActionBase *action)
{
    MFStateChunkPtr::iterator it;
    const MFStateChunkPtr::iterator itEnd = _mfChunks.end();
    Int32 ind = 0;
    UInt32 cind;

    for(it = _mfChunks.begin(), cind = 0; it != itEnd;
            ++it, ++cind)
    {
        if(*it != NullFC && !(*it)->getIgnore())
            (*it)->deactivate(action, UInt32(ind));
        if(++ind >= StateChunkClass::getNumSlots(cind))
            ind = 0;
    }
}
CgFXMaterialBase::CgFXMaterialBase(void) :
    Inherited(),
    _sfTreatTechniquesAsVariants(bool(false)),
    _sfEffectFile             (),
    _sfEffectString           (),
    _mfCompilerOptions        (),
    _sfVariables              (this,
                          VariablesFieldId,
                          ShaderProgramVariables::ParentsFieldId),
    _mfVariableNames          (),
    _sfStateVariables         (UInt32(0)),
    _mfTechniques             (),
    _mfTextures               (),
    _sfGLId                   (GLenum(0))
{
}
static void sendActivateEvent(nsIEventHandler* handler, WindowRef window, Boolean active)
{
    EventRecord event;
    ::OSEventAvail(0, &event);
    event.what = activateEvt;
    event.message = UInt32(window);
    if (active)
        event.modifiers |= activeFlag;
    else
        event.modifiers &= ~activeFlag;

    nsPluginEvent pluginEvent = { &event, window };
    PRBool handled = PR_FALSE;

    handler->HandleEvent(&pluginEvent, &handled);
}
示例#13
0
void NFIOBase::writeFCId(const FieldContainerPtr &fc)
{
    if(fc == NullFC)
    {
        _out->putValue(UInt32(0));
        return;
    }
    
    UInt32 id = getContainerId(fc);
    _out->putValue(id);
    
    if(_fcSet.count(id) == 0)
    {
        _fcSet.insert(id);
        _fcList.push_back(fc);
    }
}
示例#14
0
void DrawEnv::updateChunk(State         *pState,
                          StateOverride *pOverride)
{
    StateChunk   *c      = pState->getChunk(State::UpdateChunk);
    UInt32 const  climit = pState->getCoreGLChunkLimit();

    if(pOverride->size()         >  0                  &&
       pOverride->begin()->first == State::UpdateChunk  )
    {
        c = pOverride->begin()->second;
    }

    if(c != NULL && c->getIgnore() == false && c->getClassId() < climit)
    {
        c->changeFrom(this, c, UInt32(0));
    }
}
ViewportBase::ViewportBase(void) :
    Inherited(),
    _sfLeft                   (Real32(0.f)),
    _sfRight                  (Real32(1.f)),
    _sfBottom                 (Real32(0.f)),
    _sfTop                    (Real32(1.f)),
    _sfParent                 (NULL),
    _sfCamera                 (NULL),
    _sfRoot                   (NULL),
    _sfBackground             (NULL),
    _mfForegrounds            (),
    _sfTravMask               (UInt32(TypeTraits<UInt32>::getMax())),
    _sfDrawTime               (Real32(0.0f)),
    _sfDrawableId             (Int32(-1)),
    _sfRenderOptions          (NULL)
{
}
示例#16
0
// Outdated - use 'ITRLightingOptions' instead
Persistent::Base::Error ITRLightOptions2::write( StreamIO & io_sio,
   int /*version*/, int /*user*/ )
{
   io_sio.write(UInt32(m_lightingType));
   io_sio.write(m_geometryScale);
   io_sio.write(m_lightScale);
   io_sio.write(m_useNormals);
   io_sio.write(m_emissionQuantumNumber);
   io_sio.write(m_useMaterialProperties);

   // ambient
   io_sio.write(m_ambientIntensity.red);
   io_sio.write(m_ambientIntensity.green);
   io_sio.write(m_ambientIntensity.blue);
   
   return ((io_sio.getStatus() == STRM_OK) ? Ok : WriteError);
}
示例#17
0
Persistent::Base::Error ITRLightingOptions::write( StreamIO & sio, int, int )
{
   sio.write( UInt32( m_lightingType ) );
   sio.write( m_geometryScale );
   sio.write( m_lightScale );
   sio.write( m_useNormals );
   sio.write( m_emissionQuantumNumber );
   sio.write(m_useMaterialProperties );

   // ambient
   sio.write( m_ambientIntensity.red );
   sio.write( m_ambientIntensity.green );
   sio.write( m_ambientIntensity.blue );
   sio.write( m_applyAmbientOutside );
   
   return( ( sio.getStatus() == STRM_OK ) ? Ok : WriteError );
}
示例#18
0
 const std::vector<const Parameter*> CameraBuffer::setupParameters()
 {
     std::vector<const Parameter*> parameters;
 
     NumericParameter<UInt32>* numBuffers = new NumericParameter<UInt32>(NUM_BUFFERS);
     numBuffers->setTitle("Number of buffers");
     numBuffers->setAccessMode(runtime::Parameter::INITIALIZED_WRITE);
     numBuffers->setMin(UInt32(1));
     parameters.push_back(numBuffers);
 
     NumericParameter<UInt32>* bufferSize = new NumericParameter<UInt32>(BUFFER_SIZE);
     bufferSize->setTitle("Buffer size in bytes");
     bufferSize->setAccessMode(runtime::Parameter::INITIALIZED_WRITE);
     parameters.push_back(bufferSize);
                                 
     return parameters;
 }
TexGenChunkBase::TexGenChunkBase(void) :
    Inherited(),
    _sfGenFuncS               (GLenum(GL_NONE)),
    _sfGenFuncT               (GLenum(GL_NONE)),
    _sfGenFuncR               (GLenum(GL_NONE)),
    _sfGenFuncQ               (GLenum(GL_NONE)),
    _sfGenFuncSPlane          (Vec4f(1,0,0,0)),
    _sfGenFuncTPlane          (Vec4f(0,1,0,0)),
    _sfGenFuncRPlane          (Vec4f(0,0,1,0)),
    _sfGenFuncQPlane          (Vec4f(0,0,0,1)),
    _sfSBeacon                (NULL),
    _sfTBeacon                (NULL),
    _sfRBeacon                (NULL),
    _sfQBeacon                (NULL),
    _sfEyeModelViewMatrix     (),
    _sfEyeModelViewMode       (UInt32(0x0001))
{
}
ShaderProgramBase::ShaderProgramBase(void) :
    Inherited(),
    _sfShaderType             (GLenum(GL_NONE)),
    _sfProgram                (),
    _sfDefines                (),
    _sfGLId                   (UInt32(0)),
    _sfVariables              (this,
                          VariablesFieldId,
                          ShaderProgramVariables::ParentsFieldId),
    _mfFeedbackVaryings       (),
    _mfParameter              (),
    _mfAttributes             (),
    _sfCgFrontEnd             (bool(false)),
    _sfPointSize              (bool(false)),
    _mfParents                (),
    _mfDestroyedFunctors      ()
{
}
示例#21
0
UInt32
PollingManagerThread::calcSleepTime(bool& rightNow, bool doInit)
{
	rightNow = false;
	DateTime dtm;
	dtm.setToCurrent();
	time_t tm = dtm.get();

	Int32 const int32_max = std::numeric_limits<Int32>::max();
	time_t const time_t_max = std::numeric_limits<time_t>::max();
	time_t leastTime = (time_t_max > int32_max ? int32_max : time_t_max);
	// leastTime is now a large positive time_t value that will fit into an
	// Int32, and hence into a UInt32.

	int checkedCount = 0;
	// LOOP INVARIANT: 0 <= leastTime <= int32_max
	for (size_t i = 0; i < m_triggerRunners.size(); i++)
	{
		if (m_triggerRunners[i]->m_isRunning
			|| m_triggerRunners[i]->m_pollInterval == 0)
		{
			continue;
		}
		if (doInit)
		{
			m_triggerRunners[i]->m_nextPoll =
				safe_add(tm, m_triggerRunners[i]->m_pollInterval);
		}
		else if (m_triggerRunners[i]->m_nextPoll <= tm)
		{
			rightNow = true;
			return 0;
		}
		// GUARANTEED: m_triggerRunners[i]->m_nextPoll >= tm
		checkedCount++;
		time_t diff = m_triggerRunners[i]->m_nextPoll - tm;
		if (diff < leastTime)
		{
			leastTime = diff;
		}
	}
	return (checkedCount == 0) ? 0 : UInt32(leastTime);
}
FieldContainer *ComplexSceneManager::resolve(
    const Char8          *szName,
          FieldContainer *pDestContainer,
          Int32           iDestFieldId)
{
    FieldContainer *returnValue = this->findNamedComponent(szName);

    if(returnValue == NULL && pDestContainer != NULL && iDestFieldId >= 0)
    {
        DeferredFCUse tmpBlock;

        tmpBlock._szName       = szName;
        tmpBlock._pDstCnt      = pDestContainer;
        tmpBlock._uiDstFieldId = UInt32(iDestFieldId);

        _vUnresolvedFCs.push_back(tmpBlock);
    }

    return returnValue;
}
SInt64 SFB::Audio::TrueAudioDecoder::_SeekToFrame(SInt64 frame)
{
	TTAuint32 seconds = (TTAuint32)(frame / mSourceFormat.mSampleRate);
	TTAuint32 frame_start = 0;

	try {
		mDecoder->set_position(seconds, &frame_start);
	}
	catch(tta::tta_exception e) {
		LOGGER_ERR("org.sbooth.AudioEngine.Decoder.TrueAudio", "True Audio seek error: " << e.code());
		return -1;
	}

	mCurrentFrame = frame;

	// We need to skip some samples from start of the frame if required
	mFramesToSkip = UInt32((seconds - frame_start) * mSourceFormat.mSampleRate + 0.5);

	return mCurrentFrame;
}
示例#24
0
void State::deactivate(DrawEnv *pEnv) const
{
    MFChunksType::const_iterator cIt    = _mfChunks.begin();
    MFChunksType::const_iterator cEnd   = _mfChunks.end  ();
    Int32                        ind    = 0;
    UInt32                       cind   = osgMin(State::SkipNumChunks,
                                                 _mfChunks.size32()  );
    UInt32 const                 climit = _uiCoreGLChunkLimit;

    OSG_SKIP_IT(cIt, cind);

    for(; (cIt != cEnd) && (cind < climit); ++cIt, ++cind)
    {
        if(*cIt != NULL && (*cIt)->getIgnore() == false)
            (*cIt)->deactivate(pEnv, UInt32(ind));

        if(++ind >= StateChunkClass::getNumSlots(cind))
            ind = 0;
    }
}
ScrollPanelBase::ScrollPanelBase(void) :
    Inherited(),
    _sfView                   (NULL),
    _sfInternalVerticalScrollBar(NULL),
    _sfInternalHorizontalScrollBar(NULL),
    _sfVerticalScrollBarDisplayPolicy(UInt32(ScrollPanel::SCROLLBAR_AS_NEEDED)),
    _sfHorizontalScrollBarDisplayPolicy(UInt32(ScrollPanel::SCROLLBAR_AS_NEEDED)),
    _sfVerticalResizePolicy   (UInt32(ScrollPanel::NO_RESIZE)),
    _sfHorizontalResizePolicy (UInt32(ScrollPanel::NO_RESIZE)),
    _sfVerticalScrollBarAlignment(UInt32(ScrollPanel::SCROLLBAR_ALIGN_RIGHT)),
    _sfHorizontalScrollBarAlignment(UInt32(ScrollPanel::SCROLLBAR_ALIGN_BOTTOM)),
    _sfVerticalRangeModel     (NULL),
    _sfHorizontalRangeModel   (NULL)
{
}
示例#26
0
void SceneFileHandlerBase::readProgress(void * OSG_CHECK_ARG(data))
{
    SceneFileHandlerBase *the = SceneFileHandler::the();

    if(the->_readProgressFP == NULL || the->_progressData.is == NULL)
        return;

    UInt32 p = 0;

    while(p < 100 && !the->_readReady)
    {
        if(!the->_progressData.is->eof() &&
           !the->_progressData.is->bad())
        {
            UInt64 pos = the->_progressData.is->tellg();
            p = UInt32((pos * 100) / the->_progressData.length);
            if(p > 100)
                p = 100;
        }
        else
        {
            p = 100;
        }

        the->_readProgressFP(p);

        if(the->_useProgressThread)
        {
            osgSleep(100);
        }
        else
        {
            break;
        }
    }

    if(the->_useProgressThread && p < 100)
    {
        the->_readProgressFP(100);
    }
}
示例#27
0
文件: main.cpp 项目: ebakan/SMS
double PrepareFileAU (CAAudioUnit &au, CAStreamBasicDescription &fileFormat, AudioFileID audioFile)
{	
// 
		// calculate the duration
	UInt64 nPackets;
	UInt32 propsize = sizeof(nPackets);
	XThrowIfError (AudioFileGetProperty(audioFile, kAudioFilePropertyAudioDataPacketCount, &propsize, &nPackets), "kAudioFilePropertyAudioDataPacketCount");
		
	Float64 fileDuration = (nPackets * fileFormat.mFramesPerPacket) / fileFormat.mSampleRate;

	ScheduledAudioFileRegion rgn;
	memset (&rgn.mTimeStamp, 0, sizeof(rgn.mTimeStamp));
	rgn.mTimeStamp.mFlags = kAudioTimeStampSampleTimeValid;
	rgn.mTimeStamp.mSampleTime = 0;
	rgn.mCompletionProc = NULL;
	rgn.mCompletionProcUserData = NULL;
	rgn.mAudioFile = audioFile;
	rgn.mLoopCount = 1;
	rgn.mStartFrame = 0;
	rgn.mFramesToPlay = UInt32(nPackets * fileFormat.mFramesPerPacket);
		
		// tell the file player AU to play all of the file
	XThrowIfError (au.SetProperty (kAudioUnitProperty_ScheduledFileRegion, 
			kAudioUnitScope_Global, 0,&rgn, sizeof(rgn)), "kAudioUnitProperty_ScheduledFileRegion");
	
		// prime the fp AU with default values
	UInt32 defaultVal = 0;
	XThrowIfError (au.SetProperty (kAudioUnitProperty_ScheduledFilePrime, 
			kAudioUnitScope_Global, 0, &defaultVal, sizeof(defaultVal)), "kAudioUnitProperty_ScheduledFilePrime");

		// tell the fp AU when to start playing (this ts is in the AU's render time stamps; -1 means next render cycle)
	AudioTimeStamp startTime;
	memset (&startTime, 0, sizeof(startTime));
	startTime.mFlags = kAudioTimeStampSampleTimeValid;
	startTime.mSampleTime = -1;
	XThrowIfError (au.SetProperty(kAudioUnitProperty_ScheduleStartTimeStamp, 
			kAudioUnitScope_Global, 0, &startTime, sizeof(startTime)), "kAudioUnitProperty_ScheduleStartTimeStamp");

	return fileDuration;
}
示例#28
0
static void generateJSONString(Error& error, const HOutputStream& out, const UTF8& s)
{
	UTF16Buffer sb(2 + s.length() + 1);

	sb << '"';

	if (error)
		return;

	for (const Chr8* p = s.ptr(); (*p) != '\0'; p++)
	{
		Chr8 c = *p;

		switch (c)
		{
		case '\"' : sb << '\\' << '\"'; break;
		case '\\' : sb << '\\' << '\\'; break;
		case '/' :  sb << '\\' << '/'; break;
		case '\b' : sb << '\\' << 'b'; break;
		case '\f' : sb << '\\' << 'f'; break;
		case '\n' : sb << '\\' << 'n'; break;
		case '\r' : sb << '\\' << 'r'; break;
		case '\t' : sb << '\\' << 't'; break;
		default:
			if (c >= 0x20)
			{
				sb << c;
			}
			else
			{
				sb << UTF8("\\u00") << UTF8::format("%.2X",UInt32(c));
			}
		break;
		}
	}

	sb << '"';

	out->twrite(error, UTF8(sb));
};
void CallbackDrawTask::dump(UInt32 uiIndent)
{
    for(UInt32 i = 0; i < uiIndent; ++i) { fprintf(stderr, " "); }
    fprintf(stderr, "CallbackDrawTask : ");

    switch(_uiTypeTask)
    {
        case Callback:
        {
            fprintf(stderr, "Callback, barrier active : %d\n",
                    UInt32(_bBarrierActive));
        }
        break;

        default:
        {
            fprintf(stderr, "Unknown\n");
        }
        break;
    }

}
示例#30
0
ActionBase::ResultE Switch::intersect(Action *action)
{
    ActionBase::ResultE  returnValue = ActionBase::Continue;
    IntersectAction     *ia          = dynamic_cast<IntersectAction *>(action);

    if((getChoice()         >= 0              ) && 
       (UInt32(getChoice()) <  ia->getNNodes())   )
    {
        ia->useNodeList(                        );
        ia->addNode    (ia->getNode(getChoice()));
    }
    else if(getChoice() == ALL)
    {
        returnValue = ActionBase::Continue;
    }
    else
    {
        returnValue = ActionBase::Skip;
    }

    return returnValue;
}