There's no way to genericize the Comparable while using the static
ClipBuffer.makeKey to create them, and non-genericized Comparables make the Baby Jesus(Nate) cry, so just drop the pretense and use String. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@631 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -52,7 +52,7 @@ public class ClipBuffer
|
||||
* Create a key that uniquely identifies this combination of clip
|
||||
* provider and path.
|
||||
*/
|
||||
public static Comparable makeKey (ClipProvider provider, String path)
|
||||
public static String makeKey (ClipProvider provider, String path)
|
||||
{
|
||||
// we'll just use a string, amazing!
|
||||
return provider + ":" + path;
|
||||
@@ -73,7 +73,7 @@ public class ClipBuffer
|
||||
/**
|
||||
* Returns the unique key for this clip buffer.
|
||||
*/
|
||||
public Comparable getKey ()
|
||||
public String getKey ()
|
||||
{
|
||||
return makeKey(_provider, _path);
|
||||
}
|
||||
@@ -242,9 +242,9 @@ public class ClipBuffer
|
||||
}
|
||||
_state = UNLOADED;
|
||||
|
||||
_observers.apply(new ObserverList.ObserverOp() {
|
||||
public boolean apply (Object observer) {
|
||||
((Observer)observer).clipFailed(ClipBuffer.this);
|
||||
_observers.apply(new ObserverList.ObserverOp<Observer>() {
|
||||
public boolean apply (Observer observer) {
|
||||
observer.clipFailed(ClipBuffer.this);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -181,8 +181,8 @@ public class SoundManager
|
||||
}
|
||||
|
||||
// configure our LRU map with a removal observer
|
||||
_clips.setRemovalObserver(new LRUHashMap.RemovalObserver<Comparable,ClipBuffer>() {
|
||||
public void removedFromMap (LRUHashMap<Comparable,ClipBuffer> map,
|
||||
_clips.setRemovalObserver(new LRUHashMap.RemovalObserver<String, ClipBuffer>() {
|
||||
public void removedFromMap (LRUHashMap<String, ClipBuffer> map,
|
||||
final ClipBuffer item) {
|
||||
_rqueue.postRunnable(new Runnable() {
|
||||
public void run () {
|
||||
@@ -218,7 +218,7 @@ public class SoundManager
|
||||
*/
|
||||
protected ClipBuffer getClip (ClipProvider provider, String path, Observer observer)
|
||||
{
|
||||
Comparable ckey = ClipBuffer.makeKey(provider, path);
|
||||
String ckey = ClipBuffer.makeKey(provider, path);
|
||||
ClipBuffer buffer = _clips.get(ckey);
|
||||
try {
|
||||
if (buffer == null) {
|
||||
@@ -301,7 +301,7 @@ public class SoundManager
|
||||
final Clip clip = buffer.load();
|
||||
_rqueue.postRunnable(new Runnable() {
|
||||
public void run () {
|
||||
Comparable ckey = buffer.getKey();
|
||||
String ckey = buffer.getKey();
|
||||
log.debug("Loaded " + ckey + ".");
|
||||
_loading.remove(ckey);
|
||||
if (buffer.bind(clip)) {
|
||||
@@ -330,11 +330,11 @@ public class SoundManager
|
||||
protected float _baseGain = 1;
|
||||
|
||||
/** Contains a mapping of all currently-loading clips. */
|
||||
protected HashMap<Comparable, ClipBuffer> _loading = Maps.newHashMap();
|
||||
protected HashMap<String, ClipBuffer> _loading = Maps.newHashMap();
|
||||
|
||||
/** Contains a mapping of all loaded clips. */
|
||||
protected LRUHashMap<Comparable, ClipBuffer> _clips =
|
||||
new LRUHashMap<Comparable, ClipBuffer>(DEFAULT_CACHE_SIZE, _sizer);
|
||||
protected LRUHashMap<String, ClipBuffer> _clips =
|
||||
new LRUHashMap<String, ClipBuffer>(DEFAULT_CACHE_SIZE, _sizer);
|
||||
|
||||
/** Contains a queue of clip buffers waiting to be loaded. */
|
||||
protected Queue<ClipBuffer> _toLoad;
|
||||
|
||||
Reference in New Issue
Block a user