veandco / go-sdl2

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

Sound messed up when polling events from a module insead of main #428

Closed Matias-Barrios closed 5 years ago

Matias-Barrios commented 5 years ago

In the game I am making I am polling for vents on the game loop, which works fine and it has no problems. The problem arises when Im trying to poll for events from a module within my app.

I have crated this function that imitates a single key press :

https://github.com/Matias-Barrios/SDL_Universe/blob/master/elements/elements.go#L101-L117

But if I call it from another method as I am doing it here :

https://github.com/Matias-Barrios/SDL_Universe/blob/master/elements/elements.go#L89-L99

The once it goes to the main loop again. the sound is messed up.This issue looks suspiciously similar to this : https://github.com/veandco/go-sdl2/issues/420

Can someone help me fix this?

veeableful commented 5 years ago

Hi @Matias-Barrios, could you provide a simple way to reproduce the issue? Thanks!

Matias-Barrios commented 5 years ago

@veeableful, you can clone my repo directly. Then you let yourself lose which in turn draws You lose on the screen and waits for any key being pressed. Thing is, in order to read that key I'm looping through events. When I do that all sound is messed up from that point onwards

veeableful commented 5 years ago

Hi @Matias-Barrios, could you try using the master branch? I have pushed a similar fix to #420 :relaxed:

Matias-Barrios commented 5 years ago

@veeableful Sure. I'll do. I'll let you know the outcome. Thanks

Matias-Barrios commented 5 years ago

@veeableful Done! It works like charm now. Thanks!