Browse Source

more debugging

Cary Sandvig 25 years ago
parent
commit
51d9d1a928
2 changed files with 13 additions and 13 deletions
  1. 7 1
      panda/src/audio/audio_manager.cxx
  2. 6 12
      panda/src/audio/audio_pool.cxx

+ 7 - 1
panda/src/audio/audio_manager.cxx

@@ -85,6 +85,9 @@ AudioManager* AudioManager::get_ptr(void) {
 //  Description: get the player off the sound, and start it playing
 //  Description: get the player off the sound, and start it playing
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void AudioManager::ns_play(AudioSound* sound, float start_time) {
 void AudioManager::ns_play(AudioSound* sound, float start_time) {
+  if (audio_cat->is_debug())
+    audio_cat->debug() << "AudioManager: playing sound 0x" << (void*)sound
+		       << endl;
   if (sound->status() == AudioSound::PLAYING)
   if (sound->status() == AudioSound::PLAYING)
     this->ns_stop(sound);
     this->ns_stop(sound);
   sound->get_player()->play_sound(sound->get_sound(), sound->get_state(),
   sound->get_player()->play_sound(sound->get_sound(), sound->get_state(),
@@ -97,6 +100,9 @@ void AudioManager::ns_play(AudioSound* sound, float start_time) {
 //  Description: get the player off the sound, and stop it playing
 //  Description: get the player off the sound, and stop it playing
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void AudioManager::ns_stop(AudioSound* sound) {
 void AudioManager::ns_stop(AudioSound* sound) {
+  if (audio_cat->is_debug())
+    audio_cat->debug() << "AudioManager: stopping sound 0x" << (void*)sound
+		       << endl;
   this->ns_set_loop(sound, false);
   this->ns_set_loop(sound, false);
   if (sound->status() == AudioSound::PLAYING)
   if (sound->status() == AudioSound::PLAYING)
     sound->get_player()->stop_sound(sound->get_sound(), sound->get_state());
     sound->get_player()->stop_sound(sound->get_sound(), sound->get_state());
@@ -113,7 +119,7 @@ void AudioManager::ns_set_loop(AudioSound* sound, bool state) {
     _loopset = new LoopSet;
     _loopset = new LoopSet;
   if (state)
   if (state)
     _loopset->insert(sound);
     _loopset->insert(sound);
-  else
+  else if (_loopset->find(sound) != _loopset->end())
     _loopset->erase(sound);
     _loopset->erase(sound);
 }
 }
 
 

+ 6 - 12
panda/src/audio/audio_pool.cxx

@@ -112,16 +112,14 @@ AudioSound* AudioPool::ns_load_sound(Filename filename) {
 //  Description: The nonstatic implementation of release_sound().
 //  Description: The nonstatic implementation of release_sound().
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void AudioPool::ns_release_sound(AudioSound* sound) {
 void AudioPool::ns_release_sound(AudioSound* sound) {
+  if (audio_cat->is_debug())
+    audio_cat->debug() << "AudioPool: releasing sound 0x" << (void*)sound
+		       << endl;
   string filename = sound->get_name();
   string filename = sound->get_name();
   SoundMap::iterator si;
   SoundMap::iterator si;
   si = _sounds.find(filename);
   si = _sounds.find(filename);
-  if (si != _sounds.end() && (*si).second == sound->get_sound()) {
-    // REFCOUNT
-    // don't do this with refcounting
-    //    AudioTraits::SoundClass* sc = (*si).second;
-    //    (*(sc->get_destroy()))(sc);
+  if (si != _sounds.end() && (*si).second == sound->get_sound())
     _sounds.erase(si);
     _sounds.erase(si);
-  }
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -130,12 +128,8 @@ void AudioPool::ns_release_sound(AudioSound* sound) {
 //  Description: The nonstatic implementation of release_all_sounds().
 //  Description: The nonstatic implementation of release_all_sounds().
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void AudioPool::ns_release_all_sounds(void) {
 void AudioPool::ns_release_all_sounds(void) {
-  // REFCOUNT
-  //  for (SoundMap::iterator i=_sounds.begin(); i!=_sounds.end(); ++i) {
-    // don't do this with refcounting
-    //    AudioTraits::SoundClass* sc = (*i).second;
-    //    (*(sc->get_destroy()))(sc);
-  //  }
+  if (audio_cat->is_debug())
+    audio_cat->debug() << "AudioPool: releasing all sounds" << endl;
   _sounds.clear();
   _sounds.clear();
 }
 }