FPSDK - Tracking mixer thread changes

Here you can find (time limited) beta's for plugins & program components

Return to “Public Betas - Plugins & Components”

[You can only see part of this thread as you are not logged in to the forums]
superjoebob
Thu Dec 02, 2021 11:35 pm

x

FPSDK - Tracking mixer thread changes

I'm working on a plugin that requires each thread ID to be registered and un-registered as it comes and goes. This has been working fine for the GUI thread, as the GUI functions always seem to be called by the same thread and I can just un-register the GUI thread when the plugin terminates. The problem I'm having is that when I register the mixer thread in Gen_Render, there's no guarantee that next time Gen_Render is called it will be on the same thread. The thread ID changes -in particular, when changing a mixer channel's input- which I assume has to do with multithreaded mixer processing.

So in Gen_Render (or any other potential mixer thread function) I might register it as threadID 31020 for example, but next time it comes around it's now running on threadID 42020. At that point 31020 is left forever registered, which leads to crashes in my code when FL finally releases that thread.

The registering and unregistering is expensive, so registering at the start of the function and unregistering at the end unfortunately isn't a good option. I could also keep track of the threadID Gen_Render gives me, and un-register the old ID as soon as a new one appears, but I worry this might lead to a race condition where one of my threads tries to access the released thread before I'm able to un-register it (unless there's a guarantee that Gen_Render will be called once with the new thread before the old thread is terminated, but that seems unlikely?).

Wondering if there's some way to receive a notification when a mixer thread changes/is terminated, or alternatively if there's some way to ensure my plugin remains on the same mixer thread? Is there potentially some way I could use Lock/UnlockMix_Shared() for this purpose?


superjoebob
Thu Jan 27, 2022 8:20 pm

x

Re: FPSDK - Tracking mixer thread changes

Sorry for not getting back to you on this, the ...


Return to “Public Betas - Plugins & Components”