Pārlūkot izejas kodu

adding Miles Sound stuff

Dave Schuyler 24 gadi atpakaļ
vecāks
revīzija
9b82db7d64

+ 7 - 10
direct/src/interval/SoundInterval.py

@@ -25,8 +25,8 @@ class SoundInterval(Interval):
         id = 'Sound-%d' % SoundInterval.soundNum
         SoundInterval.soundNum += 1
         # Record instance variables
-	self.sound = sound
-	self.loop = loop
+        self.sound = sound
+        self.loop = loop
         self.wantSound = base.wantAnySound
         # If no duration given use sound's duration as interval's duration
         if duration == 0.0:
@@ -39,19 +39,19 @@ class SoundInterval(Interval):
                        ' zero sound duration assumed')
                 duration = 0.0
         # Generate unique name if necessary
-	if (name == None):
+        if (name == None):
             name = id
         # Initialize superclass
-	Interval.__init__(self, name, duration)
+        Interval.__init__(self, name, duration)
         # Update stopEvent
         if self.wantSound:
             self.stopEvent = id + '_stopEvent'
             self.stopEventList = [self.stopEvent]
         
     def updateFunc(self, t, event = IVAL_NONE):
-	""" updateFunc(t, event)
+        """ updateFunc(t, event)
         Go to time t
-	"""
+        """
         if not self.wantSound:
             return
         # Update sound based on current time
@@ -66,10 +66,7 @@ class SoundInterval(Interval):
             if (t < 0.1):
                 t = 0.0
             # Start sound
-            AudioManager.play(self.sound, t)
-            # Loop in necessary
-	    if (self.loop):
-		AudioManager.setLoop(self.sound, 1)
+            AudioManager.play(self.sound, t, self.loop)
             # Accept event to kill sound
             self.accept(self.stopEvent, lambda s = self: AudioManager.stop(s.sound))
         # Print debug information

+ 47 - 45
direct/src/showbase/ShowBase.py

@@ -177,17 +177,17 @@ class ShowBase:
         self.messenger = messenger
         self.taskMgr = taskMgr
 
-	# Particle manager
-	self.particleMgr = particleMgr
-	self.particleMgr.setFrameStepping(1)
-	self.particleMgrEnabled = 0
-
-	# Physics manager
-	self.physicsMgr = physicsMgr
-	integrator = LinearEulerIntegrator()
-	self.physicsMgr.attachLinearIntegrator(integrator)
-	self.physicsMgrEnabled = 0
-	self.physicsMgrAngular = 0
+        # Particle manager
+        self.particleMgr = particleMgr
+        self.particleMgr.setFrameStepping(1)
+        self.particleMgrEnabled = 0
+
+        # Physics manager
+        self.physicsMgr = physicsMgr
+        integrator = LinearEulerIntegrator()
+        self.physicsMgr.attachLinearIntegrator(integrator)
+        self.physicsMgrEnabled = 0
+        self.physicsMgrAngular = 0
 
         self.createAudioManager()
         self.createStats()
@@ -221,25 +221,25 @@ class ShowBase:
         self.restart()
 
     def addAngularIntegrator(self):
-	"""addAngularIntegrator(self)"""
-	if (self.physicsMgrAngular == 0):
-	    self.physicsMgrAngular = 1
-	    integrator = AngularEulerIntegrator()
-	    self.physicsMgr.attachAngularIntegrator(integrator)
+        """addAngularIntegrator(self)"""
+        if (self.physicsMgrAngular == 0):
+            self.physicsMgrAngular = 1
+            integrator = AngularEulerIntegrator()
+            self.physicsMgr.attachAngularIntegrator(integrator)
 
     def enableParticles(self):
-	"""enableParticles(self)"""
-	self.particleMgrEnabled = 1
-	self.physicsMgrEnabled = 1
-	self.taskMgr.removeTasksNamed('manager-update')
-	self.taskMgr.spawnTaskNamed(Task.Task(self.updateManagers),
-					'manager-update')
+        """enableParticles(self)"""
+        self.particleMgrEnabled = 1
+        self.physicsMgrEnabled = 1
+        self.taskMgr.removeTasksNamed('manager-update')
+        self.taskMgr.spawnTaskNamed(Task.Task(self.updateManagers),
+                                        'manager-update')
 
     def disableParticles(self):
-	"""enableParticles(self)"""
-	self.particleMgrEnabled = 0
-	self.physicsMgrEnabled = 0
-	self.taskMgr.removeTasksNamed('manager-update')
+        """enableParticles(self)"""
+        self.particleMgrEnabled = 0
+        self.physicsMgrEnabled = 0
+        self.taskMgr.removeTasksNamed('manager-update')
 
     def toggleParticles(self):
         if self.particleMgrEnabled == 0:
@@ -254,13 +254,13 @@ class ShowBase:
         return self.physicsMgrEnabled
 
     def updateManagers(self, state):
-	"""updateManagers(self)"""
-	dt = min(globalClock.getDt(), 0.1)
-	if (self.particleMgrEnabled == 1):
-	    self.particleMgr.doParticles(dt)
-	if (self.physicsMgrEnabled == 1):
-	    self.physicsMgr.doPhysics(dt)
-	return Task.cont
+        """updateManagers(self)"""
+        dt = min(globalClock.getDt(), 0.1)
+        if (self.particleMgrEnabled == 1):
+            self.particleMgr.doParticles(dt)
+        if (self.physicsMgrEnabled == 1):
+            self.physicsMgr.doPhysics(dt)
+        return Task.cont
 
     def createStats(self):
         # You must specify a pstats-host in your configrc
@@ -274,11 +274,17 @@ class ShowBase:
 
     def loadSfx(self, name):
         if (name and base.wantSfx):
-            return loader.loadSound(name)
+            sound=loader.loadSound(name)
+            if sound:
+                sound.setCategory(sound.EFFECT)
+            return sound
 
     def loadMusic(self, name):
         if (name and base.wantMusic):
-            return loader.loadSound(name)
+            sound=loader.loadSound(name)
+            if sound:
+                sound.setCategory(sound.MUSIC)
+            return sound
 
     def unloadSfx(self, sfx):
         if sfx:
@@ -288,29 +294,25 @@ class ShowBase:
         if music:
             loader.unloadSound(music)
 
-    def playSfx(self, sfx, looping = None, interupt = 1, volume = None,
+    def playSfx(self, sfx, looping = 0, interupt = 1, volume = None,
                 time = 0.):
         if (sfx and base.wantSfx):
             if not interupt:
                 if not (sfx.status() == AudioSound.PLAYING):
-                    AudioManager.play(sfx, time)
+                    AudioManager.play(sfx, time, looping)
             else:
-                AudioManager.play(sfx, time)
-            if looping:
-                AudioManager.setLoop(sfx, 1)
+                AudioManager.play(sfx, time, looping)
             if volume:
                 AudioManager.setVolume(sfx, volume)
 
-    def playMusic(self, music, looping = None, interupt = 1, volume = None,
+    def playMusic(self, music, looping = 0, interupt = 1, volume = None,
                   restart = None, time = 0.):
         if (music and base.wantMusic):
             if not interupt:
                 if not (music.status() == AudioSound.PLAYING):
-                    AudioManager.play(music, time)
+                    AudioManager.play(music, time, looping)
             else:
-                AudioManager.play(music, time)
-            if looping:
-                AudioManager.setLoop(music, 1)
+                AudioManager.play(music, time, looping)
             if volume:
                 AudioManager.setVolume(music, volume)
             if restart:

+ 17 - 10
panda/src/audio/Sources.pp

@@ -6,26 +6,33 @@
 #begin lib_target
   #define USE_AUDIO yes
   #define USE_MIKMOD yes
+  #define USE_RAD_MSS yes
 
   #define TARGET audio
   #define LOCAL_LIBS putil ipc gui
 
   #define SOURCES \
-    audio_manager.I audio_manager.cxx audio_manager.h audio_midi.cxx \
-    audio_midi.h audio_pool.I audio_pool.cxx audio_pool.h \
+    audio_manager.I audio_manager.cxx audio_manager.h \
+    audio_midi.cxx audio_midi.h \
+    audio_pool.I audio_pool.cxx audio_pool.h \
     audio_trait.cxx audio_trait.h \
-    config_audio.cxx config_audio.h audio_mikmod_traits.cxx \
-    audio_mikmod_traits.h audio_win_traits.I audio_win_traits.cxx \
-    audio_win_traits.h audio_null_traits.I audio_null_traits.cxx \
-    audio_null_traits.h audio_linux_traits.I audio_linux_traits.cxx \
-    audio_linux_traits.h audio_sound.h audio_sound.I audio_sound.cxx \
+    config_audio.cxx config_audio.h \
+    audio_mikmod_traits.cxx audio_mikmod_traits.h \
+    audio_win_traits.I audio_win_traits.cxx audio_win_traits.h \
+    audio_null_traits.I audio_null_traits.cxx audio_null_traits.h \
+    audio_rad_mss_traits.I audio_rad_mss_traits.cxx audio_rad_mss_traits.h \
+    audio_linux_traits.I audio_linux_traits.cxx audio_linux_traits.h \
+    audio_sound.I audio_sound.cxx audio_sound.h \
     audio_gui_functor.h audio_gui_functor.cxx
 
   #define INSTALL_HEADERS \
-    audio.h audio_manager.h audio_pool.I audio_pool.h \
+    audio.h audio_manager.h \
+    audio_pool.I audio_pool.h \
     audio_trait.h audio_mikmod_traits.h \
-    audio_win_traits.I audio_win_traits.h audio_null_traits.I \
-    audio_null_traits.h audio_linux_traits.I audio_linux_traits.h \
+    audio_win_traits.I audio_win_traits.h \
+    audio_rad_mss_traits.I audio_rad_mss_traits.h \
+    audio_null_traits.I audio_null_traits.h \
+    audio_linux_traits.I audio_linux_traits.h \
     config_audio.h audio_manager.I audio_sound.h audio_sound.I \
     audio_gui_functor.h
 

+ 4 - 59
panda/src/audio/audio_manager.I

@@ -21,9 +21,9 @@
 //       Access: Public, Static
 //  Description: Play some audio
 ////////////////////////////////////////////////////////////////////
-INLINE void AudioManager::play(AudioSound* sound, float start_time) {
+INLINE void AudioManager::play(AudioSound* sound, float start_time, int loop) {
   if (audio_is_active)
-    get_ptr()->ns_play(sound, start_time);
+    get_ptr()->ns_play(sound, start_time, loop);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -88,6 +88,7 @@ INLINE void AudioManager::stop(AudioSound* sound) {
   }
 }
 
+#ifndef AUDIO_USE_RAD_MSS //[
 ////////////////////////////////////////////////////////////////////
 //     Function: AudioManager::stop
 //       Access: Public, Static
@@ -107,6 +108,7 @@ INLINE void AudioManager::set_loop(AudioSound* sound, bool state) {
 INLINE bool AudioManager::get_loop(AudioSound* sound) {
   return get_ptr()->ns_get_loop(sound);
 }
+#endif //]
 
 ////////////////////////////////////////////////////////////////////
 //     Function: AudioManager::Constructor
@@ -122,27 +124,6 @@ INLINE AudioManager::AudioManager() {
   _master_music_volume = audio_master_music_volume;
 }
 
-////////////////////////////////////////////////////////////////////
-//     Function: AudioManager::set_master_sfx_volume
-//       Access: Public, Static
-//  Description: set the overall volume of SFX
-////////////////////////////////////////////////////////////////////
-INLINE void AudioManager::set_master_sfx_volume(float v) {
-  AudioManager::_master_sfx_volume = v;
-  AudioManager::_master_volume_change = true;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: AudioManager::set_master_music_volume
-//       Access: Public, Static
-//  Description: set the overall volume of music
-////////////////////////////////////////////////////////////////////
-INLINE void AudioManager::set_master_music_volume(float v) {
-  get_ptr();
-  AudioManager::_master_music_volume = v;
-  AudioManager::_master_volume_change = true;
-}
-
 ////////////////////////////////////////////////////////////////////
 //     Function: AudioManager::get_master_sfx_volume
 //       Access: Public, Static
@@ -183,42 +164,6 @@ INLINE bool AudioManager::get_all_sound_active() {
   return audio_is_active;
 }
 
-////////////////////////////////////////////////////////////////////
-//     Function: AudioManager::set_sfx_active
-//       Access: Public, Static
-//  Description: turn on/off SFX
-////////////////////////////////////////////////////////////////////
-INLINE void AudioManager::set_sfx_active(bool f) {
-  get_ptr();
-  if (f) {
-    if (AudioManager::_hard_sfx_active) {
-      AudioManager::_sfx_active = f;
-      AudioManager::_master_volume_change = true;
-    }
-  } else {
-    AudioManager::_sfx_active = f;
-    AudioManager::_master_volume_change = true;
-  }
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: AudioManager::set_music_active
-//       Access: Public, Static
-//  Description: turn on/off music
-////////////////////////////////////////////////////////////////////
-INLINE void AudioManager::set_music_active(bool f) {
-  get_ptr();
-  if (f) {
-    if (AudioManager::_hard_music_active) {
-      AudioManager::_music_active = f;
-      AudioManager::_master_volume_change = true;
-    }
-  } else {
-    AudioManager::_music_active = f;
-    AudioManager::_master_volume_change = true;
-  }
-}
-
 ////////////////////////////////////////////////////////////////////
 //     Function: AudioManager::get_sfx_active
 //       Access: Public, Static

+ 192 - 76
panda/src/audio/audio_manager.cxx

@@ -19,12 +19,17 @@
 #include "audio_manager.h"
 #include "config_audio.h"
 
+#ifdef AUDIO_USE_RAD_MSS //[
+#include "mss.h"
+#endif //]
+
+
 // Statics (all default to zero):
 AudioManager* AudioManager::_global_ptr;
 AudioManager::UpdateFunc* AudioManager::_update_func;
 AudioManager::ShutdownFunc* AudioManager::_shutdown_func;
 mutex AudioManager::_manager_mutex;
-bool AudioManager::_quit;
+volatile bool AudioManager::_quit;
 thread* AudioManager::_spawned;
 AudioManager::LoopSet* AudioManager::_loopset;
 AudioManager::LoopSet* AudioManager::_loopcopy;
@@ -84,26 +89,28 @@ copy_loopset() {
 ////////////////////////////////////////////////////////////////////
 void AudioManager::
 ns_update() {
-  // handle looping
-  if (_loopcopy) {
-    LoopSet::iterator i=_loopcopy->begin();
-    for (; i!=_loopcopy->end(); ++i) {
-      AudioSound* sound = *i;
-      if (sound->status() == AudioSound::READY) {
-        audio_debug("AudioManager::ns_update looping '" 
-            << sound->get_name() << "'");
-        AudioManager::play(sound);
-        AudioManager::set_loop(sound, true);
-      } else if (AudioManager::_master_volume_change) {
-        if (sound->get_player()->adjust_volume(sound->get_state())) {
-          audio_debug("AudioManager::ns_update sound is turned "
-              << "off, stopping '" << sound->get_name() << "'");
-          AudioManager::stop(sound);
+  #ifndef AUDIO_USE_RAD_MSS //[
+    // handle looping
+    if (_loopcopy) {
+      LoopSet::iterator i=_loopcopy->begin();
+      for (; i!=_loopcopy->end(); ++i) {
+        AudioSound* sound = *i;
+        if (sound->status() == AudioSound::READY) {
+          audio_debug("AudioManager::ns_update looping '" 
+              << sound->get_name() << "'");
+          AudioManager::play(sound);
+          AudioManager::set_loop(sound, true);
+        } else if (AudioManager::_master_volume_change) {
+          if (sound->get_player()->adjust_volume(sound->get_state())) {
+            audio_debug("AudioManager::ns_update sound is turned "
+                << "off, stopping '" << sound->get_name() << "'");
+            AudioManager::stop(sound);
+          }
         }
       }
     }
-  }
-  AudioManager::_master_volume_change = false;
+    AudioManager::_master_volume_change = false;
+  #endif //]
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -140,15 +147,21 @@ get_ptr() {
 //  Description: get the player off the sound, and start it playing
 ////////////////////////////////////////////////////////////////////
 void AudioManager::
-ns_play(AudioSound* sound, float start_time) {
-  audio_debug("AudioManager: playing sound 0x" 
-      << (void*)sound << " (" << sound->get_name() << ")");
+ns_play(AudioSound* sound, float start_time, int loop) {
+  audio_debug("AudioManager::ns_play(sound=0x"<<(void*)sound<<", start_time="<<start_time<<", loop="<<loop<<")");
+  audio_debug("  name="<<sound->get_name());
   if (sound->status() == AudioSound::PLAYING) {
     this->ns_stop(sound);
   }
-  sound->get_player()->play_sound(sound->get_sound(), 
-      sound->get_state(), start_time);
-  sound->get_player()->adjust_volume(sound->get_state());
+  #ifndef AUDIO_USE_RAD_MSS //[
+    sound->get_player()->play_sound(sound->get_sound(), 
+        sound->get_state(), start_time);
+    ns_set_loop(sound, loop);
+    sound->get_player()->adjust_volume(sound->get_state());
+  #else //][
+    sound->get_player()->play_sound(sound->get_sound(), 
+        sound->get_state(), start_time, loop);
+  #endif //]
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -160,12 +173,15 @@ void AudioManager::
 ns_stop(AudioSound* sound) {
   audio_debug("AudioManager: stopping sound 0x" 
       << (void*)sound << " (" << sound->get_name() << ")");
-  this->ns_set_loop(sound, false);
+  #ifndef AUDIO_USE_RAD_MSS //[
+    this->ns_set_loop(sound, false);
+  #endif //]
   if (sound->status() == AudioSound::PLAYING) {
     sound->get_player()->stop_sound(sound->get_sound(), sound->get_state());
   }
 }
 
+#ifndef AUDIO_USE_RAD_MSS //[
 ////////////////////////////////////////////////////////////////////
 //     Function: AudioManager::ns_set_loop (AudioSound)
 //       Access: Private
@@ -173,15 +189,19 @@ ns_stop(AudioSound* sound) {
 ////////////////////////////////////////////////////////////////////
 void AudioManager::
 ns_set_loop(AudioSound* sound, bool state) {
-  mutex_lock l(_manager_mutex);
-  if (!_loopset) {
-    _loopset = new LoopSet;
-  }
-  if (state) {
-    _loopset->insert(sound);
-  } else {
-    _loopset->erase(sound);
-  }
+  #ifndef AUDIO_USE_RAD_MSS //[
+    mutex_lock l(_manager_mutex);
+    if (!_loopset) {
+      _loopset = new LoopSet;
+    }
+    if (state) {
+      _loopset->insert(sound);
+    } else {
+      _loopset->erase(sound);
+    }
+  #else //][
+    /////sound->get_player()->set_loop_count((state)?0:1);
+  #endif //]
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -198,6 +218,7 @@ ns_get_loop(AudioSound* sound) {
   LoopSet::iterator i = _loopset->find(sound);
   return i != _loopset->end();
 }
+#endif //]
 
 ////////////////////////////////////////////////////////////////////
 //     Function: AudioManager::spawned_update
@@ -206,23 +227,27 @@ ns_get_loop(AudioSound* sound) {
 ////////////////////////////////////////////////////////////////////
 void* AudioManager::
 spawned_update(void* data) {
-  bool* flag = (bool*)data;
-  try {
-    // *flag connects to AudioManager::_quit
-    while (! (*flag)) {
-      AudioManager::update();
-      ipc_traits::sleep(0, audio_auto_update_delay);
+  #ifndef HAVE_RAD_MSS //[
+    bool* flag = (bool*)data;
+    try {
+      // *flag connects to AudioManager::_quit
+      while (! (*flag)) {
+        AudioManager::update();
+        ipc_traits::sleep(0, audio_auto_update_delay);
+      }
+    } catch (...) {
+      audio_error("Uncought Exception in audio update thread.");
+      throw;
     }
-  } catch (...) {
-    audio_error("Uncought Exception in audio update thread.");
-    throw;
-  }
-  // Switch the flag back to false,
-  // so AudioManager::ns_shutdown()
-  // knows we're done:
-  *flag = false;
-  audio_debug("exiting update thread");
-  return 0;
+    // Switch the flag back to false,
+    // so AudioManager::ns_shutdown()
+    // knows we're done:
+    *flag = false;
+    audio_debug("exiting update thread");
+    return 0;
+  #else //][
+    return 0;
+  #endif //]
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -235,6 +260,93 @@ ns_set_volume(AudioSound* sound, float v) {
   sound->get_player()->set_volume(sound->get_state(), v);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: AudioManager::set_master_sfx_volume
+//       Access: Public, Static
+//  Description: set the overall volume of SFX
+////////////////////////////////////////////////////////////////////
+void AudioManager::set_master_sfx_volume(float v) {
+  AudioManager::_master_sfx_volume = v;
+  AudioManager::_master_volume_change = true;
+  #ifdef AUDIO_USE_RAD_MSS //[
+    HDIGDRIVER dig;
+    AIL_quick_handles(&dig, 0, 0);
+    S32 volume=((int)(127*v))%128;
+    AIL_set_digital_master_volume(dig, volume);
+  #endif //]
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: AudioManager::set_master_music_volume
+//       Access: Public, Static
+//  Description: set the overall volume of music
+////////////////////////////////////////////////////////////////////
+void AudioManager::set_master_music_volume(float v) {
+  get_ptr();
+  AudioManager::_master_music_volume = v;
+  AudioManager::_master_volume_change = true;
+  #ifdef AUDIO_USE_RAD_MSS //[
+    HMDIDRIVER mdi;
+    AIL_quick_handles(0, &mdi, 0);
+    S32 volume=((int)(127*v))%128;
+    AIL_set_XMIDI_master_volume(mdi, volume);
+  #endif //]
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: AudioManager::set_sfx_active
+//       Access: Public, Static
+//  Description: turn on/off SFX
+////////////////////////////////////////////////////////////////////
+INLINE void AudioManager::set_sfx_active(bool f) {
+  get_ptr();
+  if (f) {
+    if (AudioManager::_hard_sfx_active) {
+      AudioManager::_sfx_active = f;
+      AudioManager::_master_volume_change = true;
+    }
+  } else {
+    AudioManager::_sfx_active = f;
+    AudioManager::_master_volume_change = true;
+  }
+  #ifdef AUDIO_USE_RAD_MSS //[
+    if (f) {
+      set_master_sfx_volume(_master_sfx_volume);
+    } else {
+      HDIGDRIVER dig;
+      AIL_quick_handles(&dig, 0, 0);
+      AIL_set_digital_master_volume(dig, 0);
+    }
+  #endif //]
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: AudioManager::set_music_active
+//       Access: Public, Static
+//  Description: turn on/off music
+////////////////////////////////////////////////////////////////////
+INLINE void AudioManager::set_music_active(bool f) {
+  get_ptr();
+  if (f) {
+    if (AudioManager::_hard_music_active) {
+      AudioManager::_music_active = f;
+      AudioManager::_master_volume_change = true;
+    }
+  } else {
+    AudioManager::_music_active = f;
+    AudioManager::_master_volume_change = true;
+  }
+  #ifdef AUDIO_USE_RAD_MSS //[
+    if (f) {
+      set_master_music_volume(_master_music_volume);
+    } else {
+      HMDIDRIVER mdi;
+      AIL_quick_handles(0, &mdi, 0);
+      AIL_set_XMIDI_master_volume(mdi, 0);
+    }
+  #endif //]
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: AudioManager::ns_spawn_update
 //       Access: Private
@@ -242,29 +354,31 @@ ns_set_volume(AudioSound* sound, float v) {
 ////////////////////////////////////////////////////////////////////
 void AudioManager::
 ns_spawn_update() {
-  if (!_spawned) {
-    _quit = false;
-    thread::priority_t pri;
-    switch (audio_thread_priority) {
-    case 0:
-      pri = thread::PRIORITY_LOW;
-      break;
-    case 1:
-      pri = thread::PRIORITY_NORMAL;
-      break;
-    case 2:
-      pri = thread::PRIORITY_HIGH;
-      break;
-    default:
-      audio_error("audio-thread-priority set to something other "
-          << "then low, normal, or high");
-      audio_thread_priority = 1;
-      pri = thread::PRIORITY_NORMAL;
+  #ifndef HAVE_RAD_MSS //[
+    if (!_spawned) {
+      _quit = false;
+      thread::priority_t pri;
+      switch (audio_thread_priority) {
+      case 0:
+        pri = thread::PRIORITY_LOW;
+        break;
+      case 1:
+        pri = thread::PRIORITY_NORMAL;
+        break;
+      case 2:
+        pri = thread::PRIORITY_HIGH;
+        break;
+      default:
+        audio_error("audio-thread-priority set to something other "
+            << "then low, normal, or high");
+        audio_thread_priority = 1;
+        pri = thread::PRIORITY_NORMAL;
+      }
+      _spawned = thread::create(spawned_update, (void*)&_quit, pri);
+    } else {
+      audio_error("tried to spawn 2 update threads");
     }
-    _spawned = thread::create(spawned_update, &_quit, pri);
-  } else {
-    audio_error("tried to spawn 2 update threads");
-  }
+  #endif //]
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -279,10 +393,12 @@ ns_shutdown() {
   if (_shutdown_func) {
     (*_shutdown_func)();
   }
-  if (_spawned) {
-    while (_quit) {
-      // waiting on update thread to stop spinning.
+  #ifndef HAVE_RAD_MSS //[
+    if (_spawned) {
+      while (_quit) {
+        // waiting on update thread to stop spinning.
+      }
     }
-  }
+  #endif //]
   audio_debug("update thread has shutdown");
 }

+ 17 - 13
panda/src/audio/audio_manager.h

@@ -33,32 +33,34 @@ class EXPCL_PANDA AudioManager {
   typedef pset<AudioSound*> LoopSet;
 
 PUBLISHED:
-  INLINE static void play(AudioSound*, float = 0.0);
+  INLINE static void play(AudioSound*, float start_time= 0.0, int loop=0);
   INLINE static void stop(AudioSound*);
   
-  INLINE static void set_loop(AudioSound*, bool);
-  INLINE static bool get_loop(AudioSound*);
+  #ifndef AUDIO_USE_RAD_MSS //[
+    INLINE static void set_loop(AudioSound*, bool loop);
+    INLINE static bool get_loop(AudioSound*);
+  #endif //]
   
-  INLINE static void set_volume(AudioSound*, float);
+  INLINE static void set_volume(AudioSound*, float volume);
   
   INLINE static void update();
   INLINE static void spawn_update();
   
   INLINE static void shutdown();
   
-  INLINE static void set_master_sfx_volume(float);
+  static void set_master_sfx_volume(float volume);
   INLINE static float get_master_sfx_volume();
   
-  INLINE static void set_master_music_volume(float);
+  static void set_master_music_volume(float volume);
   INLINE static float get_master_music_volume();
   
   INLINE static void set_all_sound_active(bool);
   INLINE static bool get_all_sound_active();
   
-  INLINE static void set_sfx_active(bool);
+  static void set_sfx_active(bool);
   INLINE static bool get_sfx_active();
   
-  INLINE static void set_music_active(bool);
+  static void set_music_active(bool);
   INLINE static bool get_music_active();
 
 public:
@@ -74,11 +76,13 @@ private:
   INLINE AudioManager();
 
   void copy_loopset();
-  void ns_play(AudioSound*, float);
+  void ns_play(AudioSound*, float start_time, int loop);
   void ns_stop(AudioSound*);
-  void ns_set_loop(AudioSound*, bool);
-  bool ns_get_loop(AudioSound*);
-  void ns_set_volume(AudioSound*, float);
+  #ifndef AUDIO_USE_RAD_MSS //[
+    void ns_set_loop(AudioSound*, bool loop);
+    bool ns_get_loop(AudioSound*);
+  #endif //]
+  void ns_set_volume(AudioSound*, float volume);
   void ns_spawn_update();
   void ns_shutdown();
   void ns_update();
@@ -90,7 +94,7 @@ private:
   static UpdateFunc* _update_func;
   static ShutdownFunc* _shutdown_func;
   static mutex _manager_mutex;
-  static bool _quit;
+  volatile static bool _quit;
   static thread* _spawned;
   static LoopSet* _loopset;
   static LoopSet* _loopcopy;

+ 2 - 1
panda/src/audio/audio_pool.cxx

@@ -148,8 +148,9 @@ void AudioPool::ns_release_sound(AudioSound* sound) {
   string filename = sound->get_name();
   SoundMap::iterator si;
   si = _sounds.find(filename);
-  if (si != _sounds.end() && (*si).second == sound->get_sound())
+  if (si != _sounds.end() && (*si).second == sound->get_sound()) {
     _sounds.erase(si);
+  }
 }
 
 ////////////////////////////////////////////////////////////////////

+ 21 - 8
panda/src/audio/audio_sound.h

@@ -33,11 +33,32 @@ class AudioManager;
 class EXPCL_PANDA AudioSound : public TypedObject, public Namable {
 */
 class EXPCL_PANDA AudioSound : public TypedReferenceCount, public Namable {
+PUBLISHED:
+  virtual ~AudioSound();
+  INLINE bool operator==(const AudioSound&) const;
+  INLINE bool operator!=(const AudioSound&) const;
+
+  enum Category { EFFECT, MUSIC }; // sync with AudioTraits::PlayingClass.
+  enum SoundStatus { BAD, READY, PLAYING };
+
+  float length() const;
+  SoundStatus status() const;
+  
+  void set_category(Category category) {
+    _state->set_category(
+      static_cast<AudioTraits::PlayingClass::Category>(category)
+    );
+  }
+  Category get_category() const {
+    return static_cast<Category>(_state->get_category());
+  }
+
 private:
   PT(AudioTraits::SoundClass) _sound;
   AudioTraits::PlayingClass *_state;
   AudioTraits::PlayerClass *_player;
   AudioTraits::DeletePlayingFunc *_delstate;
+
 protected:
   INLINE AudioSound(AudioTraits::SoundClass*, AudioTraits::PlayingClass*,
                     AudioTraits::PlayerClass*, AudioTraits::DeletePlayingFunc*,
@@ -51,15 +72,7 @@ protected:
 
   friend class AudioPool;
   friend class AudioManager;
-PUBLISHED:
-  virtual ~AudioSound();
-  INLINE bool operator==(const AudioSound&) const;
-  INLINE bool operator!=(const AudioSound&) const;
-
-  enum SoundStatus { BAD, READY, PLAYING } ;
 
-  float length() const;
-  SoundStatus status() const;
 public:
   // type stuff
   static TypeHandle get_class_type() {

+ 1 - 1
panda/src/audio/audio_trait.cxx

@@ -56,7 +56,7 @@ AudioTraits::PlayerClass::~PlayerClass() {
 }
 
 void AudioTraits::PlayerClass::play_sound(AudioTraits::SoundClass*,
-                                          AudioTraits::PlayingClass*, float) {
+                                          AudioTraits::PlayingClass*, float, int) {
   audio_cat->error() << "In abstract PlayerClass::play_sound!" << endl;
 }
 

+ 21 - 10
panda/src/audio/audio_trait.h

@@ -42,25 +42,32 @@ public:
     virtual DeletePlayingFunc* get_delstate() const = 0;
   };
   class EXPCL_PANDA PlayingClass {
-  protected:
-    SoundClass* _sound;
-    float _volume;
   public:
-    PlayingClass(SoundClass* s) : _sound(s), _volume(1.0) {}
+    PlayingClass(SoundClass* s) 
+        : _sound(s), _volume(1.0), _category(EFFECT) {}
     virtual ~PlayingClass();
 
-    enum PlayingStatus { BAD, READY, PLAYING } ;
+    enum Category { EFFECT, MUSIC }; // sync with AudioSound.
+    
+    enum PlayingStatus { BAD, READY, PLAYING };
 
     virtual PlayingStatus status() = 0;
     INLINE void set_volume(float v) { _volume = v; }
     INLINE float get_volume() const { return _volume; }
+    
+    void set_category(Category category) { _category=category; }
+    Category get_category() const { return _category; }
+  protected:
+    SoundClass* _sound;
+    float _volume;
+    Category _category;
   };
   class EXPCL_PANDA PlayerClass {
   public:
     PlayerClass() {}
     virtual ~PlayerClass();
 
-    virtual void play_sound(SoundClass*, PlayingClass*, float) = 0;
+    virtual void play_sound(SoundClass*, PlayingClass*, float start_time, int loop) = 0;
     virtual void stop_sound(SoundClass*, PlayingClass*) = 0;
     virtual void set_volume(PlayingClass*, float) = 0;
     virtual bool adjust_volume(PlayingClass*) = 0;
@@ -71,13 +78,17 @@ public:
 // all of the driver files on any system, I need to centralize a switch
 // for which one is real.
 #ifdef HAVE_SYS_SOUNDCARD_H
-#define AUDIO_USE_LINUX
+  #define AUDIO_USE_LINUX
+#elif 1
+  #define AUDIO_USE_RAD_MSS
+#elif defined(HAVE_RAD_MSS)
+  #define AUDIO_USE_RAD_MSS
 #elif defined(WIN32_VC)
-#define AUDIO_USE_WIN32
+  #define AUDIO_USE_WIN32
 #elif defined(HAVE_MIKMOD)
-#define AUDIO_USE_MIKMOD
+  #define AUDIO_USE_MIKMOD
 #else
-#define AUDIO_USE_NULL
+  #define AUDIO_USE_NULL
 #endif
 
 #endif /* __AUDIO_TRAIT_H__ */

+ 26 - 13
panda/src/audio/audio_win_traits.I

@@ -16,43 +16,56 @@
 //
 ////////////////////////////////////////////////////////////////////
 
-INLINE WinSample::WinSample() : AudioTraits::SoundClass(), _data(NULL),
-                                    _len(0) {
+INLINE WinSample::
+WinSample() 
+    : AudioTraits::SoundClass(), _data(NULL), _len(0) {
 }
 
-INLINE DWORD WinSample::get_length() const {
+INLINE DWORD WinSample::
+get_length() const {
   return _len;
 }
 
-INLINE WAVEFORMATEX WinSample::get_format() const {
+INLINE WAVEFORMATEX WinSample::
+get_format() const {
   return _info;
 }
 
-INLINE WinMusic::WinMusic() : AudioTraits::SoundClass(),
-                                  _performance(NULL), _music(NULL),
-                                  _buffer(NULL), _synth(NULL) {
+INLINE WinMusic::
+WinMusic() 
+    : AudioTraits::SoundClass(), 
+    _performance(NULL), _music(NULL),
+    _buffer(NULL), _synth(NULL) {
   init();
 }
 
-INLINE IDirectMusicPerformance* WinMusic::get_performance() const {
+INLINE IDirectMusicPerformance* WinMusic::
+get_performance() const {
   return _performance;
 }
 
-INLINE IDirectMusicSegment* WinMusic::get_music() {
+INLINE IDirectMusicSegment* WinMusic::
+get_music() {
   return _music;
 }
 
-INLINE LPDIRECTSOUNDBUFFER WinSamplePlaying::get_channel() {
+INLINE LPDIRECTSOUNDBUFFER WinSamplePlaying::
+get_channel() {
   return _channel;
 }
 
-INLINE IDirectMusicPerformance* WinMusicPlaying::get_performance() const {
+INLINE IDirectMusicPerformance* WinMusicPlaying::
+get_performance() const {
   WinMusic* wmusic = (WinMusic*)_sound;
   return wmusic->get_performance();
 }
 
-INLINE WinSamplePlayer::WinSamplePlayer() : AudioTraits::PlayerClass() {
+INLINE WinSamplePlayer::
+WinSamplePlayer() 
+    : AudioTraits::PlayerClass() {
 }
 
-INLINE WinMusicPlayer::WinMusicPlayer() : AudioTraits::PlayerClass() {
+INLINE WinMusicPlayer::
+WinMusicPlayer() 
+    : AudioTraits::PlayerClass() {
 }

+ 115 - 204
panda/src/audio/audio_win_traits.cxx

@@ -43,7 +43,7 @@ static IDirectSound* musicDirectSound = NULL;
                        << endl; \
     audio_is_active = false; \
     return; \
-  }
+  } else {}
 
 #define CHECK_RESULT_SFX(_result, _msg) \
   if (FAILED(_result)) { \
@@ -51,7 +51,7 @@ static IDirectSound* musicDirectSound = NULL;
                        << endl; \
     AudioManager::set_hard_sfx_active(false); \
     return; \
-  }
+  } else {}
 
 #define CHECK_RESULT_MUSIC(_result, _msg) \
   if (FAILED(_result)) { \
@@ -59,7 +59,7 @@ static IDirectSound* musicDirectSound = NULL;
                        << endl; \
     AudioManager::set_hard_music_active(false); \
     return; \
-  }
+  } else {}
 
 // #define MULTI_TO_WIDE(_in, _out) MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, _in, -1, _out, DMUS_MAX_FILENAME)
 #define MULTI_TO_WIDE(x,y) MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, y, -1, x, _MAX_PATH);
@@ -97,8 +97,8 @@ static void initialize() {
   // set the cooperative level
   result = soundDirectSound->SetCooperativeLevel(global_hwnd, DSSCL_PRIORITY);
   if (FAILED(result)) {
-    audio_cat->warning() << "could not set Direct Sound co-op level to "
-             << "DSSCL_PRIORITY, trying DSSCL_NORMAL" << endl;
+    audio_warning("could not set Direct Sound co-op level to "
+        << "DSSCL_PRIORITY, trying DSSCL_NORMAL");
     result = soundDirectSound->SetCooperativeLevel(global_hwnd, DSSCL_NORMAL);
     CHECK_RESULT_SFX(result, "failed setting to DSSCL_NORMAL");
   }
@@ -112,8 +112,8 @@ static void initialize() {
   ZeroMemory(&dsbd, sizeof(DSBUFFERDESC));
   dsbd.dwSize  =  sizeof(DSBUFFERDESC);
   dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER;
-  result = soundDirectSound->CreateSoundBuffer(&dsbd, &soundPrimaryBuffer,
-                           NULL);
+  result = soundDirectSound->CreateSoundBuffer(&dsbd, 
+      &soundPrimaryBuffer, NULL);
   CHECK_RESULT_SFX(result, "could not create primary buffer");
 
   // set primary buffer format to 22kHz and 16-bit output
@@ -128,9 +128,10 @@ static void initialize() {
   wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
   result = soundPrimaryBuffer->SetFormat(&wfx);
   // SetFormat requires at least DSSCL_PRIORITY, which we may not have
-  if (result == DSERR_PRIOLEVELNEEDED)
-    audio_cat->warning() << "could not set format of Primary Buffer because "
-             << "we didn't get DSSCL_PRIORITY" << endl;
+  if (result == DSERR_PRIOLEVELNEEDED) {
+    audio_warning("could not set format of Primary Buffer because "
+        << "we didn't get DSSCL_PRIORITY");
+  }
 
 /*
   //
@@ -365,62 +366,47 @@ HRESULT wave_load(const CHAR* filename, WAVEFORMATEX& wavInfo, BYTE*& wavData,
           UINT& wavSize) {
   pwfx = NULL;
   HRESULT result = wave_load_internal(filename, wavInfo, wavData, wavSize);
-  if (pwfx) {
-    delete pwfx;
-    pwfx = NULL;
-  }
+  delete pwfx;
+  pwfx = NULL;
   return result;
 }
 
 WinSample* WinSample::load_wav(Filename filename) {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "in winsample load_wav" << endl;
-  }
-  WinSample* ret = (WinSample*)0L;
-
+  audio_debug("in winsample load_wav");
   initialize();
-
   if (!audio_is_active) {
-    return ret;
+    return 0;
   }
-
+  // Load the wave:
   WAVEFORMATEX wavInfo;
   UINT wavSize = 0;
   BYTE* wavData = NULL;
-
   string stmp = filename.to_os_specific();
   HRESULT result = wave_load(stmp.c_str(), wavInfo, wavData, wavSize);
   if (FAILED(result)) {
-    if (wavData) {
-      delete [] wavData;
-    }
-    if (audio_cat.is_debug()) {
-      audio_cat->debug() << "wave_load failed, returning NULL" << endl;
-    }
-    return ret;
+    delete [] wavData;
+    audio_debug("wave_load failed, returning NULL");
+    return 0;
   }
-
-  ret = new WinSample();
+  // Create the sample:
+  WinSample* ret = new WinSample();
+  nassertr(ret, 0); // new should have thrown.
   memcpy(&(ret->_info), &wavInfo, sizeof(WAVEFORMATEX));
   ret->_data = wavData;
   ret->_len = wavSize;
-
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "returning 0x" << (void*)ret << endl;
-  }
+  audio_debug("returning 0x" << (void*)ret);
   return ret;
 }
 
 WinSample* WinSample::load_raw(unsigned char* data, unsigned long size) {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "in winsample load_raw" << endl;
-  }
-  WinSample* ret = (WinSample*)0L;
-
+  audio_debug("in winsample load_raw");
   initialize();
-
   if (!audio_is_active) {
-    return ret;
+    return 0;
+  }
+  if (!data) {
+    audio_debug("data is null, returning same");
+    return 0;
   }
 
   // synth a wav header for this data
@@ -433,29 +419,19 @@ WinSample* WinSample::load_raw(unsigned char* data, unsigned long size) {
   wavInfo.nBlockAlign = wavInfo.wBitsPerSample / 8 * wavInfo.nChannels;
   wavInfo.nAvgBytesPerSec = wavInfo.nSamplesPerSec * wavInfo.nBlockAlign;
 
-  if (data == (unsigned char*)0L) {
-    if (audio_cat.is_debug()) {
-      audio_cat->debug() << "data is null, returning same" << endl;
-    }
-    return ret;
-  }
-
   // create a direct sound channel for this data
-  ret = new WinSample();
+  WinSample* ret = new WinSample();
+  nassertr(ret, 0);
   memcpy(&(ret->_info), &wavInfo, sizeof(WAVEFORMATEX));
   ret->_data = data;
   ret->_len = size;
-  if (audio_cat.is_debug())
-    audio_cat->debug() << "WinSample::load_raw returning 0x" << (void*)ret
-               << endl;
+  audio_debug("WinSample::load_raw returning 0x" << (void*)ret);
   return ret;
 }
 
 WinMusic::~WinMusic() {
   // AudioManager::stop(this);
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "in WinMusic::~WinMusic()" << endl;
-  }
+  audio_debug("in WinMusic::~WinMusic()");
 
   if (_music) {
     _music->Release();
@@ -595,7 +571,6 @@ AudioTraits::DeletePlayingFunc* WinMusic::get_delstate() const {
 WinMusic* WinMusic::load_midi(Filename filename) {
   audio_debug("in WinMusic::load_midi()");
   initialize();
-
   if (!audio_is_active) {
     return (WinMusic*)0L;
   }
@@ -608,14 +583,14 @@ WinMusic* WinMusic::load_midi(Filename filename) {
   }
   ret->_music = NULL;
   IDirectMusicLoader* loader;
-  HRESULT result = CoCreateInstance(CLSID_DirectMusicLoader, NULL,
-                    CLSCTX_INPROC, IID_IDirectMusicLoader,
-                    (void**)&loader);
+  HRESULT result = CoCreateInstance(
+      CLSID_DirectMusicLoader, NULL,
+      CLSCTX_INPROC, IID_IDirectMusicLoader,
+      (void**)&loader);
   if (FAILED(result)) {
-    audio_cat->error() << "could not create music loader" << endl;
+    audio_error("could not create music loader");
     delete ret;
-    ret = (WinMusic*)0L;
-    return ret;
+    return 0;
   }
 
   /*
@@ -653,74 +628,56 @@ WinMusic* WinMusic::load_midi(Filename filename) {
 */
   string stmp = filename.to_os_specific();
   MULTI_TO_WIDE(fdesc.wszFileName, stmp.c_str());
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "os_specific name '" << stmp << "'" << endl;
-  }
+  audio_debug("os_specific name '" << stmp << "'");
   if (filename.is_local()) {
     fdesc.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_FILENAME;
-    if (audio_cat.is_debug()) {
-      audio_cat->debug() << "is local" << endl;
-    }
+    audio_debug("is local");
     char szDir[2] = ".";
     WCHAR wszDir[2];
     MULTI_TO_WIDE(wszDir, szDir);
-    result = loader->SetSearchDirectory(GUID_DirectMusicAllTypes, wszDir,
-                    FALSE);
+    result = loader->SetSearchDirectory(
+        GUID_DirectMusicAllTypes, wszDir, FALSE);
     if (FAILED(result)) {
-      audio_cat->error() << "could not set search directory to '.'" << endl;
+      audio_error("could not set search directory to '.'");
       loader->Release();
       delete ret;
-      ret = (WinMusic*)0L;
-      return ret;
+      return 0;
     }
   } else {
     fdesc.dwValidData = DMUS_OBJ_CLASS | DMUS_OBJ_FILENAME | DMUS_OBJ_FULLPATH;
-    if (audio_cat.is_debug()) {
-      audio_cat->debug() << "is not local" << endl;
-    }
+    audio_debug("is not local");
   }
   result = loader->GetObject(&fdesc, IID_IDirectMusicSegment2,
-                 (void**)&(ret->_music));
+      (void**)&(ret->_music));
   if (FAILED(result)) {
-    audio_cat->error() << "failed to load file" << endl;
+    audio_error("failed to load file");
     loader->Release();
     delete ret;
-    ret = (WinMusic*)0L;
-    return ret;
+    return 0;
   }
-  ret->_music->SetParam(GUID_StandardMIDIFile, -1, 0, 0,
-            (void*)(ret->_performance));
+  ret->_music->SetParam(GUID_StandardMIDIFile, 
+      -1, 0, 0, (void*)(ret->_performance));
   ret->_music->SetParam(GUID_Download, -1, 0, 0, (void*)(ret->_performance));
-  if (audio_cat.is_debug())
-    audio_cat->debug() << "out of WinMusic::load_midi()  _music = "
-                       << (void*)ret->_music << endl;
+  audio_debug("out of WinMusic::load_midi()  _music = "
+      << (void*)ret->_music);
   return ret;
 }
 
 WinSamplePlaying::WinSamplePlaying(AudioTraits::SoundClass* s)
   : AudioTraits::PlayingClass(s) {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "in WinSamplePlaying constructor" << endl;
-  }
-
+  audio_debug("in WinSamplePlaying constructor");
   initialize();
-
   if (!audio_is_active) {
     return;
   }
 
   WinSample* ws = (WinSample*)s;
-
-  if (ws == (WinSample*)0L) {
-    if (audio_cat.is_debug())
-      audio_cat->debug() << "the sample we were handed is NULL, returning"
-             << endl;
+  if (!ws) {
+    audio_debug("the sample we were handed is NULL, returning");
     return;
   }
-  if (ws->_data == (unsigned char*)0L) {
-    if (audio_cat.is_debug()) {
-      audio_cat->debug() << "the sample has null data, returning" << endl;
-    }
+  if (!ws->_data) {
+    audio_debug("the sample has null data, returning");
     return;
   }
 
@@ -731,22 +688,18 @@ WinSamplePlaying::WinSamplePlaying(AudioTraits::SoundClass* s)
   dsbdDesc.dwBufferBytes = ws->_len;
   dsbdDesc.lpwfxFormat = &(ws->_info);
   dsbdDesc.lpwfxFormat->cbSize = sizeof(ws->_info);
-  HRESULT result = soundDirectSound->CreateSoundBuffer(&dsbdDesc, &_channel,
-                                                        NULL);
+  HRESULT result = soundDirectSound->CreateSoundBuffer(&dsbdDesc, 
+      &_channel, NULL);
 
   if (FAILED(result)) {
     _channel = NULL;
-    if (audio_cat.is_debug()) {
-      audio_cat->debug() << "failed to create a channel" << endl;
-    }
+    audio_debug("failed to create a channel");
     return;
   }
   BYTE* dst = NULL;
   dst = this->lock();
-  if (audio_cat.is_debug())
-    audio_cat->debug() << "WinSamplePlaying::WinSamplePlaying _data = 0x"
-               << (void*)(ws->_data) << "  dst = 0x"
-               << (void*)dst << endl;
+  audio_debug("WinSamplePlaying::WinSamplePlaying _data = 0x"
+      << (void*)(ws->_data) << "  dst = 0x" << (void*)dst);
 
   // The Intel compiler dumps core if we attempt to protect this in a
   // try .. catch block.  We probably shouldn't be using exception
@@ -767,15 +720,11 @@ WinSamplePlaying::WinSamplePlaying(AudioTraits::SoundClass* s)
 }
 
 WinSamplePlaying::~WinSamplePlaying() {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "winsampleplaying destructor" << endl;
-  }
+  audio_debug("winsampleplaying destructor");
 }
 
 void WinSamplePlaying::destroy(AudioTraits::PlayingClass* play) {
-  if (audio_cat.is_debug())
-    audio_cat->debug() << "winsampleplaying destroy got 0x" << (void*)play
-               << endl;
+  audio_debug("winsampleplaying destroy got 0x" << (void*)play);
   delete play;
 }
 
@@ -791,61 +740,44 @@ AudioTraits::PlayingClass::PlayingStatus WinSamplePlaying::status() {
 }
 
 BYTE* WinSamplePlaying::lock() {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "in winsampleplaying lock" << endl;
-  }
+  audio_debug("in winsampleplaying lock");
   WinSample* s = (WinSample*)(_sound);
-  HRESULT result = _channel->Lock(0, 0, (void**)&_data, &(s->_len), NULL,
-                  0, DSBLOCK_ENTIREBUFFER);
+  HRESULT result = _channel->Lock(0, 
+      0, (void**)&_data, &(s->_len), NULL, 0, DSBLOCK_ENTIREBUFFER);
   if (FAILED(result)) {
-    audio_cat->error() << "failed to lock buffer" << endl;
+    audio_error("failed to lock buffer");
     return NULL;
   }
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "returning 0x" << (void*)_data << endl;
-  }
+  audio_debug("returning 0x" << (void*)_data);
   return _data;
 }
 
 void WinSamplePlaying::unlock() {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "in winsampleplaying unlock" << endl;
-  }
+  audio_debug("in winsampleplaying unlock");
   WinSample* s = (WinSample*)(_sound);
   HRESULT result = _channel->Unlock(_data, s->_len, NULL, 0);
   CHECK_RESULT(result, "failed to unlock buffer");
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "out of winsampleplaying unlock" << endl;
-  }
+  audio_debug("out of winsampleplaying unlock");
 }
 
 WinMusicPlaying::WinMusicPlaying(AudioTraits::SoundClass* s)
   : AudioTraits::PlayingClass(s) {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "in winmusicplaying constructor" << endl;
-  }
+  audio_debug("in winmusicplaying constructor");
   initialize();
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "out of winmusicplaying constructor" << endl;
-  }
+  audio_debug("out of winmusicplaying constructor");
 }
 
 WinMusicPlaying::~WinMusicPlaying() {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "winmusicplaying destructor" << endl;
-  }
+  audio_debug("winmusicplaying destructor");
 }
 
 void WinMusicPlaying::destroy(AudioTraits::PlayingClass* play) {
-  if (audio_cat.is_debug())
-    audio_cat->debug() << "winmusicplaying destroy got 0x" << (void*)play
-               << endl;
+  audio_debug("winmusicplaying destroy got 0x" << (void*)play);
   delete play;
 }
 
 AudioTraits::PlayingClass::PlayingStatus WinMusicPlaying::status() {
   WinMusic* wm = (WinMusic*)_sound;
-
   if (wm->get_performance() && wm->get_music()) {
     if (wm->get_performance()->IsPlaying(wm->get_music(), NULL) == S_OK) {
       return PLAYING;
@@ -857,16 +789,14 @@ AudioTraits::PlayingClass::PlayingStatus WinMusicPlaying::status() {
 WinSamplePlayer* WinSamplePlayer::_global_instance = (WinSamplePlayer*)0L;
 
 WinSamplePlayer::~WinSamplePlayer() {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "in winsampleplayer destructor" << endl;
-  }
+  audio_debug("in winsampleplayer destructor");
 }
 
 void WinSamplePlayer::play_sound(AudioTraits::SoundClass* sample,
                AudioTraits::PlayingClass* play, float start_time) {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "in winsampleplayer play_sound" << endl;
-  }
+  nassertv(sample);
+  nassertv(play);
+  audio_debug("in winsampleplayer play_sound ");
   initialize();
   if (!audio_is_active) {
     return;
@@ -891,12 +821,10 @@ void WinSamplePlayer::play_sound(AudioTraits::SoundClass* sample,
     chan->SetCurrentPosition(p);
     HRESULT result = chan->Play(0, 0, 0);
     if (FAILED(result)) {
-      audio_cat->error() << "sample play failed" << endl;
+      audio_error("sample play failed");
     }
   }
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "out of winsampleplayer play_sound" << endl;
-  }
+  audio_debug("out of winsampleplayer play_sound");
 }
 
 void WinSamplePlayer::stop_sound(AudioTraits::SoundClass*,
@@ -916,9 +844,7 @@ void WinSamplePlayer::stop_sound(AudioTraits::SoundClass*,
 }
 
 void WinSamplePlayer::set_volume(AudioTraits::PlayingClass* play, float v) {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "winsampleplayer set_volume" << endl;
-  }
+  audio_debug("winsampleplayer set_volume");
   initialize();
   if (!audio_is_active) {
     return;
@@ -937,9 +863,7 @@ void WinSamplePlayer::set_volume(AudioTraits::PlayingClass* play, float v) {
 }
 
 bool WinSamplePlayer::adjust_volume(AudioTraits::PlayingClass* play) {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "winsampleplayer adjust_volume" << endl;
-  }
+  audio_debug("winsampleplayer adjust_volume");
   initialize();
   if (!audio_is_active) {
     return true;
@@ -958,30 +882,23 @@ bool WinSamplePlayer::adjust_volume(AudioTraits::PlayingClass* play) {
 }
 
 WinSamplePlayer* WinSamplePlayer::get_instance() {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "in winsampleplayer get_instance" << endl;
-  }
-  if (_global_instance == (WinSamplePlayer*)0L)
+  audio_debug("in winsampleplayer get_instance");
+  if (!_global_instance) {
     _global_instance = new WinSamplePlayer();
-  if (audio_cat.is_debug())
-    audio_cat->debug() << "winsampleplayer returning 0x"
-               << (void*)_global_instance << endl;
+  }
+  audio_debug("winsampleplayer returning 0x" << (void*)_global_instance);
   return _global_instance;
 }
 
 WinMusicPlayer* WinMusicPlayer::_global_instance = (WinMusicPlayer*)0L;
 
 WinMusicPlayer::~WinMusicPlayer() {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "in winmusicplayer destructor" << endl;
-  }
+  audio_debug("in winmusicplayer destructor");
 }
 
 void WinMusicPlayer::play_sound(AudioTraits::SoundClass* music,
                 AudioTraits::PlayingClass*, float) {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "in WinMusicPlayer::play_sound()" << endl;
-  }
+  audio_debug("in WinMusicPlayer::play_sound()");
   initialize();
   if (!audio_is_active) {
     return;
@@ -992,36 +909,36 @@ void WinMusicPlayer::play_sound(AudioTraits::SoundClass* music,
   WinMusic* wmusic = (WinMusic*)music;
   IDirectMusicPerformance* _perf = wmusic->get_performance();
   IDirectMusicSegment* _msc = wmusic->get_music();
-  if (audio_cat.is_debug())
-    audio_cat->debug() << "about to jump in: _perf = " << (void*)_perf
-                       << "  _msc = " << (void*)_msc << endl;
+  audio_debug("about to jump in: _perf = " 
+      << (void*)_perf << "  _msc = " << (void*)_msc);
   if (_perf && _msc) {
-    if (audio_cat.is_debug()) {
-      audio_cat->debug() << "made it inside" << endl;
-    }
+    audio_debug("made it inside");
     // _msc->SetRepeats(0);
     IDirectMusicSegmentState* segState;
     // HRESULT result = _perf->PlaySegment(_msc, 0, 0, NULL);
     HRESULT result = _perf->PlaySegment(_msc, 0, 0, &segState);
     if (result != S_OK) {
-      audio_cat->error() << "music play failed" << endl;
+      audio_error("music play failed");
       switch (result) {
-      case E_OUTOFMEMORY: audio_cat->error() << "reports out of memory" << endl;
+      case E_OUTOFMEMORY:
+        audio_error("reports out of memory");
         break;
-      case E_POINTER: audio_cat->error() << "reports invalid pointer" << endl;
+      case E_POINTER:
+        audio_error("reports invalid pointer");
         break;
-      case DMUS_E_NO_MASTER_CLOCK: audio_cat->error() << "reports no master clock" << endl;
+      case DMUS_E_NO_MASTER_CLOCK:
+        audio_error("reports no master clock");
         break;
-      case DMUS_E_SEGMENT_INIT_FAILED: audio_cat->error() << "reports segment init failed" << endl;
+      case DMUS_E_SEGMENT_INIT_FAILED:
+        audio_error("reports segment init failed");
         break;
-      case DMUS_E_TIME_PAST: audio_cat->error() << "reports time past" << endl;
+      case DMUS_E_TIME_PAST:
+        audio_error("reports time past");
         break;
       };
     }
   }
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "out of WinMusicPlayer::play_sound()" << endl;
-  }
+  audio_debug("out of WinMusicPlayer::play_sound()");
 }
 
 void WinMusicPlayer::stop_sound(AudioTraits::SoundClass* music,
@@ -1036,17 +953,15 @@ void WinMusicPlayer::stop_sound(AudioTraits::SoundClass* music,
   if (_perf && _msc) {
     HRESULT result = _perf->Stop(_msc, 0, 0, 0);
     if (result != S_OK) {
-      audio_cat->error() << "music stop failed" << endl;
+      audio_error("music stop failed");
+    } else {
+      audio_debug("music stop succeeded");
     }
-    else if (audio_cat.is_debug())
-      audio_cat->debug() << "music stop succeeded" << endl;
   }
 }
 
 void WinMusicPlayer::set_volume(AudioTraits::PlayingClass* play, float v) {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "WinMusicPlayer::set_volume()" << endl;
-  }
+  audio_debug("WinMusicPlayer::set_volume()");
   WinMusicPlaying* wplay = (WinMusicPlaying*)play;
   IDirectMusicPerformance* perf = wplay->get_performance();
   float tmpv = v * AudioManager::get_master_music_volume();
@@ -1061,9 +976,7 @@ void WinMusicPlayer::set_volume(AudioTraits::PlayingClass* play, float v) {
 }
 
 bool WinMusicPlayer::adjust_volume(AudioTraits::PlayingClass* play) {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "WinMusicPlayer::adjust_volume()" << endl;
-  }
+  audio_debug("WinMusicPlayer::adjust_volume()");
   WinMusicPlaying* wplay = (WinMusicPlaying*)play;
   IDirectMusicPerformance* perf = wplay->get_performance();
   float tmpv = play->get_volume() * AudioManager::get_master_music_volume();
@@ -1078,14 +991,12 @@ bool WinMusicPlayer::adjust_volume(AudioTraits::PlayingClass* play) {
 }
 
 WinMusicPlayer* WinMusicPlayer::get_instance() {
-  if (audio_cat.is_debug()) {
-    audio_cat->debug() << "in WinMusicPlayer::get_instance" << endl;
-  }
-  if (_global_instance == (WinMusicPlayer*)0L)
+  audio_debug("in WinMusicPlayer::get_instance");
+  if (!_global_instance) {
     _global_instance = new WinMusicPlayer();
-  if (audio_cat.is_debug())
-    audio_cat->debug() << "WinMusicPlayer::get_instance returning 0x"
-               << (void*)_global_instance << endl;
+  }
+  audio_debug("WinMusicPlayer::get_instance returning 0x"
+      << (void*)_global_instance);
   return _global_instance;
 }
 

+ 3 - 0
panda/src/audio/audio_win_traits.h

@@ -23,11 +23,14 @@
 #ifndef __AUDIO_WIN_TRAITS_H__
 #define __AUDIO_WIN_TRAITS_H__
 
+#error You should try the Miles version.
+
 #include <filename.h>
 
 #include <windows.h>
 #include <dsound.h>
 #include <dmusici.h>
+#include "config_audio.h"
 
 class WinSamplePlaying;
 

+ 4 - 0
panda/src/audio/config_audio.h

@@ -50,10 +50,14 @@ extern EXPCL_PANDA void audio_load_loaders();
 
   #define audio_info(msg) \
     audio_cat->info() << msg << endl
+
+  #define audio_warning(msg) \
+    audio_cat->warning() << msg << endl
 #else //][
   // Release build:
   #define audio_debug(msg) ((void)0)
   #define audio_info(msg) ((void)0)
+  #define audio_warning(msg) ((void)0)
 #endif //]
 
 #define audio_error(msg) \

+ 8 - 0
panda/src/audiotraits/audio_load_midi.cxx

@@ -31,6 +31,14 @@ AudioTraits::SoundClass* AudioLoadMidi(Filename filename) {
   return MikModMidi::load_midi(filename);
 }
 
+#elif defined(AUDIO_USE_RAD_MSS)
+
+#include "audio_rad_mss_traits.h"
+
+EXPCL_MISC AudioTraits::SoundClass* AudioLoadMidi(Filename filename) {
+  return MilesSound::load(filename);
+}
+
 #elif defined(AUDIO_USE_WIN32)
 
 #include "audio_win_traits.h"

+ 8 - 0
panda/src/audiotraits/audio_load_mp3.cxx

@@ -530,6 +530,14 @@ AudioTraits::SoundClass* AudioLoadMp3(Filename) {
   return (AudioTraits::SoundClass*)0L;
 }
 
+#elif defined(AUDIO_USE_RAD_MSS)
+
+#include "audio_rad_mss_traits.h"
+
+EXPCL_MISC AudioTraits::SoundClass* AudioLoadMp3(Filename filename) {
+  return MilesSound::load(filename);
+}
+
 #elif defined(AUDIO_USE_WIN32)
 
 #include "audio_win_traits.h"

+ 8 - 0
panda/src/audiotraits/audio_load_st.cxx

@@ -400,6 +400,14 @@ AudioTraits::SoundClass* AudioLoadSt(Filename) {
   return (AudioTraits::SoundClass*)0L;
 }
 
+#elif defined(AUDIO_USE_RAD_MSS)
+
+#include "audio_rad_mss_traits.h"
+
+EXPCL_MISC AudioTraits::SoundClass* AudioLoadSt(Filename filename) {
+  return MilesSound::load(filename);
+}
+
 #elif defined(AUDIO_USE_WIN32)
 
 #include "audio_win_traits.h"

+ 8 - 0
panda/src/audiotraits/audio_load_wav.cxx

@@ -32,6 +32,14 @@ AudioTraits::SoundClass* AudioLoadWav(Filename filename) {
   return MikModSample::load_wav(filename);
 }
 
+#elif defined(AUDIO_USE_RAD_MSS)
+
+#include "audio_rad_mss_traits.h"
+
+EXPCL_MISC AudioTraits::SoundClass* AudioLoadWav(Filename filename) {
+  return MilesSound::load(filename);
+}
+
 #elif defined(AUDIO_USE_WIN32)
 
 #include "audio_win_traits.h"