reference counting changes
This commit is contained in:
parent
2a311939b5
commit
fa1e185e73
|
|
@ -24,8 +24,10 @@
|
|||
|
||||
#include "load_dso.h"
|
||||
|
||||
TypeHandle AudioManager::_type_handle;
|
||||
|
||||
namespace {
|
||||
AudioManager* create_NullAudioManger() {
|
||||
PT(AudioManager) create_NullAudioManger() {
|
||||
audio_debug("create_NullAudioManger()");
|
||||
return new NullAudioManager();
|
||||
}
|
||||
|
|
@ -41,7 +43,7 @@ register_AudioManager_creator(Create_AudioManager_proc* proc) {
|
|||
|
||||
|
||||
// Factory method for getting a platform specific AudioManager:
|
||||
AudioManager* AudioManager::
|
||||
PT(AudioManager) AudioManager::
|
||||
create_AudioManager() {
|
||||
audio_debug("create_AudioManager()\n audio_library_name=\""
|
||||
<<*audio_library_name<<"\"");
|
||||
|
|
@ -59,7 +61,7 @@ create_AudioManager() {
|
|||
nassertr(_create_AudioManager==create_NullAudioManger, 0);
|
||||
} else {
|
||||
// ...the library will register itself with the AudioManager.
|
||||
#if defined(WIN32) && !defined(NDEBUG) //[
|
||||
#if defined(DWORD) && defined(WIN32) && !defined(NDEBUG) //[
|
||||
const int bufLen=256;
|
||||
char path[bufLen];
|
||||
DWORD count = GetModuleFileName((HMODULE)lib, path, bufLen);
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@
|
|||
#include "config_audio.h"
|
||||
#include "audioSound.h"
|
||||
|
||||
typedef AudioManager* Create_AudioManager_proc();
|
||||
typedef PT(AudioManager) Create_AudioManager_proc();
|
||||
|
||||
|
||||
class EXPCL_PANDA AudioManager {
|
||||
class EXPCL_PANDA AudioManager : public TypedReferenceCount {
|
||||
PUBLISHED:
|
||||
// Create an AudioManager for each category of sounds you have.
|
||||
// E.g.
|
||||
|
|
@ -39,12 +39,12 @@ PUBLISHED:
|
|||
// You own the AudioManager*, please delete it when you're done with it.
|
||||
// Do not delete the AudioManager (i.e. you're not done with it), until
|
||||
// you have deleted all the associated AudioSounds.
|
||||
static AudioManager* create_AudioManager();
|
||||
static PT(AudioManager) create_AudioManager();
|
||||
virtual ~AudioManager() {}
|
||||
|
||||
// Get a sound:
|
||||
// You own this sound. Be sure to delete it when you're done.
|
||||
virtual AudioSound* get_sound(const string& file_name) = 0;
|
||||
virtual PT(AudioSound) get_sound(const string& file_name) = 0;
|
||||
// Tell the AudioManager there is no need to keep this one cached.
|
||||
virtual void drop_sound(const string& file_name) = 0;
|
||||
|
||||
|
|
@ -74,6 +74,26 @@ protected:
|
|||
AudioManager() {
|
||||
// intentionally blank.
|
||||
}
|
||||
|
||||
public:
|
||||
// type stuff
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
}
|
||||
static void init_type() {
|
||||
TypedReferenceCount::init_type();
|
||||
register_type(_type_handle, "AudioManager",
|
||||
TypedReferenceCount::get_class_type());
|
||||
}
|
||||
virtual TypeHandle get_type() const {
|
||||
return get_class_type();
|
||||
}
|
||||
virtual TypeHandle force_init_type() {
|
||||
init_type();
|
||||
return get_class_type();
|
||||
}
|
||||
private:
|
||||
static TypeHandle _type_handle;
|
||||
};
|
||||
|
||||
#include "audioManager.I"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
int MilesAudioManager::_active_managers;
|
||||
HDLSFILEID MilesAudioManager::_dls_field;
|
||||
|
||||
AudioManager* Create_AudioManager() {
|
||||
PT(AudioManager) Create_AudioManager() {
|
||||
audio_debug("Create_AudioManger()");
|
||||
return new MilesAudioManager();
|
||||
}
|
||||
|
|
@ -143,9 +143,9 @@ load(Filename file_name) {
|
|||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
AudioSound* MilesAudioManager::
|
||||
PT(AudioSound) MilesAudioManager::
|
||||
get_sound(const string& file_name) {
|
||||
audio_debug("MilesAudioManager::get_sound(file_name=\""<<file_name<<"\"");
|
||||
audio_debug("MilesAudioManager::get_sound(file_name=\""<<file_name<<"\")");
|
||||
Filename path = file_name;
|
||||
path.resolve_filename(get_sound_path());
|
||||
audio_debug(" resolved file_name is '"<<path<<"'");
|
||||
|
|
@ -177,7 +177,7 @@ get_sound(const string& file_name) {
|
|||
}
|
||||
}
|
||||
// Create an AudioSound from the sound:
|
||||
AudioSound* audioSound = 0;
|
||||
PT(AudioSound) audioSound = 0;
|
||||
if (audio) {
|
||||
MilesAudioSound* milesAudioSound
|
||||
=new MilesAudioSound(*this, audio, (*si).first);
|
||||
|
|
@ -198,7 +198,7 @@ get_sound(const string& file_name) {
|
|||
void MilesAudioManager::
|
||||
drop_sound(const string& file_name) {
|
||||
audio_debug("MilesAudioManager::drop_sound(file_name=\""
|
||||
<<file_name<<"\"");
|
||||
<<file_name<<"\")");
|
||||
Filename path = file_name;
|
||||
path.resolve_filename(get_sound_path());
|
||||
audio_debug(" path=\""<<path<<"\"");
|
||||
|
|
@ -217,7 +217,7 @@ drop_sound(const string& file_name) {
|
|||
void MilesAudioManager::
|
||||
release_sound(MilesAudioSound* audioSound) {
|
||||
audio_debug("MilesAudioManager::release_sound(audioSound=\""
|
||||
<<audioSound->get_name()<<"\"");
|
||||
<<audioSound->get_name()<<"\")");
|
||||
_soundsOnLoan.erase(audioSound);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public:
|
|||
MilesAudioManager();
|
||||
~MilesAudioManager();
|
||||
|
||||
AudioSound* get_sound(const string& file_name);
|
||||
PT(AudioSound) get_sound(const string& file_name);
|
||||
void drop_sound(const string& file_name);
|
||||
|
||||
void set_volume(float volume);
|
||||
|
|
@ -58,7 +58,7 @@ private:
|
|||
friend MilesAudioSound;
|
||||
};
|
||||
|
||||
EXPCL_MILES_AUDIO AudioManager* Create_AudioManager();
|
||||
EXPCL_MILES_AUDIO PT(AudioManager) Create_AudioManager();
|
||||
|
||||
|
||||
#endif //]
|
||||
|
|
|
|||
Loading…
Reference in New Issue