[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [fluid-dev] Possible approach to preloading samples / presets

From: Tom M.
Subject: Re: [fluid-dev] Possible approach to preloading samples / presets
Date: Sun, 25 Oct 2020 11:33:46 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0

Ok, I see.

So, my preference of implementing this is to use the pinning approach.

I'm thinking of a function like

fluid_synth_pin_preset(synth, fluid_preset_t*)

The function will attempt to pin all samples of the given preset and
load them into memory, if they are currently unloaded. "to pin" in this
context means preventing them from being unloaded by an upcoming channel
prog change. If successful, FLUID_OK is returned.

If the preset doesn't support pinning (because it's a DLS preset, which
doesn't use the sample cache currently), FLUID_FAILED is returned.

If the preset supports pinning, but dynamic-sample-loading is disabled,
FLUID_OK is still returned. Not an error, it is already loaded and will
never be unloaded.

No exposing of the internal sample cache is needed.

Ofc, we'll need a way to unpin presets. I'd vote for a separate "unpin"
function. This function should unset the is_pinned flag. Again, if the
preset doesn't support pinning, FLUID_FAILED is returned. Ideally, the
function also unloads the samples if the given preset is no longer
referenced by any channel. In this case, care must be taken to avoid a
race condition with the rendering thread: If you unload the samples from
memory (because the ref count was zero) and just right afterwards, the
rendering thread selects the sample again, then just make sure that the
sample is first being unloaded cleanly and then loaded back cleanly.
Can't remember if you were already using some kind of synchronization
like that, didn't had a look.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]