more refcounting

This commit is contained in:
Cary Sandvig 2000-12-06 22:52:42 +00:00
parent 397f403188
commit b7d2a31c69
4 changed files with 11 additions and 15 deletions

View File

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

View File

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

View File

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

View File

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