Browse Source

add exclusive mode

cxgeorge 23 năm trước cách đây
mục cha
commit
dd2b927420
2 tập tin đã thay đổi với 13 bổ sung4 xóa
  1. 7 0
      panda/src/audio/audioManager.cxx
  2. 6 4
      panda/src/audio/audioManager.h

+ 7 - 0
panda/src/audio/audioManager.cxx

@@ -41,6 +41,7 @@ register_AudioManager_creator(Create_AudioManager_proc* proc) {
 }
 
 
+
 // Factory method for getting a platform specific AudioManager:
 PT(AudioManager) AudioManager::
 create_AudioManager() {
@@ -78,7 +79,13 @@ create_AudioManager() {
   if (!am->is_valid()) {
     am = create_NullAudioManger();
   }
+  am->_bExclusive = false;
   return am;
 }
 
+void AudioManager::
+set_mutually_exclusive(bool bExclusive) {
+  _bExclusive = bExclusive;
+}
+
 

+ 6 - 4
panda/src/audio/audioManager.h

@@ -36,11 +36,8 @@ PUBLISHED:
   //   my_sound = MySoundEffects.get_sound("neatSfx.mp3");
   //   my_music = MyMusicManager.get_sound("introTheme.mid");
 
-  // bOneAtATime: if true, turn off any currently-playing sounds before playing
-  //              a new one (useful for midi songs)
-static PT(AudioManager) create_AudioManager(/*bool bOneAtATime*/);
+  static PT(AudioManager) create_AudioManager();
   virtual ~AudioManager() {}
-  
   virtual bool is_valid() = 0;
   
   // Get a sound:
@@ -56,6 +53,10 @@ static PT(AudioManager) create_AudioManager(/*bool bOneAtATime*/);
   virtual void set_cache_limit(int count) = 0;
   virtual int get_cache_limit() = 0;
 
+  // if set, turn off any currently-playing sounds before playing
+  // a new one (useful for midi songs)
+  void set_mutually_exclusive(bool bExclusive);
+
   // Control volume:
   // FYI:
   //   If you start a sound with the volume off and turn the volume 
@@ -81,6 +82,7 @@ public:
 
 protected:
   static Create_AudioManager_proc* _create_AudioManager;
+  bool _bExclusive;
 
   AudioManager() {
     // intentionally blank.