# HG changeset patch # User prock@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1287071563 0 # Node ID 2851e232a11360f1214991abd93e076138ea5e0f # Parent 51bbda7676f0e1453f412a3dc17b0efd47227199 * Modified the sound manager to better take care of sound clips. (Hope this fixes the crash at the end of the shooter demo) diff -r 51bbda7676f0 -r 2851e232a113 demos/shooter/scripts/ships/enemies.py --- a/demos/shooter/scripts/ships/enemies.py Thu Oct 14 15:32:09 2010 +0000 +++ b/demos/shooter/scripts/ships/enemies.py Thu Oct 14 15:52:43 2010 +0000 @@ -45,7 +45,7 @@ super(BossActionListener, self).onInstanceActionFinished(instance, action) if action.getId() == 'explode': - self.delayed = fife_timer.delayCall(1000,self._ship.endLevel()) + self.delayed = fife_timer.delayCall(5000,self._ship.endLevel()) class Saucer1(Ship): diff -r 51bbda7676f0 -r 2851e232a113 engine/python/fife/extensions/soundmanager.py --- a/engine/python/fife/extensions/soundmanager.py Thu Oct 14 15:32:09 2010 +0000 +++ b/engine/python/fife/extensions/soundmanager.py Thu Oct 14 15:52:43 2010 +0000 @@ -93,6 +93,9 @@ self._position = None self._rolloff = 0 + + def __del__(self): + self._soundmanager.unregisterClip(self) def play(self): self._soundmanager.playClip(self) @@ -201,6 +204,9 @@ #A dict of fife emitters self._loadedclips = {} + #A list of created clips + self._soundclips = [] + #A tuple representing the listener position (x,y) self._listenerposition = None @@ -245,7 +251,9 @@ if position is not None: clip.position = position clip.rolloff = self.rolloff - + + self._soundclips.append(clip) + return clip def playClip(self, clip): @@ -330,6 +338,12 @@ else: clip = self.createSoundEmitter(clip.name) self.playClip(clip) + + def unregisterClip(self, clip): + self.stopClip(clip) + + if clip in self._soundclips: + self._soundclips.remove(clip) def stopClip(self, clip): """ @@ -347,9 +361,8 @@ clip.timer = None def stopAllSounds(self): - for emitterlist in self._loadedclips.values(): - for emitter in emitterlist: - emitter.stop() + for clip in self._soundclips: + self.stopClip(clip) def destroy(self): """ @@ -364,7 +377,7 @@ self._fifesoundmanager.releaseEmitter(emitter.getId()) emitter = None - self._loadedclips.clear() + self._loadedclips.clear() def _getRolloff(self): return self._rolloff