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

Most upvoted comments

I have reported this (when an empty stream is passed, NewReader just returned io.EOF, but I think we can get a better error) https://github.com/jfreymuth/oggvorbis/issues/9

Thank you so much for the help !! 😄

In summary, I have succeeded to play a sound by this change:

diff --git a/main.go b/main.go
index 4cb5321..ffc2d17 100644
--- a/main.go
+++ b/main.go
@@ -1,6 +1,7 @@
 package main
 
 import (
+       _ "embed"
        "log"
 
        "bytes"
@@ -35,7 +36,7 @@ func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeigh
        return cfg.WindowWidth, cfg.WindowHeight
 }
 
-// go:embed sound.ogg
+//go:embed move.ogg
 var moveRaw []byte
 
 func main() {