mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
fix crash at shutdown
This commit is contained in:
parent
478909b764
commit
a180898666
@ -441,6 +441,8 @@ class ShowBase(DirectObject.DirectObject):
|
||||
if getattr(self, 'musicManager', None):
|
||||
self.musicManager.shutdown()
|
||||
self.musicManager = None
|
||||
for sfxManager in self.sfxManagerList:
|
||||
sfxManager.shutdown()
|
||||
self.sfxManagerList = []
|
||||
if getattr(self, 'loader', None):
|
||||
self.loader.destroy()
|
||||
|
@ -679,8 +679,9 @@ release_sound(MilesAudioSound *audioSound) {
|
||||
<<audioSound->get_name()<<"\"), this = " << (void *)this);
|
||||
LightReMutexHolder holder(_lock);
|
||||
AudioSet::iterator ai = _sounds_on_loan.find(audioSound);
|
||||
nassertv(ai != _sounds_on_loan.end());
|
||||
_sounds_on_loan.erase(ai);
|
||||
if (ai != _sounds_on_loan.end()) {
|
||||
_sounds_on_loan.erase(ai);
|
||||
}
|
||||
|
||||
audio_debug("MilesAudioManager::release_sound() finished");
|
||||
}
|
||||
@ -702,8 +703,10 @@ cleanup() {
|
||||
}
|
||||
|
||||
// Be sure to cleanup associated sounds before cleaning up the manager:
|
||||
AudioSet orig_sounds;
|
||||
orig_sounds.swap(_sounds_on_loan);
|
||||
AudioSet::iterator ai;
|
||||
for (ai = _sounds_on_loan.begin(); ai != _sounds_on_loan.end(); ++ai) {
|
||||
for (ai = orig_sounds.begin(); ai != orig_sounds.end(); ++ai) {
|
||||
(*ai)->cleanup();
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,6 @@ MilesAudioSample::
|
||||
~MilesAudioSample() {
|
||||
miles_audio_debug("~MilesAudioSample()");
|
||||
cleanup();
|
||||
_manager->release_sound(this);
|
||||
miles_audio_debug("~MilesAudioSample() done");
|
||||
}
|
||||
|
||||
@ -123,6 +122,10 @@ play() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void MilesAudioSample::
|
||||
stop() {
|
||||
if (_manager == (MilesAudioManager *)NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
miles_audio_debug("stop()");
|
||||
_manager->stopping_sound(this);
|
||||
// The _paused flag should not be cleared here. _paused is not like
|
||||
@ -279,6 +282,13 @@ status() const {
|
||||
void MilesAudioSample::
|
||||
cleanup() {
|
||||
stop();
|
||||
set_active(false);
|
||||
nassertv(_sample == 0);
|
||||
|
||||
if (_manager != (MilesAudioManager *)NULL) {
|
||||
_manager->release_sound(this);
|
||||
_manager = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -567,6 +577,9 @@ finish_callback(HSAMPLE sample) {
|
||||
milesAudio_cat.debug()
|
||||
<< "finished " << *self << "\n";
|
||||
}
|
||||
if (self->_manager == (MilesAudioManager *)NULL) {
|
||||
return;
|
||||
}
|
||||
self->_manager->_sounds_finished = true;
|
||||
}
|
||||
|
||||
|
@ -152,6 +152,10 @@ set_time(float time) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void MilesAudioSound::
|
||||
set_active(bool active) {
|
||||
if (_manager == (MilesAudioManager *)NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
miles_audio_debug("set_active(active="<<active<<")");
|
||||
if (_active != active) {
|
||||
_active = active;
|
||||
|
@ -54,7 +54,6 @@ MilesAudioStream::
|
||||
miles_audio_debug("~MilesAudioStream()");
|
||||
cleanup();
|
||||
|
||||
_manager->release_sound(this);
|
||||
miles_audio_debug("~MilesAudioStream() done");
|
||||
}
|
||||
|
||||
@ -129,6 +128,9 @@ play() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void MilesAudioStream::
|
||||
stop() {
|
||||
if (_manager == (MilesAudioManager *)NULL) {
|
||||
return;
|
||||
}
|
||||
miles_audio_debug("stop()");
|
||||
_manager->stopping_sound(this);
|
||||
|
||||
@ -286,6 +288,13 @@ cleanup() {
|
||||
if (_stream) {
|
||||
stop();
|
||||
}
|
||||
set_active(false);
|
||||
nassertv(_stream == 0);
|
||||
|
||||
if (_manager != (MilesAudioManager *)NULL) {
|
||||
_manager->release_sound(this);
|
||||
_manager = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -301,6 +310,9 @@ finish_callback(HSTREAM stream) {
|
||||
milesAudio_cat.debug()
|
||||
<< "finished " << *self << "\n";
|
||||
}
|
||||
if (self->_manager == (MilesAudioManager *)NULL) {
|
||||
return;
|
||||
}
|
||||
self->_manager->_sounds_finished = true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user