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:
@@ -124,6 +124,12 @@ public class ClipBuffer
|
|||||||
*/
|
*/
|
||||||
public void resolve (Observer observer)
|
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 we're already loaded, this is easy
|
||||||
if (_state == LOADED) {
|
if (_state == LOADED) {
|
||||||
if (observer != null) {
|
if (observer != null) {
|
||||||
@@ -132,13 +138,6 @@ public class ClipBuffer
|
|||||||
return;
|
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
|
// queue up the observer
|
||||||
if (observer != null) {
|
if (observer != null) {
|
||||||
_observers.add(observer);
|
_observers.add(observer);
|
||||||
|
|||||||
@@ -258,8 +258,9 @@ public class Sound
|
|||||||
if (_sourceId != -1 &&
|
if (_sourceId != -1 &&
|
||||||
AL10.alGetSourcei(_sourceId, AL10.AL_SOURCE_STATE) ==
|
AL10.alGetSourcei(_sourceId, AL10.AL_SOURCE_STATE) ==
|
||||||
AL10.AL_STOPPED) {
|
AL10.AL_STOPPED) {
|
||||||
_sourceId = -1;
|
AL10.alSourcei(_sourceId, AL10.AL_BUFFER, 0);
|
||||||
_buffer.sourceUnbound();
|
_buffer.sourceUnbound();
|
||||||
|
_sourceId = -1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
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
|
* Adds a stream to the list maintained by the manager. Called by streams
|
||||||
* when they are created.
|
* when they are created.
|
||||||
|
|||||||
Reference in New Issue
Block a user