Unbind buffer from source before we attempt to delete it, allow

re-resolving clips waiting to be unloaded.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4155 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Andrzej Kapolka
2006-05-29 02:53:50 +00:00
parent 6b3aba0225
commit e04f7eb1f8
3 changed files with 17 additions and 8 deletions
@@ -124,6 +124,12 @@ public class ClipBuffer
*/
public void resolve (Observer observer)
{
// if we were waiting to unload, cancel that
if (_state == UNLOADING) {
_state = LOADED;
_manager.restoreClip(this);
}
// if we're already loaded, this is easy
if (_state == LOADED) {
if (observer != null) {
@@ -132,13 +138,6 @@ public class ClipBuffer
return;
}
// this shouldn't happen
if (_state == UNLOADING) {
Log.warning("Tried to resolve buffer in the process of " +
"unloading [key=" + getKey() + "].");
return;
}
// queue up the observer
if (observer != null) {
_observers.add(observer);
+2 -1
View File
@@ -258,8 +258,9 @@ public class Sound
if (_sourceId != -1 &&
AL10.alGetSourcei(_sourceId, AL10.AL_SOURCE_STATE) ==
AL10.AL_STOPPED) {
_sourceId = -1;
AL10.alSourcei(_sourceId, AL10.AL_BUFFER, 0);
_buffer.sourceUnbound();
_sourceId = -1;
return true;
}
return false;
@@ -247,6 +247,15 @@ public class SoundManager
});
}
/**
* Adds the supplied clip buffer back to the cache after it has been marked
* for disposal and subsequently re-requested.
*/
protected void restoreClip (ClipBuffer buffer)
{
_clips.put(buffer.getKey(), buffer);
}
/**
* Adds a stream to the list maintained by the manager. Called by streams
* when they are created.