void asCObjectType::DropFromEngine() { DestroyInternal(); // If the ref counter reached zero while doing the above clean-up then we must delete the object now if( refCount.get() == 0 ) asDELETE(this, asCObjectType); }
asCObjectType::~asCObjectType() { if( engine == 0 ) return; // TODO: 2.30.0: redesign: Shouldn't this have been done already? DestroyInternal(); }
void r3dTexture::Unload() { if( ( m_Loaded || Flags&fCreated ) && !( Flags & fRenderTarget ) ) { int size = -(int) GetTextureSizeInVideoMemory() ; UpdateTextureStats( size ) ; } DestroyInternal() ; InterlockedExchange( &m_Loaded, 0 ) ; }
// internal asCScriptFunction::~asCScriptFunction() { // Dummy functions that are allocated on the stack are not reference counted asASSERT( funcType == asFUNC_DUMMY || (externalRefCount.get() == 0 && internalRefCount.get() == 0) ); // Remove the script function from the engine's scriptFunctions array here // Don't remove it before, because there may still be functions referring to it // by index until now. If it was removed in DestroyInternal, those would not // be able to release the refcount, thus causing memory leak. if( engine && id != 0 && funcType != asFUNC_DUMMY ) engine->RemoveScriptFunction(this); // If the engine pointer is 0, then DestroyInternal has already been called and there is nothing more to do if( engine == 0 ) return; DestroyInternal(); // Finally set the engine pointer to 0 because it must not be accessed again engine = 0; }
// internal asCScriptFunction::~asCScriptFunction() { // Dummy functions that are allocated on the stack are not reference counted asASSERT( funcType == asFUNC_DUMMY || refCount.get() == 0 ); // If the engine pointer is 0, then DestroyInternal has already been called and there is nothing more to do if( engine == 0 ) return; DestroyInternal(); // Tell engine to free the function id. This will make it impossible to // refer to the function by id. Where this is done, it is quite possible // they will leak. if( funcType != -1 && funcType != asFUNC_IMPORTED && id ) engine->FreeScriptFunctionId(id); id = 0; // Finally set the engine pointer to 0 because it must not be accessed again engine = 0; }
void r3dTexture::Destroy() { r3d_assert( Flags & fCreated ) ; if( !( Flags & fRenderTarget ) ) { int size = -GetTextureSizeInVideoMemory() ; UpdateTextureStats( size ) ; } DestroyInternal() ; Flags &= ~fCreated ; InterlockedExchange( &m_Loaded, 0 ) ; r3d_assert(Instances == 1); Instances = 0; r3d_assert(m_iNumTextures>0); m_iNumTextures = 0 ; }
asCObjectType::~asCObjectType() { DestroyInternal(); }
asCFuncdefType::~asCFuncdefType() { DestroyInternal(); }
asCTypedefType::~asCTypedefType() { DestroyInternal(); }
/* ======================== idSoundVoice_OpenAL::Create ======================== */ void idSoundVoice_OpenAL::Create( const idSoundSample* leadinSample_, const idSoundSample* loopingSample_ ) { if( IsPlaying() ) { // This should never hit Stop(); return; } triggered = true; leadinSample = ( idSoundSample_OpenAL* )leadinSample_; loopingSample = ( idSoundSample_OpenAL* )loopingSample_; if( alIsSource( openalSource ) && CompatibleFormat( leadinSample ) ) { sampleRate = leadinSample->format.basic.samplesPerSec; } else { DestroyInternal(); formatTag = leadinSample->format.basic.formatTag; numChannels = leadinSample->format.basic.numChannels; sampleRate = leadinSample->format.basic.samplesPerSec; //soundSystemLocal.hardware.pXAudio2->CreateSourceVoice( &pSourceVoice, ( const WAVEFORMATEX* )&leadinSample->format, XAUDIO2_VOICE_USEFILTER, 4.0f, &streamContext ); CheckALErrors(); alGenSources( 1, &openalSource ); if( CheckALErrors() != AL_NO_ERROR ) //if( pSourceVoice == NULL ) { // If this hits, then we are most likely passing an invalid sample format, which should have been caught by the loader (and the sample defaulted) return; } alSourcef( openalSource, AL_ROLLOFF_FACTOR, 0.0f ); //if( ( loopingSample == NULL && leadinSample->openalBuffer != 0 ) || ( loopingSample != NULL && soundShader->entries[0]->hardwareBuffer ) ) if( leadinSample->openalBuffer != 0 ) { alSourcei( openalSource, AL_BUFFER, 0 ); // handle uncompressed (non streaming) single shot and looping sounds /* if( triggered ) { alSourcei( openalSource, AL_BUFFER, looping ? chan->soundShader->entries[0]->openalBuffer : leadinSample->openalBuffer ); } */ } else { //if( triggered ) // handle streaming sounds (decode on the fly) both single shot AND looping alSourcei( openalSource, AL_BUFFER, 0 ); alDeleteBuffers( 3, &lastopenalStreamingBuffer[0] ); lastopenalStreamingBuffer[0] = openalStreamingBuffer[0]; lastopenalStreamingBuffer[1] = openalStreamingBuffer[1]; lastopenalStreamingBuffer[2] = openalStreamingBuffer[2]; alGenBuffers( 3, &openalStreamingBuffer[0] ); /* if( soundSystemLocal.alEAXSetBufferMode ) { soundSystemLocal.alEAXSetBufferMode( 3, &chan->openalStreamingBuffer[0], alGetEnumValue( ID_ALCHAR "AL_STORAGE_ACCESSIBLE" ) ); } */ openalStreamingBuffer[0]; openalStreamingBuffer[1]; openalStreamingBuffer[2]; } if( s_debugHardware.GetBool() ) { if( loopingSample == NULL || loopingSample == leadinSample ) { idLib::Printf( "%dms: %i created for %s\n", Sys_Milliseconds(), openalSource, leadinSample ? leadinSample->GetName() : "<null>" ); } else { idLib::Printf( "%dms: %i created for %s and %s\n", Sys_Milliseconds(), openalSource, leadinSample ? leadinSample->GetName() : "<null>", loopingSample ? loopingSample->GetName() : "<null>" ); } } } sourceVoiceRate = sampleRate; //pSourceVoice->SetSourceSampleRate( sampleRate ); //pSourceVoice->SetVolume( 0.0f ); alSourcei( openalSource, AL_SOURCE_RELATIVE, AL_TRUE ); alSource3f( openalSource, AL_POSITION, 0.0f, 0.0f, 0.0f ); // RB: FIXME 0.0f ? alSourcef( openalSource, AL_GAIN, 1.0f ); //OnBufferStart( leadinSample, 0 ); }
/* ======================== idSoundVoice_OpenAL::~idSoundVoice_OpenAL ======================== */ idSoundVoice_OpenAL::~idSoundVoice_OpenAL() { DestroyInternal(); }