From ea5e5adbad29a2fd7ad686b3051e564216332782 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Fri, 26 Jul 2002 16:00:19 +0000 Subject: [PATCH] Pay our respects to Chapter 12 of the JLS. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1619 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/media/sound/SoundManager.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/java/com/threerings/media/sound/SoundManager.java b/src/java/com/threerings/media/sound/SoundManager.java index aafca6395..af6294279 100644 --- a/src/java/com/threerings/media/sound/SoundManager.java +++ b/src/java/com/threerings/media/sound/SoundManager.java @@ -1,5 +1,5 @@ // -// $Id: SoundManager.java,v 1.3 2002/07/26 00:16:47 ray Exp $ +// $Id: SoundManager.java,v 1.4 2002/07/26 16:00:19 mdb Exp $ package com.threerings.media; @@ -49,7 +49,7 @@ public class SoundManager // create a thread to manage the sound queue _player = new Thread() { public void run () { - while (Thread.currentThread() == _player) { + while (amRunning()) { // wait for a sound _clips.waitForItem(); @@ -69,12 +69,21 @@ public class SoundManager /** * Shut the damn thing off. */ - public void shutdown () + public synchronized void shutdown () { _player = null; _clips.append(this); // signal death } + /** + * Used by the sound playing thread to determine whether or not to + * shut down. + */ + protected synchronized boolean amRunning () + { + return (_player == Thread.currentThread()); + } + /** * Queues up the sound file with the given pathname to be played when * the sound manager deems the time appropriate.