veandco / go-sdl2

SDL2 binding for Go
https://godoc.org/github.com/veandco/go-sdl2
BSD 3-Clause "New" or "Revised" License
2.17k stars 219 forks source link

Example not working #566

Closed pro-anon closed 1 year ago

pro-anon commented 1 year ago

Go version: 1.20.2 linux/amd64 Go-SDL2 version: 0.4.34 SDL2 version: 2.26.5-1 OS: Linux arch 6.1.12-arch1-1 Architecture: x86_64

Steps

  1. git clone 'https://github.com/veandco/go-sdl2-examples'
  2. cd examples/audio_wav_memory
  3. go mod init example
  4. go mod tidy
  5. go run ./audio_wav_memory.go

Expected behavior

Hearing the audio, then the program would exit.

Actual behavior

The program just freezes. Nothing happens, no audio is playing, the program doesn't exit, no errors are shown. image

veeableful commented 1 year ago

Hi @pro-anon, thanks for reporting this issue! Could you help me identify where it is stuck? Perhaps by putting some log.Println() lines in-between the SDL2 functions. I wonder if it is stuck at the chunk.Play() line as it is the only one without error checking.

pro-anon commented 1 year ago

At the beginning of the main function

func main() {
    log.Println("Start main function")
    ...
}

Nothing gets printed.

Maybe it's an issue that happens when importing before the main function?

veeableful commented 1 year ago

Hi @pro-anon, could you try running go build instead of go run then run the executable? I wonder if it's simply compiling for the first time which does take some time.

pro-anon commented 1 year ago

You're correct. After some time, it worked. Thanks!

thatnerdjosh commented 10 months ago

@veeableful - it does seem to take quite a while to compile for the first time - do you know why it takes so long/is there any way to optimize this?

veeableful commented 10 months ago

Hi @thatnerdjosh, it needs to compile the go-sdl2 binding first before compiling the example.