[SOLVED] Does OpenAL need to be on the main thread?

Started by bobjob, January 05, 2016, 10:34:21

Previous topic - Next topic

bobjob

Just wondering if OpenAL is required to load/run on the same main thread along with OpenGL on any OS?

Kai

Neither OpenGL nor OpenAL need to run on the main thread. You can "render" graphics and sound on any thread.
What you probably mean by "OpenGL" is the need for window creation and window message processing to be on the main thread with some OS'es.

bobjob

When I used LWJGL 2 i had to make sure all GL calls were on the same Thread. I thought that LWJGL3 was the same, and that maybe OpenAL.

My issue is one of dynamic loading. I wanted to know how much resource loading I can get away with by loading it on another Thread. In this case making calls to bind the buffer.

spasi

OpenGL has the concept of current contexts. You can only call OpenGL functions in threads where a context is current (but that doesn't mean you can't have multiple contexts in multiple threads).

OpenAL normally has a process-wide context. You can call OpenAL functions from any thread. Unless you use the ALC_EXT_thread_local_context extension, in which case it operates more like OpenGL.

In terms of performance, it does make sense to use a separate thread for OpenAL. Especially with OpenAL Soft that LWJGL ships with, all sound processing happens on the CPU. It may be trivial for plain stereo playback, but depending on the features/extensions used (e.g. ALC_EXT_EFX or ALC_SOFT_HRTF), it can get costly.

bobjob