Open gucio321 opened 3 months ago
Does the current example cause crash? Then, could you file an issue and send a PR? Thanks,
Or, if the crash happens in your app, I need to see your code...
Well, I didn't manage to reproduce this crash with an example yet, maybe it is related to my Seek
implementation or something?
my code is here: https://github.com/gucio321/morse/blob/master/pkg/generator/sine_wave.go try to comment out m.Lock/Unlock calls, then run cmd/gnerator. sometimes sounds are too long, sometimes (rarely) it crashes
you can run this: while true; do go run .; done
and after some time you should get
panic: runtime error: slice bounds out of range [:-17280]
goroutine 6 [running]:
github.com/gucio32/morse/pkg/generator.(*SineWave).Read(0xc000096af0, {0xc0000b0000?, 0x482fa9?, 0x0?})
/home/me/git/morse/pkg/generator/sine_wave.go:54 +0x4f7
github.com/ebitengine/oto/v3/internal/mux.(*playerImpl).read(0xc0000bc000?, {0xc0000b0000?, 0xc000096b50?, 0x481200?})
/home/me/go/pkg/mod/github.com/ebitengine/oto/v3@v3.2.0/internal/mux/mux.go:268 +0xc8
github.com/ebitengine/oto/v3/internal/mux.(*playerImpl).readSourceToBuffer(0xc0000aa1b0)
/home/me/go/pkg/mod/github.com/ebitengine/oto/v3@v3.2.0/internal/mux/mux.go:529 +0x145
github.com/ebitengine/oto/v3/internal/mux.(*Mux).loop(0xc00008a0c0)
/home/me/go/pkg/mod/github.com/ebitengine/oto/v3@v3.2.0/internal/mux/mux.go:108 +0x205
created by github.com/ebitengine/oto/v3/internal/mux.New in goroutine 1
/home/me/go/pkg/mod/github.com/ebitengine/oto/v3@v3.2.0/internal/mux/mux.go:69 +0xf8
exit status 2
Oto implementation also uses mutex so Seek should be thread safe. I'll take a look later, but I hope you could create a more minimal case to reproduce the issue. Thanks,
You should return an error when p.pos < 0
or p.pos > p.length
at Seek
at least.
I found an interessting thing: if you modify an example like this: https://github.com/gucio321/oto/commit/d969893e144a41939b2a9ed9714f74eb53071bb3 not every sound is played
OK, please report issues one by one with a minimized test case to reproduce it. Thanks,
Hi there!
context
I'm working on a morse code generator app. I've based my code on oto's example (sine wave is exactly what I needed).
My issue
After implementing the code in my app I noticed 2 issues:
(*SinWave).Read
sometimes panics withindex out of range [:-3XXXX]
or, sometimes sound was corrupted (longer and glitchy). I managed to fix that by addingsync.Mutex
(For some reason Read was called twice by oto, idk why).the other issue may be specific to my app, where it must not appear, and may be wanted here in example to keep it as simple as possible: when the sound starts playing and when it ends, you can hear a "tap". It is a hardware thing imo. It could be removed by the following:
stuckReduction
is a constant, which for me is300
but could be reducd probably to about 100/200.Let me know if my notes are worth adding to the example :smile:.