Bit of an odd thread, you want feedback but supply no context, which makes giving feedback difficult.
The topic of delaying initialization of the audio layer in Blender has come up again recently.
This sounds like a means to an end, delaying initialization doesn’ t seem like a goal on its own, It’s likely meant to solve some kind of problem, but it’s unclear from the information given what this problem is? You say it has come up again, can you add some context here, how did it come up? when was the last time this came up? why didn’t we fix “the problem” back then?
I have loked into managing device state by using
AUD_exit() from Blender side. This can lead to memory leaks and crashes if some data structures aren’t managed properly. Also code would be harder to maintalin and understand without knowledge of Audaspace internals.
I expect to be able to call any library’s init/exit functions at any time without having to worry about its internal state. If audaspace has issues in that department, perhaps it’s good to fix and upstream those, or report to @neXyon and have them fixed, as audaspace would be a better library for it.
Better approach seems to be to implement this feature on Audaspace side.
Why is this better?
I have tested this with WASAPI, OpenAL and Core Audio. So far, only OpenAL implementation proved to be problematic.
Why was it problematic?
In general, the approach is to initialize the device when playback starts and release the device when playback stops.
Certainly sounds like something you could do, but I still have no idea what the problem is you are solving, so unable to decide if this is a good solution or not.
There is a rather simplistic patch for Core Audio, that implements this feature with builds available. More technical details and todo’s are in patch description.
Kinda strange, you tested with WASAPI, OpenAL and Core Audio, openAL had issues so it be valuable to include it and have a comment on where it is misbehaving, yet the patch only includes CoreAudio.
Feedback is welcome!
My suggestion is to talk to @neXyon about whatever the issue is you are having, and by that i mean the actual actual issue and see what his thoughts are on the subject. Maybe the direction you are going is the right one, but from the information and patch given, it is impossible to tell.
feels a bit like an xyproblem