ci-platforms / darwin amd64 smoke (push) Skipped
GitHub / linux amd64 native GitHub-hosted native CI: success
ci-platforms / windows amd64 smoke (push) Skipped
GitHub / windows amd64 native GitHub-hosted native CI: success
GitHub / darwin arm64 native GitHub-hosted native CI: success
GitHub / darwin amd64 native GitHub-hosted native CI: success
ci / checks (push) Failing after 1h21m34s
ci / native-authoring (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
github-native / gitea-pending (push) Skipped
github-native / darwin amd64 native (push) Skipped
github-native / linux amd64 native (push) Skipped
github-native / windows amd64 native (push) Skipped
github-native / darwin arm64 native (push) Skipped
github-native / gitea-result (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 12m4s
ci / release (push) Skipped
Add dockable Art tools, animation and previews, guarded asset workflows, and the Web Asset Studio built on the shared Art Core. Expand English and Russian documentation, interactive Try scenes, examples and editor icons. Add audio waveform navigation, source analysis, guarded previews and a browser Worker mixer. Preserve source changes and recovery with bounded checks, and strengthen native, browser and interoperability CI. Prepare version 0.12.5 and manually built native artifact candidates. Fix the production site image demo build dependency. Reuse immutable scene indices when capturing keyframes. Wait for real Persist save/load completion in component tests. Stabilize browser Game View captures outside pointer hover. Aseprite interchange and persistent Audio EDL recovery remain limited; the artifact workflow does not publish releases or change stable.
122 lines
2.9 KiB
Go
122 lines
2.9 KiB
Go
package main
|
|
|
|
import (
|
|
"math"
|
|
"testing"
|
|
|
|
"aego/audio/mix"
|
|
"aego/audio/workerproto"
|
|
)
|
|
|
|
func TestControllerReplaceStreamTransfersAndReleasesSources(t *testing.T) {
|
|
s := initService(t, 2<<20)
|
|
m, err := mix.New(mix.Config{SampleRate: 48000, Voices: 4, Block: 512})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
controller, err := workerproto.NewController(m)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
drive := func() {
|
|
t.Helper()
|
|
for i := 0; i < 1000; i++ {
|
|
step, ok, err := controller.Next()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !ok {
|
|
return
|
|
}
|
|
var result []byte
|
|
if step.Chunk {
|
|
copy(s.memory[step.Offset:], step.PCM)
|
|
} else {
|
|
if step.Op == opStreamWrite {
|
|
buf, err := s.streamBuffer(len(step.PCM))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
copy(buf, step.PCM)
|
|
}
|
|
result = call(t, s, step.Op, step.Request)
|
|
}
|
|
if err := controller.Ack(step.Token, result); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
t.Fatal("controller did not become idle")
|
|
}
|
|
drain := func() {
|
|
t.Helper()
|
|
batch, err := workerproto.DecodeBatch(call(t, s, opDrain, request{}))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := controller.ApplyBatch(batch.Mix()); err != nil {
|
|
t.Fatalf("invalid batch: %+v, %v", batch, err)
|
|
}
|
|
}
|
|
old := m.Play(mix.PlayParams{Memory: &mix.Memory{PCM: make([]float32, 128), Rate: 48000, Channels: 1}, Gain: 1})
|
|
if !old.Valid() {
|
|
t.Fatal("could not start old preview")
|
|
}
|
|
drive()
|
|
if _, err := s.render(1); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
drain()
|
|
stream := mix.NewStream(24000, 1, 128)
|
|
pcm := make([]float32, 128)
|
|
for i := range pcm {
|
|
pcm[i] = float32(math.Sin(float64(i)*.11)) * .5
|
|
}
|
|
if stream.Ring.Write(pcm) != len(pcm) {
|
|
t.Fatal("could not prepare stream PCM")
|
|
}
|
|
newVoice := m.ReplaceStream(old, mix.PlayParams{Stream: stream, Gain: 1}, 1, false)
|
|
if !newVoice.Valid() {
|
|
t.Fatal("could not queue replacement")
|
|
}
|
|
drive()
|
|
got, err := s.render(32)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
ref, err := mix.New(mix.Config{SampleRate: 48000})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
id := ref.Play(mix.PlayParams{Memory: &mix.Memory{PCM: pcm, Rate: 24000, Channels: 1}, Gain: 1})
|
|
if !id.Valid() || !ref.SeekMemory(id, 1) {
|
|
t.Fatal("could not prepare reference")
|
|
}
|
|
want := make([]float32, len(got))
|
|
ref.Mix(want)
|
|
for i := range got {
|
|
if math.Float32bits(got[i]) != math.Float32bits(want[i]) {
|
|
t.Fatalf("sample %d: worker=%v reference=%v", i, got[i], want[i])
|
|
}
|
|
}
|
|
drain()
|
|
if m.Live(old) || !m.Live(newVoice) {
|
|
t.Fatal("producer did not reconcile the replaced voice")
|
|
}
|
|
if !m.StopPair(old, newVoice, 0) {
|
|
t.Fatal("could not stop replacement")
|
|
}
|
|
drive()
|
|
if _, err := s.render(512); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
drain()
|
|
drive() // Retire both source registrations and the stream sender claim.
|
|
claim, err := mix.NewRemoteStreamSender(stream)
|
|
if err != nil {
|
|
t.Fatalf("replacement retained its stream claim: %v", err)
|
|
}
|
|
if err := claim.Close(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|