Files
aego/audio/pump/timing_test.go
sanspie 91090d27c4
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-platforms / darwin amd64 smoke (push) Skipped
ci-platforms / windows amd64 smoke (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
ci / checks (push) Failing after 13m5s
github-native / darwin arm64 native (push) Skipped
github-native / gitea-result (push) Skipped
GitHub / linux amd64 native GitHub-hosted native CI: success
ci / release (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 17m6s
fix: use precise Windows audio mix timing
2026-11-10 01:03:49 +03:00

37 lines
917 B
Go

package pump
import (
"testing"
"time"
"aego/audio/mix"
)
func TestRecordMixDurations(t *testing.T) {
m, err := mix.New(mix.Config{SampleRate: 48000, Channels: 2})
if err != nil {
t.Fatal(err)
}
p := New(m, nil, Config{})
// Zero is a valid observation when a block finishes within one clock tick.
for _, d := range []time.Duration{0, 2 * time.Nanosecond, 5 * time.Nanosecond} {
p.record(d)
}
s := p.Stats()
if s.Blocks != 3 || s.MixMax != 5*time.Nanosecond || s.MixAvg != 2*time.Nanosecond {
t.Fatalf("stats = %+v, want 3 blocks, max 5ns and average 2ns", s)
}
}
func TestFillDoesNotAllocate(t *testing.T) {
m, err := mix.New(mix.Config{SampleRate: 48000, Channels: 2})
if err != nil {
t.Fatal(err)
}
p := New(m, &sink{channels: 2}, Config{})
p.Fill()
if n := testing.AllocsPerRun(200, func() { p.Fill() }); n != 0 {
t.Fatalf("steady-state Fill allocated %v times per call", n)
}
}