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:
Charlie Groves
2008-08-15 22:38:46 +00:00
parent fb830e1693
commit 8a3c6c8614
2 changed files with 12 additions and 12 deletions
@@ -52,7 +52,7 @@ public class ClipBuffer
* Create a key that uniquely identifies this combination of clip * Create a key that uniquely identifies this combination of clip
* provider and path. * 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! // we'll just use a string, amazing!
return provider + ":" + path; return provider + ":" + path;
@@ -73,7 +73,7 @@ public class ClipBuffer
/** /**
* Returns the unique key for this clip buffer. * Returns the unique key for this clip buffer.
*/ */
public Comparable getKey () public String getKey ()
{ {
return makeKey(_provider, _path); return makeKey(_provider, _path);
} }
@@ -242,9 +242,9 @@ public class ClipBuffer
} }
_state = UNLOADED; _state = UNLOADED;
_observers.apply(new ObserverList.ObserverOp() { _observers.apply(new ObserverList.ObserverOp<Observer>() {
public boolean apply (Object observer) { public boolean apply (Observer observer) {
((Observer)observer).clipFailed(ClipBuffer.this); observer.clipFailed(ClipBuffer.this);
return true; return true;
} }
}); });
@@ -181,8 +181,8 @@ public class SoundManager
} }
// configure our LRU map with a removal observer // configure our LRU map with a removal observer
_clips.setRemovalObserver(new LRUHashMap.RemovalObserver<Comparable,ClipBuffer>() { _clips.setRemovalObserver(new LRUHashMap.RemovalObserver<String, ClipBuffer>() {
public void removedFromMap (LRUHashMap<Comparable,ClipBuffer> map, public void removedFromMap (LRUHashMap<String, ClipBuffer> map,
final ClipBuffer item) { final ClipBuffer item) {
_rqueue.postRunnable(new Runnable() { _rqueue.postRunnable(new Runnable() {
public void run () { public void run () {
@@ -218,7 +218,7 @@ public class SoundManager
*/ */
protected ClipBuffer getClip (ClipProvider provider, String path, Observer observer) 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); ClipBuffer buffer = _clips.get(ckey);
try { try {
if (buffer == null) { if (buffer == null) {
@@ -301,7 +301,7 @@ public class SoundManager
final Clip clip = buffer.load(); final Clip clip = buffer.load();
_rqueue.postRunnable(new Runnable() { _rqueue.postRunnable(new Runnable() {
public void run () { public void run () {
Comparable ckey = buffer.getKey(); String ckey = buffer.getKey();
log.debug("Loaded " + ckey + "."); log.debug("Loaded " + ckey + ".");
_loading.remove(ckey); _loading.remove(ckey);
if (buffer.bind(clip)) { if (buffer.bind(clip)) {
@@ -330,11 +330,11 @@ public class SoundManager
protected float _baseGain = 1; protected float _baseGain = 1;
/** Contains a mapping of all currently-loading clips. */ /** 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. */ /** Contains a mapping of all loaded clips. */
protected LRUHashMap<Comparable, ClipBuffer> _clips = protected LRUHashMap<String, ClipBuffer> _clips =
new LRUHashMap<Comparable, ClipBuffer>(DEFAULT_CACHE_SIZE, _sizer); new LRUHashMap<String, ClipBuffer>(DEFAULT_CACHE_SIZE, _sizer);
/** Contains a queue of clip buffers waiting to be loaded. */ /** Contains a queue of clip buffers waiting to be loaded. */
protected Queue<ClipBuffer> _toLoad; protected Queue<ClipBuffer> _toLoad;