Use the new LRUHashMap removal observer mechanism.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3672 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -27,14 +27,12 @@ import java.nio.IntBuffer;
|
|||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
import org.lwjgl.openal.AL10;
|
import org.lwjgl.openal.AL10;
|
||||||
|
|
||||||
import com.samskivert.util.LRUHashMap;
|
|
||||||
import com.samskivert.util.ObserverList;
|
import com.samskivert.util.ObserverList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a sound that has been loaded into the OpenAL system.
|
* Represents a sound that has been loaded into the OpenAL system.
|
||||||
*/
|
*/
|
||||||
public class ClipBuffer
|
public class ClipBuffer
|
||||||
implements LRUHashMap.LRUItem
|
|
||||||
{
|
{
|
||||||
/** Used to notify parties interested in when a clip is loaded. */
|
/** Used to notify parties interested in when a clip is loaded. */
|
||||||
public static interface Observer
|
public static interface Observer
|
||||||
@@ -164,8 +162,10 @@ public class ClipBuffer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface LRUHashMap.LRUItem
|
/**
|
||||||
public void removedFromMap (LRUHashMap map)
|
* Frees up the internal audio buffers associated with this clip.
|
||||||
|
*/
|
||||||
|
public void dispose ()
|
||||||
{
|
{
|
||||||
if (_bufferId != null) {
|
if (_bufferId != null) {
|
||||||
// we've been given the boot, free up our buffer
|
// we've been given the boot, free up our buffer
|
||||||
|
|||||||
@@ -120,6 +120,13 @@ public class SoundManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// configure our LRU map with a removal observer
|
||||||
|
_clips.setRemovalObserver(new LRUHashMap.RemovalObserver() {
|
||||||
|
public void removedFromMap (LRUHashMap map, Object item) {
|
||||||
|
((ClipBuffer)item).dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// create our loading queue
|
// create our loading queue
|
||||||
_toLoad = new Queue();
|
_toLoad = new Queue();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user