MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _releaseAllResources

Method _releaseAllResources

Engine/source/sfx/sfxDevice.cpp:70–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68//-----------------------------------------------------------------------------
69
70void SFXDevice::_releaseAllResources()
71{
72 using namespace SFXInternal;
73
74 // Kill the update thread, if there is one.
75 // Do this first so that further buffer processing
76 // can be done synchronously by us.
77
78 ThreadSafeRef< SFXUpdateThread > sfxThread = UPDATE_THREAD();
79 if( sfxThread != NULL )
80 {
81 gUpdateThread = NULL; // Kill the global reference.
82
83 sfxThread->stop();
84 sfxThread->triggerUpdate();
85 sfxThread->join();
86
87 sfxThread = NULL;
88 }
89
90 // Clean up voices. Do this before cleaning up buffers so that
91 // resources held by voices that are tied to resources held by buffers
92 // get released properly.
93
94 SFXVoice::smVoiceDestroyedSignal.remove( this, &SFXDevice::_removeVoice );
95 for( VoiceIterator voice = mVoices.begin();
96 voice != mVoices.end(); voice++ )
97 ( *voice )->destroySelf();
98 mVoices.clear();
99
100 // Clean up buffers.
101
102 SFXBuffer::smBufferDestroyedSignal.remove( this, &SFXDevice::_removeBuffer );
103 for( BufferIterator buffer = mBuffers.begin();
104 buffer != mBuffers.end(); ++ buffer )
105 if( !( *buffer )->isDead() )
106 ( *buffer )->destroySelf();
107 mBuffers.clear();
108
109 // Flush all asynchronous requests.
110
111 THREAD_POOL().flushWorkItems();
112
113 // Clean out the buffer update list and kill
114 // all buffers that surfaced on the dead list.
115 // Now the sound buffers are really gone.
116
117 UPDATE_LIST().process();
118 PurgeDeadBuffers();
119
120 // Clean out stats.
121
122 mStatNumBuffers = 0;
123 mStatNumVoices = 0;
124 mStatNumBufferBytes = 0;
125}
126
127//-----------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 13

UPDATE_THREADFunction · 0.85
PurgeDeadBuffersFunction · 0.85
triggerUpdateMethod · 0.80
isDeadMethod · 0.80
flushWorkItemsMethod · 0.80
stopMethod · 0.45
joinMethod · 0.45
removeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
destroySelfMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected