Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/audiotraits/milesAudioManager.h

Go to the documentation of this file.
00001 // Filename: milesAudioManager.h
00002 // Created by:  skyler (June 6, 2001)
00003 // Prior system by: cary
00004 //
00005 ////////////////////////////////////////////////////////////////////
00006 //
00007 // PANDA 3D SOFTWARE
00008 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00009 //
00010 // All use of this software is subject to the terms of the Panda 3d
00011 // Software license.  You should have received a copy of this license
00012 // along with this source code; you will also find a current copy of
00013 // the license at http://www.panda3d.org/license.txt .
00014 //
00015 // To contact the maintainers of this program write to
00016 // panda3d@yahoogroups.com .
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   // See AudioManager.h for documentation.
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   // Optional Downloadable Sound field for software midi:
00058   // made public so C atexit fn can access it
00059   static HDLSFILEID _dls_field;
00060 
00061 private:
00062   // The sound cache:
00063   typedef pmap<string, HAUDIO > SoundMap;
00064   SoundMap _sounds;
00065 
00066   typedef pset<MilesAudioSound* > AudioSet;
00067   // The offspring of this manager:
00068   AudioSet _soundsOnLoan;
00069 
00070   // The Least Recently Used mechanism:
00071   typedef pdeque<const string* > LRU;
00072   LRU _lru;
00073   // State:
00074   float _volume;
00075   bool _active;
00076   int _cache_limit;
00077   // keep a count for startup and shutdown:
00078   static int _active_managers;
00079   
00080   bool _is_valid;
00081   bool _bHasMidiSounds;
00082   
00083   HAUDIO load(Filename file_name);
00084   // Tell the manager that the sound dtor was called.
00085   void release_sound(MilesAudioSound* audioSound);
00086   
00087   void most_recently_used(const string& path);
00088   void uncache_a_sound();
00089 
00090   // utility function that should be moved to another class:
00091   bool get_registry_entry(HKEY base, 
00092                           const char* subKeyName, 
00093                           const char* keyName, 
00094                           string& result);
00095   // get the default dls file path:
00096   void get_gm_file_path(string& result);
00097 
00098   // These are "callback" functions that implement vfs-style I/O for
00099   // Miles.
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 

Generated on Fri May 2 00:34:33 2003 for Panda by doxygen1.3