ebiten: audio/vorbis: EOF error when decoding
OS : Windows Ebiten : v2 (2.3.7) Vorbis : v1.0.2
I have been running into an error when I started implementing audio for my game.
panic: EOF
goroutine 1 [running, locked to thread]:
github.com/---/chessgo/pkg/sounds.GetTracks(0xc000069d60?)
E:/code/chess_go/pkg/sounds/sounds.go:25 +0xf4
github.com/---/chessgo/pkg/board.InitBoard(0xc000054000?, 0x100c000048058?, 0xc00011c180)
E:/code/chess_go/pkg/board/board.go:104 +0x229
main.main()
E:/code/chess_go/main.go:41 +0x75
Tried going through the documentation and source code, but cannot figure things out. I’m currently creating a new player like so :
package sounds
import (
"github.com/hajimehoshi/ebiten/v2/audio"
"github.com/hajimehoshi/ebiten/v2/audio/vorbis"
"bytes"
_ "embed"
)
// go:embed capture.ogg
var CaptureRaw []byte
// go:embed move.ogg
var MoveRaw []byte
func GetTracks(ctx *audio.Context) (*audio.Player){
s, err := vorbis.Decode(ctx, bytes.NewReader(MoveRaw))
if err != nil {
panic(err)
}
capture, err := ctx.NewPlayer(s)
if err != nil {
panic(err)
}
return capture
}
And I call this function by simply passing in the reference to the audio context I’ve created
// Sounds
log.Println(actx)
move:= sounds.GetTracks(actx)
But as said previously it runs into some kind of deadlock. Would be great if someone could look into this !
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (11 by maintainers)
Commits related to this issue
- update github.com/jfreymuth/oggvorbis to v1.0.4 This improves an error message when an empty source is passed to the decoder. Updates #2251 — committed to hajimehoshi/ebiten by hajimehoshi 2 years ago
- update github.com/jfreymuth/oggvorbis to v1.0.4 This improves an error message when an empty source is passed to the decoder. Updates #2251 — committed to superloach/ebiten by hajimehoshi 2 years ago
I have reported this (when an empty stream is passed,
NewReader
just returnedio.EOF
, but I think we can get a better error) https://github.com/jfreymuth/oggvorbis/issues/9Thank you so much for the help !! 😄
In summary, I have succeeded to play a sound by this change: