Cope with failing to initialize the sound system.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3683 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
//
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// Narya library - tools for developing networked games
|
||||||
|
// Copyright (C) 2002-2005 Three Rings Design, Inc., All Rights Reserved
|
||||||
|
// http://www.threerings.net/code/narya/
|
||||||
|
//
|
||||||
|
// This library is free software; you can redistribute it and/or modify it
|
||||||
|
// under the terms of the GNU Lesser General Public License as published
|
||||||
|
// by the Free Software Foundation; either version 2.1 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This library is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this library; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
package com.threerings.openal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A blank sound used when we cannot initialize the sound system.
|
||||||
|
*/
|
||||||
|
public class BlankSound extends Sound
|
||||||
|
{
|
||||||
|
protected BlankSound ()
|
||||||
|
{
|
||||||
|
super(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean play (boolean allowDefer, boolean loop)
|
||||||
|
{
|
||||||
|
return false; // nothing doing
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -48,7 +48,11 @@ public class SoundGroup
|
|||||||
*/
|
*/
|
||||||
public Sound getSound (String path)
|
public Sound getSound (String path)
|
||||||
{
|
{
|
||||||
return new Sound(this, _manager.getClip(_provider, path));
|
if (_manager.isInitialized()) {
|
||||||
|
return new Sound(this, _manager.getClip(_provider, path));
|
||||||
|
} else {
|
||||||
|
return new BlankSound();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,6 +71,12 @@ public class SoundGroup
|
|||||||
_manager = manager;
|
_manager = manager;
|
||||||
_provider = provider;
|
_provider = provider;
|
||||||
|
|
||||||
|
// if we were unable to initialize the sound system at all, just
|
||||||
|
// stop here and we'll behave as if we have no available sources
|
||||||
|
if (!_manager.isInitialized()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// create our sources
|
// create our sources
|
||||||
_sourceIds = BufferUtils.createIntBuffer(sources);
|
_sourceIds = BufferUtils.createIntBuffer(sources);
|
||||||
AL10.alGenSources(_sourceIds);
|
AL10.alGenSources(_sourceIds);
|
||||||
|
|||||||
@@ -69,6 +69,14 @@ public class SoundManager
|
|||||||
return _soundmgr;
|
return _soundmgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if we were able to initialize the sound system.
|
||||||
|
*/
|
||||||
|
public boolean isInitialized ()
|
||||||
|
{
|
||||||
|
return (_toLoad != null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the size of our sound cache. If this value is larger
|
* Configures the size of our sound cache. If this value is larger
|
||||||
* than memory available to the underlying sound system, it will be
|
* than memory available to the underlying sound system, it will be
|
||||||
|
|||||||
Reference in New Issue
Block a user