00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __FMOD_AUDIO_MANAGER_H__
00021 #define __FMOD_AUDIO_MANAGER_H__
00022
00023 #include <pandabase.h>
00024 #ifdef HAVE_FMOD //[
00025
00026 #include "audioManager.h"
00027 class FmodAudioSound;
00028 #include "filename.h"
00029 #include "pdeque.h"
00030 #include "pmap.h"
00031 #include "pset.h"
00032
00033 #include <fmod.h>
00034
00035 class EXPCL_FMOD_AUDIO FmodAudioManager : public AudioManager {
00036
00037
00038
00039
00040 public:
00041 FmodAudioManager();
00042 virtual ~FmodAudioManager();
00043
00044 virtual bool is_valid();
00045
00046 virtual PT(AudioSound) get_sound(const string&);
00047 virtual void uncache_sound(const string&);
00048 virtual void clear_cache();
00049 virtual void set_cache_limit(int);
00050 virtual int get_cache_limit();
00051
00052
00053 void most_recently_used(const string& path);
00054
00055
00056 void uncache_a_sound();
00057
00058 virtual void set_volume(float);
00059 virtual float get_volume();
00060
00061 virtual void set_active(bool);
00062 virtual bool get_active();
00063 void stop_all_sounds();
00064
00065 protected:
00066
00067
00068 void inc_refcount(const string& file_name);
00069 void dec_refcount(const string& file_name);
00070 private:
00071 typedef struct {
00072 size_t size;
00073 unsigned int refcount;
00074 bool stale;
00075 char *data;
00076 } SoundCacheEntry;
00077 typedef pmap<string, SoundCacheEntry > SoundMap;
00078 SoundMap _sounds;
00079
00080 typedef pset<FmodAudioSound* > AudioSet;
00081
00082 AudioSet _soundsOnLoan;
00083
00084
00085 typedef pdeque<string> LRU;
00086 LRU _lru;
00087
00088 void release_sound(FmodAudioSound *audioSound);
00089
00090 int _cache_limit;
00091 static int _active_managers;
00092 bool _is_valid;
00093 bool _active;
00094
00095 char* load(const Filename& filename, size_t &size) const;
00096
00097 friend class FmodAudioSound;
00098 };
00099
00100 EXPCL_FMOD_AUDIO PT(AudioManager) Create_AudioManager();
00101
00102 #endif //]
00103
00104 #endif