Issue with threading and AUD

(Nicholas_A) #1

I am using the AUD module to stream music from soundcloud to play in my game. The streaming works fine. However, when I press spacebar to change songs, the game still gets caught up. The threading works. It does everything in a separate thread from the game. I was able to isolate the issue to line 90 of the script:, where it actually plays the music with

Here is the blend to try it: Space Game 2018-4-15.blend (1.87 MB)

Controls are W, S, A, D to fly, and Spacebar to change songs.

(sdfgeoff) #2

BGE is not thread-safe, so it doesn’t surprise me that calling from another thread is causing issues. Maybe use a cross-thread-communication channel (queue, flag, semaphore etc) and have the called from the main BGE thread.

(Nicholas_A) #3

Didn’t work. It causes blender to freeze.

(BluePrintRandom) #4

maybe start a external py app and use it ?
Is there a way to include py 3x version in a installer?

install it,(if it does not exist) - call it and startup a seperate gil basically.

( #5

As mentioned before, putting this here for other people:

Run the download in a thread, feed the thread the URLs via one queue, download the music and put it in a file, put the URI of the file on disk into a second queue, in a controller main loop on each tick try to pop the URIs back in the main thread and play the musics then.

The idea is to just download the files in the thread.