| 68 | //----------------------------------------------------------------------------- |
| 69 | |
| 70 | void 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 | //----------------------------------------------------------------------------- |
nothing calls this directly
no test coverage detected