feat: port the client to MyGo native UI (0.3.0)
Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
This commit is contained in:
1 parent
2fb4a8ea79
commit
6c0ee61750
2538 files changed
+675779
-4792
No files matched your search
Vendored
+94
@@ -0,0 +1,94 @@
|
||||
package audio
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// A tune's intro plays once, then its loop again and again, without a gap.
|
||||
func TestLoopRange(t *testing.T) {
|
||||
setup(t)
|
||||
samples := ramp(100) // frame i is i/200
|
||||
p := NewSound(sampleRate, 1, samples).NewPlayer().
|
||||
SetLoopRange(frames(30, sampleRate), frames(60, sampleRate))
|
||||
p.Play()
|
||||
out := render(200)
|
||||
for i := range 200 {
|
||||
want := i
|
||||
if i >= 60 {
|
||||
want = 30 + (i-60)%30
|
||||
}
|
||||
if !near(out[2*i], samples[want]) {
|
||||
t.Fatalf("frame %d = %v, want frame %d's %v", i, out[2*i], want, samples[want])
|
||||
}
|
||||
}
|
||||
// 200 frames in: 60 + 140 = 4 loops of 30 and 20 more.
|
||||
if got, want := p.Position(), frames(50, sampleRate); got != want {
|
||||
t.Errorf("Position = %v, want %v", got, want)
|
||||
}
|
||||
// Looping no more, it plays on past the loop's end, to the end (after
|
||||
// what it read ahead, a few milliseconds).
|
||||
p.SetLoop(false)
|
||||
out = render(1000)
|
||||
last := -1
|
||||
for i := range 1000 {
|
||||
if out[2*i] != 0 {
|
||||
last = i
|
||||
}
|
||||
}
|
||||
if last < 0 || !near(out[2*last], samples[99]) || p.Playing() {
|
||||
t.Errorf("after SetLoop(false): last frame %d = %v, playing %v", last, out[2*max(last, 0)], p.Playing())
|
||||
}
|
||||
if !near(out[2*(last-39)], samples[60]) {
|
||||
t.Errorf("frames 60 to 99 do not end it: %v", out[2*(last-39)])
|
||||
}
|
||||
}
|
||||
|
||||
func TestStreamLoopRange(t *testing.T) {
|
||||
setup(t)
|
||||
d := &genDecoder{ch: 1, length: 5000} // frame i is (i%1000)/1000
|
||||
p := NewPlayer(d).SetLoopRange(frames(1000, sampleRate), frames(3000, sampleRate))
|
||||
waitDecoded(t, p)
|
||||
p.Play()
|
||||
out := make([]float32, 0, 9000*channels)
|
||||
for len(out) < 9000*channels {
|
||||
chunk := make([]float32, 64*channels)
|
||||
s := p.v.src.(*stream)
|
||||
for {
|
||||
s.mu.Lock()
|
||||
n := s.n
|
||||
s.mu.Unlock()
|
||||
if n >= 64 {
|
||||
break
|
||||
}
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
mix(chunk)
|
||||
out = append(out, chunk...)
|
||||
}
|
||||
for i := range 9000 {
|
||||
f := i
|
||||
if i >= 3000 {
|
||||
f = 1000 + (i-3000)%2000
|
||||
}
|
||||
if want := float32(f%1000) / 1000; !near(out[2*i], want) {
|
||||
t.Fatalf("frame %d = %v, want frame %d's %v", i, out[2*i], f, want)
|
||||
}
|
||||
}
|
||||
p.Close()
|
||||
}
|
||||
|
||||
func TestLoopRangeOutOfRange(t *testing.T) {
|
||||
setup(t)
|
||||
p := NewSound(sampleRate, 1, ramp(100)).NewPlayer()
|
||||
// An end before the start loops it all.
|
||||
p.SetLoopRange(frames(60, sampleRate), frames(30, sampleRate))
|
||||
if p.v.loopStart != 0 || p.v.loopEnd != 0 || !p.Loop() {
|
||||
t.Errorf("loop %d to %d, looping %v", p.v.loopStart, p.v.loopEnd, p.Loop())
|
||||
}
|
||||
// Past the end, clamped to it.
|
||||
p.SetLoopRange(frames(10, sampleRate), time.Hour)
|
||||
if p.v.loopStart != 10 || p.v.loopEnd != 100 {
|
||||
t.Errorf("loop %d to %d", p.v.loopStart, p.v.loopEnd)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user