fixed it from horking repeatedly on my machine
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1618 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: SoundManager.java,v 1.2 2002/07/24 21:39:43 shaper Exp $
|
// $Id: SoundManager.java,v 1.3 2002/07/26 00:16:47 ray Exp $
|
||||||
|
|
||||||
package com.threerings.media;
|
package com.threerings.media;
|
||||||
|
|
||||||
@@ -49,19 +49,32 @@ public class SoundManager
|
|||||||
// create a thread to manage the sound queue
|
// create a thread to manage the sound queue
|
||||||
_player = new Thread() {
|
_player = new Thread() {
|
||||||
public void run () {
|
public void run () {
|
||||||
while (true) {
|
while (Thread.currentThread() == _player) {
|
||||||
// wait for a sound
|
// wait for a sound
|
||||||
_clips.waitForItem();
|
_clips.waitForItem();
|
||||||
|
|
||||||
// play the sound
|
// play the sound
|
||||||
playSound((String)_clips.get());
|
Object o = _clips.get();
|
||||||
|
if (o instanceof String) {
|
||||||
|
playSound((String) o);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Log.debug("SoundManager exit.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
_player.setDaemon(true);
|
_player.setDaemon(true);
|
||||||
_player.start();
|
_player.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shut the damn thing off.
|
||||||
|
*/
|
||||||
|
public void shutdown ()
|
||||||
|
{
|
||||||
|
_player = null;
|
||||||
|
_clips.append(this); // signal death
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queues up the sound file with the given pathname to be played when
|
* Queues up the sound file with the given pathname to be played when
|
||||||
* the sound manager deems the time appropriate.
|
* the sound manager deems the time appropriate.
|
||||||
@@ -109,6 +122,10 @@ public class SoundManager
|
|||||||
clip.start();
|
clip.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (LineUnavailableException lue) {
|
||||||
|
Log.warning("Sound unavailable, fuck it...");
|
||||||
|
shutdown();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.warning("Failed to play sound [path=" + path +
|
Log.warning("Failed to play sound [path=" + path +
|
||||||
", e=" + e + "].");
|
", e=" + e + "].");
|
||||||
|
|||||||
Reference in New Issue
Block a user