From 25bd81e59ad3e2d5a1f0dc3145a6769857776b72 Mon Sep 17 00:00:00 2001 From: Walter Korman Date: Mon, 30 Sep 2002 06:13:36 +0000 Subject: [PATCH] Added facilities for disabling the playing of sound without shutting down the sound manager wholeheartedly. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1760 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/media/sound/SoundManager.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/java/com/threerings/media/sound/SoundManager.java b/src/java/com/threerings/media/sound/SoundManager.java index ab5857d28..18ae63af4 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.5 2002/08/02 01:45:19 shaper Exp $ +// $Id: SoundManager.java,v 1.6 2002/09/30 06:13:36 shaper Exp $ package com.threerings.media; @@ -91,13 +91,21 @@ public class SoundManager return (_player == Thread.currentThread()); } + /** + * Sets whether sound is enabled. + */ + public void setEnabled (boolean enabled) + { + _enabled = enabled; + } + /** * Queues up the sound file with the given pathname to be played when * the sound manager deems the time appropriate. */ public void play (String path) { - if (_player != null) { + if (_player != null && _enabled) { // Log.debug("Queueing sound [path=" + path + "]."); _clips.append(path); } @@ -110,6 +118,10 @@ public class SoundManager { // Log.debug("Playing sound [path=" + path + "]."); + if (!_enabled) { + return; + } + try { // get the audio input stream Tuple tup = getAudioInfo(path); @@ -264,6 +276,9 @@ public class SoundManager /** The cached audio file data. */ protected HashMap _data = new HashMap(); + /** Whether sound is enabled. */ + protected boolean _enabled = true; + /** The buffer size in bytes used when reading audio file data. */ protected static final int BUFFER_SIZE = 2048; }