00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __MILES_AUDIO_MANAGER_H__ //[
00021 #define __MILES_AUDIO_MANAGER_H__
00022
00023 #include <pandabase.h>
00024 #ifdef HAVE_RAD_MSS //[
00025
00026 #include "audioManager.h"
00027 #include "mss.h"
00028 #include "pset.h"
00029 #include "pmap.h"
00030 #include "pdeque.h"
00031
00032 class MilesAudioSound;
00033
00034 class EXPCL_MILES_AUDIO MilesAudioManager: public AudioManager {
00035 public:
00036
00037
00038 MilesAudioManager();
00039 ~MilesAudioManager();
00040
00041 bool is_valid();
00042
00043 PT(AudioSound) get_sound(const string& file_name);
00044 void uncache_sound(const string& file_name);
00045 void clear_cache();
00046 void set_cache_limit(int count);
00047 int get_cache_limit();
00048
00049 void set_volume(float volume);
00050 float get_volume();
00051
00052 void set_active(bool active);
00053 bool get_active();
00054 void stop_all_sounds();
00055 void forceMidiReset();
00056
00057
00058
00059 static HDLSFILEID _dls_field;
00060
00061 private:
00062
00063 typedef pmap<string, HAUDIO > SoundMap;
00064 SoundMap _sounds;
00065
00066 typedef pset<MilesAudioSound* > AudioSet;
00067
00068 AudioSet _soundsOnLoan;
00069
00070
00071 typedef pdeque<const string* > LRU;
00072 LRU _lru;
00073
00074 float _volume;
00075 bool _active;
00076 int _cache_limit;
00077
00078 static int _active_managers;
00079
00080 bool _is_valid;
00081 bool _bHasMidiSounds;
00082
00083 HAUDIO load(Filename file_name);
00084
00085 void release_sound(MilesAudioSound* audioSound);
00086
00087 void most_recently_used(const string& path);
00088 void uncache_a_sound();
00089
00090
00091 bool get_registry_entry(HKEY base,
00092 const char* subKeyName,
00093 const char* keyName,
00094 string& result);
00095
00096 void get_gm_file_path(string& result);
00097
00098
00099
00100 static U32 AILCALLBACK vfs_open_callback(const char *filename, U32 *file_handle);
00101 static U32 AILCALLBACK vfs_read_callback(U32 file_handle, void *buffer, U32 bytes);
00102 static S32 AILCALLBACK vfs_seek_callback(U32 file_handle, S32 offset, U32 type);
00103 static void AILCALLBACK vfs_close_callback(U32 file_handle);
00104
00105 friend MilesAudioSound;
00106 };
00107
00108 EXPCL_MILES_AUDIO PT(AudioManager) Create_AudioManager();
00109
00110
00111 #endif //]
00112
00113 #endif //]
00114
00115