Panda3D
globalMilesManager.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file globalMilesManager.h
10  * @author drose
11  * @date 2007-07-26
12  */
13 
14 #ifndef GLOBALMILESMANAGER_H
15 #define GLOBALMILESMANAGER_H
16 
17 #include "pandabase.h"
18 #ifdef HAVE_RAD_MSS //[
19 
20 #include "pset.h"
21 #include "lightMutex.h"
22 #include "lightMutexHolder.h"
23 
24 #include <mss.h>
25 
26 #ifndef UINTa
27 #define UINTa U32
28 #endif
29 
30 #ifndef SINTa
31 #define SINTa S32
32 #endif
33 
34 class MilesAudioSample;
35 class MilesAudioSequence;
36 
37 /**
38  * This is a wrapper around the parts of the Miles API that should only be
39  * created once. This represents the global data common to all
40  * MilesAudioManagers.
41  */
42 class EXPCL_MILES_AUDIO GlobalMilesManager {
43 private:
44  GlobalMilesManager();
45 
46 public:
47  void add_manager(MilesAudioManager *manager);
48  void remove_manager(MilesAudioManager *manager);
49  void cleanup();
50  INLINE bool is_open() const;
51 
52  bool get_sample(HSAMPLE &sample, size_t &index, MilesAudioSample *sound);
53  void release_sample(size_t index, MilesAudioSample *sound);
54  INLINE int get_num_samples() const;
55 
56  bool get_sequence(HSEQUENCE &sequence, size_t &index, MilesAudioSequence *sound);
57  void release_sequence(size_t index, MilesAudioSequence *sound);
58  INLINE int get_num_sequences() const;
59 
60  void force_midi_reset();
61 
62  static GlobalMilesManager *get_global_ptr();
63 
64 public:
65  HDIGDRIVER _digital_driver;
66  HMDIDRIVER _midi_driver;
67 
68  // For software MIDI:
69  HDLSDEVICE _dls_device;
70  HDLSFILEID _dls_file;
71  vector_uchar _dls_data;
72 
73 private:
74  void open_api();
75  void close_api();
76 
77  static U32 AILCALLBACK open_callback(char const *filename, UINTa *file_handle);
78  static void AILCALLBACK close_callback(UINTa file_handle);
79  static S32 AILCALLBACK seek_callback(UINTa file_handle, S32 offset, U32 type);
80  static U32 AILCALLBACK read_callback(UINTa file_handle, void *buffer, U32 bytes);
81 
82 
83 private:
84  bool _is_open;
85 
86  typedef pset<MilesAudioManager *> Managers;
87  Managers _managers;
88  LightMutex _managers_lock;
89 
90  class SampleData {
91  public:
92  HSAMPLE _sample;
93  MilesAudioSample *_sound;
94  };
95 
96  typedef pvector<SampleData> Samples;
97  Samples _samples;
98  LightMutex _samples_lock;
99 
100  class SequenceData {
101  public:
102  HSEQUENCE _sequence;
103  MilesAudioSequence *_sound;
104  };
105 
106  typedef pvector<SequenceData> Sequences;
107  Sequences _sequences;
108  LightMutex _sequences_lock;
109 
110  static GlobalMilesManager *_global_ptr;
111 };
112 
113 #include "globalMilesManager.I"
114 
115 #endif //]
116 
117 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
This is our own Panda specialization on the default STL set.
Definition: pset.h:49
This is a standard, non-reentrant mutex, similar to the Mutex class.
Definition: lightMutex.h:39