Hello Guest

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

  • 4 Replies
  • 15104 Views
*

Offline bobjob

  • ****
  • 394
  • LWJGL: WOW SO GOOD
[SOLVED] Does OpenAL need to be on the main thread?
« on: January 05, 2016, 10:34:21 »
Just wondering if OpenAL is required to load/run on the same main thread along with OpenGL on any OS?
« Last Edit: January 11, 2016, 05:37:33 by bobjob »

*

Kai

Re: Does OpenAL need to be on the main thread?
« Reply #1 on: January 05, 2016, 10:39:01 »
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.

*

Offline bobjob

  • ****
  • 394
  • LWJGL: WOW SO GOOD
Re: Does OpenAL need to be on the main thread?
« Reply #2 on: January 07, 2016, 07:50:31 »
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.

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Does OpenAL need to be on the main thread?
« Reply #3 on: January 07, 2016, 11:14:39 »
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.

*

Offline bobjob

  • ****
  • 394
  • LWJGL: WOW SO GOOD
Re: Does OpenAL need to be on the main thread?
« Reply #4 on: January 07, 2016, 13:24:04 »
thanks, that helps a lot.