Panda3D
|
00001 // Filename: globalMilesManager.h 00002 // Created by: drose (26Jul07) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef GLOBALMILESMANAGER_H 00016 #define GLOBALMILESMANAGER_H 00017 00018 #include "pandabase.h" 00019 #ifdef HAVE_RAD_MSS //[ 00020 00021 #include "mss.h" 00022 #include "pset.h" 00023 #include "lightMutex.h" 00024 #include "lightMutexHolder.h" 00025 00026 #ifndef UINTa 00027 #define UINTa U32 00028 #endif 00029 00030 #ifndef SINTa 00031 #define SINTa S32 00032 #endif 00033 00034 class MilesAudioSample; 00035 class MilesAudioSequence; 00036 00037 //////////////////////////////////////////////////////////////////// 00038 // Class : GlobalMilesManager 00039 // Description : This is a wrapper around the parts of the Miles API 00040 // that should only be created once. This represents 00041 // the global data common to all MilesAudioManagers. 00042 //////////////////////////////////////////////////////////////////// 00043 class EXPCL_MILES_AUDIO GlobalMilesManager { 00044 private: 00045 GlobalMilesManager(); 00046 00047 public: 00048 void add_manager(MilesAudioManager *manager); 00049 void remove_manager(MilesAudioManager *manager); 00050 void cleanup(); 00051 INLINE bool is_open() const; 00052 00053 bool get_sample(HSAMPLE &sample, size_t &index, MilesAudioSample *sound); 00054 void release_sample(size_t index, MilesAudioSample *sound); 00055 INLINE int get_num_samples() const; 00056 00057 bool get_sequence(HSEQUENCE &sequence, size_t &index, MilesAudioSequence *sound); 00058 void release_sequence(size_t index, MilesAudioSequence *sound); 00059 INLINE int get_num_sequences() const; 00060 00061 void force_midi_reset(); 00062 00063 static GlobalMilesManager *get_global_ptr(); 00064 00065 public: 00066 HDIGDRIVER _digital_driver; 00067 HMDIDRIVER _midi_driver; 00068 00069 // For software MIDI: 00070 HDLSDEVICE _dls_device; 00071 HDLSFILEID _dls_file; 00072 pvector<unsigned char> _dls_data; 00073 00074 private: 00075 void open_api(); 00076 void close_api(); 00077 00078 static U32 AILCALLBACK open_callback(char const *filename, UINTa *file_handle); 00079 static void AILCALLBACK close_callback(UINTa file_handle); 00080 static S32 AILCALLBACK seek_callback(UINTa file_handle, S32 offset, U32 type); 00081 static U32 AILCALLBACK read_callback(UINTa file_handle, void *buffer, U32 bytes); 00082 00083 00084 private: 00085 bool _is_open; 00086 00087 typedef pset<MilesAudioManager *> Managers; 00088 Managers _managers; 00089 LightMutex _managers_lock; 00090 00091 class SampleData { 00092 public: 00093 HSAMPLE _sample; 00094 MilesAudioSample *_sound; 00095 }; 00096 00097 typedef pvector<SampleData> Samples; 00098 Samples _samples; 00099 LightMutex _samples_lock; 00100 00101 class SequenceData { 00102 public: 00103 HSEQUENCE _sequence; 00104 MilesAudioSequence *_sound; 00105 }; 00106 00107 typedef pvector<SequenceData> Sequences; 00108 Sequences _sequences; 00109 LightMutex _sequences_lock; 00110 00111 static GlobalMilesManager *_global_ptr; 00112 }; 00113 00114 #include "globalMilesManager.I" 00115 00116 #endif //] 00117 00118 #endif 00119 00120 00121