Browse Source

more refcounting

Cary Sandvig 25 years ago
parent
commit
b7d2a31c69

+ 1 - 1
panda/src/audio/audio_manager.h

@@ -32,7 +32,7 @@ private:
 
   typedef void UpdateFunc(void);
   typedef void ShutdownFunc(void);
-  typedef set<AudioSound*> LoopSet;
+  typedef set<PT(AudioSound)> LoopSet;
   static AudioManager* _global_ptr;
   static UpdateFunc* _update_func;
   static ShutdownFunc* _shutdown_func;

+ 2 - 5
panda/src/audio/audio_pool.I

@@ -24,11 +24,8 @@ INLINE bool AudioPool::has_sound(const string& filename) {
 //               return a valid AudioSound pointer.
 ////////////////////////////////////////////////////////////////////
 INLINE bool AudioPool::verify_sound(const string& filename) {
-  AudioSound* foo = load_sound(filename);
-  bool ret = foo != (AudioSound*)0L;
-  if (ret)
-    delete foo;
-  return ret;
+  PT(AudioSound) foo = load_sound(filename);
+  return !(foo.is_null());
 }
 
 ////////////////////////////////////////////////////////////////////

+ 3 - 5
panda/src/audio/audio_sound.h

@@ -7,9 +7,7 @@
 #define __AUDIO_SOUND_H__
 
 #include "audio_trait.h"
-/*
-#include "typedReferenceCount.h"
-*/
+#include <typedReferenceCount.h>
 #include <typeHandle.h>
 #include <namable.h>
 #include <pointerTo.h>
@@ -19,9 +17,9 @@ class AudioPool;
 class AudioManager;
 
 /*
-class EXPCL_PANDA AudioSound : public TypedReferenceCount, public Namable {
-*/
 class EXPCL_PANDA AudioSound : public TypedObject, public Namable {
+*/
+class EXPCL_PANDA AudioSound : public TypedReferenceCount, public Namable {
 private:
   PT(AudioTraits::SoundClass) _sound;
   AudioTraits::PlayingClass *_state;

+ 5 - 4
panda/src/audio/test_audio.cxx

@@ -18,10 +18,11 @@ main(int argc, char* argv[]) {
     }
 
   {
-    AudioSound* tester = AudioPool::load_sound(argv[1]);
-    AudioPool::release_all_sounds();
-    cerr << "all sounds but 1 released" << endl;
-    delete tester;
+    {
+      PT(AudioSound) tester = AudioPool::load_sound(argv[1]);
+      AudioPool::release_all_sounds();
+      cerr << "all sounds but 1 released" << endl;
+    }
     cerr << "all sounds released" << endl;
   }