-
-
Notifications
You must be signed in to change notification settings - Fork 711
Open
Labels
Milestone
Description
Ebitengine Version
v2.8.8
Operating System
- Windows
- macOS
- Linux
- FreeBSD
- OpenBSD
- Android
- iOS
- Nintendo Switch
- PlayStation 5
- Xbox
- Web Browsers
Go Version (go version
)
v1.24.3
What steps will reproduce the problem?
OK, so the issue is that it's possible to set up an infinite loop and then attempt to decode the loop - this makes the loop not take effect, as the stream hasn't been decoded first, but no compile or runtime error is generated, making for a silent "bug". The player works normally once, but then goes silent after the first playthrough.
// byteData is a []byte that contains audio in wav format.
byteReader := bytes.NewReader(byteData)
sampleRate := audio.CurrentContext().SampleRate()
// Loop the audio byte data; of course, this doesn't make sense
looped := audio.NewInfiniteLoop(byteReader, int64(len(byteData)))
// Decode the looped data; these two should be switched in ordering
stream, err := wav.DecodeWithSampleRate(sampleRate, looped)
if err != nil {
panic(err)
}
It might be good to make the DecodeWithSampleRate()
functions panic if they're given *audio.InfiniteLoop
as a source, since it doesn't make sense to decode a loop as it should already be decoded.
What is the expected result?
Maybe a panic?
What happens instead?
No error in compile-time or run-time - the audio just plays back normally once, then looping fails.
Anything else you feel useful to add?
No response