Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Preparing audio streaming, allow not-destroy-while-iterating.

  • Loading branch information...
commit 0b21dbd422346878d847bc205bc0848b86249e63 1 parent d963e92
@nddrylliog authored
View
4 source/ldkit/Actor.ooc
@@ -3,7 +3,7 @@ Actor: class {
init: func {}
- update: func (delta: Float) {
+ update: func (delta: Float) -> Bool {
"Override %s#update! (delta = %.2f)" printfln(class name, delta)
}
@@ -21,7 +21,7 @@ ActorClosure: class extends Actor {
}
- update: func (delta: Float) {
+ update: func (delta: Float) -> Bool {
f(delta)
}
View
15 source/ldkit/Engine.ooc
@@ -30,9 +30,10 @@ Engine: class {
ticks = LTime getTicks()
// two physics simulation
- for(a in actors) a update(delta * 0.5)
+ updateActors(delta * 0.5)
+
if (!slomo) {
- for(a in actors) a update(delta * 0.5)
+ updateActors(delta * 0.5)
}
ui update()
@@ -44,6 +45,16 @@ Engine: class {
}
}
+ updateActors: func (realDelta: Float) {
+ iter := actors iterator()
+ while (iter hasNext?()) {
+ actor := iter next()
+ if (actor update(realDelta)) {
+ iter remove()
+ }
+ }
+ }
+
add: func (actor: Actor) {
actors add(actor)
}
View
10 source/ldkit/Sound.ooc
@@ -36,11 +36,13 @@ Source: class {
match als {
case AL_STOPPED => SourceState STOPPED
case => SourceState PLAYING
- // TODO: handle other cases?
}
}
update: func {
+ if (sample streaming) {
+ }
+
if(getState() == SourceState STOPPED) {
if(autofree) {
// "Freeing source %d, because already stopped" printfln(sourceID)
@@ -73,8 +75,10 @@ Sample: class {
path: String
+ streaming: Bool
+
// loads the sample
- init: func (=path) {
+ init: func (=path, =streaming) {
if (path endsWith?(".ogg")) {
loadOgg(path)
} else {
@@ -172,7 +176,7 @@ Boombox: class {
cache get(aPath)
} else {
logger info("Loading audio file... %s" format(path))
- s := Sample new(aPath)
+ s := Sample new(aPath, false)
cache put(aPath, s)
s
}
Please sign in to comment.
Something went wrong with that request. Please try again.