/* * Return the sample buffer of this sound */ IBuffer* CSimpleSound::getBuffer() { if (_Buffer == 0) { // try to find the sample buffer in the sample bank. CAudioMixerUser *audioMixer = CAudioMixerUser::instance(); _Buffer = audioMixer->getSampleBankManager()->get(_Buffername); audioMixer->getSoundBank()->registerBufferAssoc(this, _Buffer); _Registered = true; } return _Buffer; }
bool CSampleBank::unload() { vector<IBuffer*> vec; TSampleTable::iterator it; if (!_Loaded) { nlwarning("Trying to unload an already unloaded bank : %s", CStringMapper::unmap(_Name).c_str ()); return true; } // need to wait end of load ? if (!_LoadingDone) return false; //nlinfo("Unloading sample bank %s", CStringMapper::unmap(_Name).c_str()); for (it = _Samples.begin(); it != _Samples.end(); ++it) { IBuffer *buffer = it->second; if (buffer) { const NLMISC::TStringId & bufferName = buffer->getName(); CAudioMixerUser *audioMixer = _SampleBankManager->m_AudioMixer; // Warn the mixer to stop any track playing this buffer. audioMixer->bufferUnloaded(buffer); // Warn the sound banks about this buffer. audioMixer->getSoundBank()->bufferUnloaded(bufferName); // delete it->second = NULL; delete buffer; } } _Loaded = false; _SampleBankManager->m_LoadedSize -= _ByteSize; _ByteSize = 0; return true; }