How is the sound handled in the engine?

Is it also hardbaked into the loop? I mean, does it stop/pause when assets are loaded or scene is changed? If not, I may actually come up with some artificial gameplay element like dark souls’ fog walls to make you stay still to hide assets loading.

As already said, the GDevelop engine is a single threaded engine. So, the sound loading is done in the main thread. Then, obviously the sound is played from another thread (so it won’t freeze even if the game freezes).

Doesn’t that mean that it’s multithreaded with second thread being used for sound? ^^’ That’s why I asked actually. And I may be able to work with that.

It’s the only exception. In fact, the engine doesn’t even create the thread itself as it is created by the multimedia library used by the engine (SFML).

Now I wonder if something like that can be used to load textures, and only create objects in question when it’s done.

UPD: You just call external library and gibe it that task, then check if textures are loaded every frame, like you do anyway to not load copies.

No. :frowning:

But that sounds so similar and easy :c

This is not the same at all.

Why can’t you just take away the ability to load anything from main engine, and make a separate program that runs in the background and listens for calls from the engine as to what to load? And maybe even reports back on the progress, so we could have loading bars, and engine knows exactly when to create object without wasting resources for checking.

It’s not possible to share loaded data between programs (the RAM of each process are separated).

How can separate library play the music loaded by the engine then? And is it the same for GPU memory?

Because it’s a library, linked to the program, executed in the same program.

Well, then just make another library that manages textures!

Library != Thread. Making a library doesn’t mean you execute the things into another thread. The sound playback threading is only possible because it’s sounds. Besides, the sound loading is done in the main thread.

How is it playing though if the whole thing is bottlenecked? Just doesn’t make any sense…

The main loop is making it playing : receiving events from the OS (mouse clicks, …), update the data (to reflect the changes and react to events), rendering the game and so on, again and again. It’s an “infinite” loop that makes the game playable.

I meant music when I said “playing”, if it’s playing from the same program, it would pause when that program gets bottlenecked by cpu or anything really.

No, because executed from another thread of the program. However, loading texture from another thread is not possible (limitation of OpenGL).

Then play the game logic from another thread.

I meant physics and forces when I said “logic”, just don’t pause them.