Author Topic: Issue with BassVst.BASS_VST_GetInfo  (Read 3321 times)

kafffee

  • Posts: 273
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #50 on: 31 Jul '23 - 16:14 »
Hey Ian,

my computer just broke down, and I can't even boot from usb no more, so this might take a little time.

I'll let you know when I'm back on the road...

kafffee

  • Posts: 273
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #51 on: 21 Aug '23 - 12:05 »
Hey Ian, this indeed took a while, I had to get a new computer.

I removed Supertron from that vst folder (respectively did not download it again on my new pc :-)).

Now I get the error as mentioned in post#1 again. I did not activate that MS Symbols Server thing though yet. Do I need to do this again or are we over that? What about enabling page heap in GFlags?

What are your plans now to debug this? Just for me to know, so we can reduce misunderstandings in the future and we can cooperate betterly...

What do you think about Chris' suggestion, to check if there is a memory leak?
« Last Edit: 21 Aug '23 - 22:39 by kafffee »

Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #52 on: 22 Aug '23 - 14:10 »
Good to see you're up and running again :)

Yes, please enable the debug symbols and GFlags stuff again, and then when a crash happens, check the debugger's "Output" window for heap problem messages as well as the call stack. The aim of this is to hopefully find what's corrupting the heap. Please also try the code changes in my last reply.

kafffee

  • Posts: 273
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #53 on: 23 Aug '23 - 11:21 »
Hahaaaa finally did it!   ;D ;D

As your code snippet did not work (I got error #3000 on Dim TestHandle As Integer = BassVst.BASS_VST_ChannelSetDSP(0, PlugInDatei, BASSVSTDsp.BASS_VST_DEFAULT, 0)) I tried to enhance the Sub on myself and came up with this:

   
Code: [Select]
    For Each PlugInDatei In System.IO.Directory.GetFiles(MainModule.VSTVerzeichnis, "*.dll", IO.SearchOption.AllDirectories)
            Dim ProduktNameEffekt As String
            Dim ProduktNameInstrument As String
            Dim vstInfo As New BASS_VST_INFO()

            TestHandleInstrument = BassVst.BASS_VST_ChannelCreate(44100, 2, PlugInDatei, 0)

            Dim TestHandleEffekt As Integer = BassVst.BASS_VST_ChannelSetDSP(0, PlugInDatei, Nothing, 0)


            If (BassVst.BASS_VST_GetInfo(TestHandleEffekt, vstInfo)) AndAlso (Not String.IsNullOrEmpty(vstInfo.effectName)) AndAlso (Not vstInfo.isInstrument) Then
                'ProduktName = vstInfo.productName
                ProduktNameEffekt = vstInfo.effectName
            Else
                ProduktNameEffekt = System.IO.Path.GetFileNameWithoutExtension(PlugInDatei)
            End If

            If (BassVst.BASS_VST_GetInfo(TestHandleInstrument, vstInfo)) AndAlso (Not String.IsNullOrEmpty(vstInfo.productName)) AndAlso (vstInfo.isInstrument) Then
                'ProduktName = vstInfo.productName
                ProduktNameInstrument = vstInfo.effectName
            Else
                ProduktNameInstrument = System.IO.Path.GetFileNameWithoutExtension(PlugInDatei)
            End If

            'BassVst.BASS_VST_ChannelRemoveDSP(0, TestHandleEffekt)
            'BassVst.BASS_VST_ChannelFree(TestHandleInstrument)

            If vstInfo.isInstrument = False Then
                If BassVst.BASS_VST_ChannelSetDSP(0, PlugInDatei, 0, 0) <> 0 Then
                    EffektListe.Add(New ViewModel.PlugInsViewModel(Nothing, PlugInDatei, ProduktNameEffekt, True, 0, Nothing, False, CType(System.Windows.Application.Current.Resources("VordergrundfarbeBrush"), SolidColorBrush), New List(Of Single)))
                Else
                    'BassVst.BASS_VST_ChannelRemoveDSP(0, 0)
                    SindEffekteInvalid = True
                End If
                'EffektListe.Add(New ViewModel.PlugInsViewModel(PlugInDatei, "Effekt1", True, 0, Nothing, False))
                'EffektListe.Add(New ViewModel.PlugInsViewModel(PlugInDatei, "Effekt2", True, 0, Nothing, False))
                'EffektListe.Add(New ViewModel.PlugInsViewModel(PlugInDatei, "Effekt3", True, 0, Nothing, False))
            Else
                Dim InstrumentTestHandle As Integer = BassVst.BASS_VST_ChannelCreate(44100, 2, PlugInDatei, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_SAMPLE_FLOAT)

                If InstrumentTestHandle <> 0 Then
                    InstrumentenListe.Add(New ViewModel.PlugInsViewModel(Nothing, PlugInDatei, ProduktNameInstrument, True, 0, Nothing, False, Nothing, New List(Of Single)))
                Else
                    'BassVst.BASS_VST_ChannelFree(InstrumentTestHandle)
                    SindInstrumenteInvalid = True
                End If

            End If

            BassVst.BASS_VST_ChannelRemoveDSP(0, TestHandleEffekt)
            BassVst.BASS_VST_ChannelFree(TestHandleInstrument)

        Next

I guess the error was that I called vstInfo after I had freed the handles:

Code: [Select]
BassVst.BASS_VST_ChannelRemoveDSP(0, TestHandleEffekt)
BassVst.BASS_VST_ChannelFree(TestHandleInstrument)

But now I got another issue:

In my combobox, which is bound to InstrumentenListe, it will only show Sketch Trumpet and not SuperTron for some reason (SindInstrumenteInvalid turns out to be True, which means the dll is invalid). On my old computer this worked out, as you remember...

The file is being found by For Each PlugInDatei In System.IO.Directory.GetFiles(MainModule.VSTVerzeichnis, "*.dll", IO.SearchOption.AllDirectories), though...

Do you have any clue why?
« Last Edit: 23 Aug '23 - 11:43 by kafffee »

Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #54 on: 23 Aug '23 - 14:22 »
As your code snippet did not work (I got error #3000 on Dim TestHandle As Integer = BassVst.BASS_VST_ChannelSetDSP(0, PlugInDatei, BASSVSTDsp.BASS_VST_DEFAULT, 0))

Is there any more info given, or do you know what "error #3000" means?

Your modified code still looks suboptimal to me, with unnecessary duplicate BASS_VST_ChannelSetDSP/BASS_VST_ChannelCreate calls. I think this code should be tweaked first, before looking into the heap corruption problem if it still persists afterwards.

kafffee

  • Posts: 273
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #55 on: 23 Aug '23 - 14:48 »
Ah okay I think we have a misunderstanding:

I tried what happens when I try to load a Instrument (and not a effect) with ChannelSetDSP. Thats when I get ErrorGetCode = 3000. Which is, according to the docs that it's probably an Instrument. This Sub works with effects and instruments ans separates them into two lists. So this is why I said that it's not working. Besides this fact it should be fine :-)

The heap corruption thing is working now (I tried a couple of times) with Sketch Trumpet.

The problem with SuperTron is just that it gets sorted out as invalid and therefore it's entry does not appear in the combobox, so I cant get to test it

You re totally right when you say its suboptimal and I know that. But at least it seems to work. I tried to fix the problem with the multiple calls of ChannelSetDSP and Channel Create but run into some wird error again, so I decided to post this here for you to take a look at it first if you see any obvious logical mistakes before I start messing around with it...

What could be the cause for it to get marked as invalid? I am not sure if it's exactly the same dll as on my old computer, but I checked the version number and whether it's 64 or 32 bit.

Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #56 on: 23 Aug '23 - 16:08 »
I tried what happens when I try to load a Instrument (and not a effect) with ChannelSetDSP. Thats when I get ErrorGetCode = 3000. Which is, according to the docs that it's probably an Instrument.

Ah, I see now. It looks like BASS_VST_ChannelSetDSP can't be used with chHandle=0 to just get info from a VSTi. That could perhaps be changed (or a new universal info function added) for greater efficiency, but for now, a BASS_VST_ChannelCreate call will also be needed if BASS_VST_ChannelSetDSP fails. Please try this:

Code: [Select]
For Each PlugInDatei In System.IO.Directory.GetFiles(MainModule.VSTVerzeichnis, "*.dll", IO.SearchOption.AllDirectories)
                Dim ProduktName As String
                Dim vstInfo As New BASS_VST_INFO()

                Dim TestHandle As Integer = BassVst.BASS_VST_ChannelSetDSP(0, PlugInDatei, BASSVSTDsp.BASS_VST_DEFAULT, 0)
                If TestHandle = 0 Then
                    TestHandle = BassVst.BASS_VST_ChannelCreate(44100, 2, PlugInDatei, BASSFlag.BASS_STREAM_DECODE)
                End If
                If TestHandle <> 0 Then
                    If (BassVst.BASS_VST_GetInfo(TestHandle, vstInfo)) AndAlso (Not String.IsNullOrEmpty(vstInfo.effectName)) Then
                        ProduktName = vstInfo.effectName
                    Else
                        ProduktName = System.IO.Path.GetFileNameWithoutExtension(PlugInDatei)
                    End If
                    BassVst.BASS_VST_ChannelRemoveDSP(0, TestHandle)
                    If vstInfo.isInstrument = False Then
                        EffektListe.Add(New ViewModel.PlugInsViewModel(Nothing, PlugInDatei, ProduktName, True, 0, Nothing, False, CType(System.Windows.Application.Current.Resources("VordergrundfarbeBrush"), SolidColorBrush), New List(Of Single)))
                    Else
                        InstrumentenListe.Add(New ViewModel.PlugInsViewModel(Nothing, PlugInDatei, ProduktName, True, 0, Nothing, False, Nothing, New List(Of Single)))
                    End If
                End If
            Next

I haven't added a BASS_VST_ChannelFree call because BASS_VST_ChannelRemoveDSP currently also frees VSTi handles. I'm not sure if that's intentional. It isn't mentioned in the BASS_VST.H documentation, so I'm guessing it wasn't intentional, but some users may be depending on it now, so perhaps too late to correct it.

kafffee

  • Posts: 273
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #57 on: 24 Aug '23 - 06:19 »
Okay this works, but I had to do a little change: I moved the ChannelRemoveDSP call right before the Next in the For...Next-Loop:

Code: [Select]
For Each PlugInDatei In System.IO.Directory.GetFiles(MainModule.VSTVerzeichnis, "*.dll", IO.SearchOption.AllDirectories)
    Dim ProduktName As String
    Dim vstInfo As New BASS_VST_INFO()

    Dim TestHandle As Integer = BassVst.BASS_VST_ChannelSetDSP(0, PlugInDatei, BASSVSTDsp.BASS_VST_DEFAULT, 0)
    If TestHandle = 0 Then
        TestHandle = BassVst.BASS_VST_ChannelCreate(44100, 2, PlugInDatei, BASSFlag.BASS_STREAM_DECODE)
    End If
    If TestHandle <> 0 Then
        If (BassVst.BASS_VST_GetInfo(TestHandle, vstInfo)) AndAlso (Not String.IsNullOrEmpty(vstInfo.effectName)) Then
            ProduktName = vstInfo.effectName
        Else
            ProduktName = System.IO.Path.GetFileNameWithoutExtension(PlugInDatei)
        End If

        If vstInfo.isInstrument = False Then
            EffektListe.Add(New ViewModel.PlugInsViewModel(Nothing, PlugInDatei, ProduktName, True, 0, Nothing, False, CType(System.Windows.Application.Current.Resources("VordergrundfarbeBrush"), SolidColorBrush), New List(Of Single)))
        Else
            InstrumentenListe.Add(New ViewModel.PlugInsViewModel(Nothing, PlugInDatei, ProduktName, True, 0, Nothing, False, Nothing, New List(Of Single)))
        End If
    Else
        SindVSTsInvalid = True
    End If
    BassVst.BASS_VST_ChannelRemoveDSP(0, TestHandle)
Next

But still: SuperTron does not appear in InstrumentenListe (SindVSTsInvalid gets set to True)

This might not be our fault, but i'm just wondering because on my old computer, it at least apppeared in InstruemntenListe...

What reasons could there be for this besides that its the wrong bit version (32 or 64 Bit)

I  am not sure whether its completely the same dll file as on my old computer, but I checked version number and 64 Bit compatibility of it...

Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #58 on: 24 Aug '23 - 14:04 »
Okay this works, but I had to do a little change: I moved the ChannelRemoveDSP call right before the Next in the For...Next-Loop:

Strange, why did you need to move that call? BASS_VST_ChannelRemoveDSP only needs to be called when TestHandle isn't 0, so the "if" block should be the right place for it.

But still: SuperTron does not appear in InstrumentenListe (SindVSTsInvalid gets set to True)

That looks like both BASS_VST_ChannelSetDSP and BASS_VST_ChannelCreate failed with it then? If so, please check the error code.

kafffee

  • Posts: 273
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #59 on: 24 Aug '23 - 14:29 »
Quote
Strange, why did you need to move that call? BASS_VST_ChannelRemoveDSP only needs to be called when TestHandle isn't 0, so the "if" block should be the right place for it.

Because if not, the original error as in post #1 of this topic happened again. But you're right, I put the call into the if-block and it works out as well.


Quote
That looks like both BASS_VST_ChannelSetDSP and BASS_VST_ChannelCreate failed with it then? If so, please check the error code.

ErrorCodes on SuperTron are:

ChannelSetDSP: 2 - Can't open the file
ChannelCreate: 0 - All is OK

Can't be my virus protection I guess, I checked the file manually and also I did not get a message when it got executed either...

Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #60 on: 24 Aug '23 - 15:54 »
Quote
Strange, why did you need to move that call? BASS_VST_ChannelRemoveDSP only needs to be called when TestHandle isn't 0, so the "if" block should be the right place for it.

Because if not, the original error as in post #1 of this topic happened again. But you're right, I put the call into the if-block and it works out as well.

But it was already in the "if" block in the code I posted :) ... Have you put it somewhere else now?

Quote
That looks like both BASS_VST_ChannelSetDSP and BASS_VST_ChannelCreate failed with it then? If so, please check the error code.

ErrorCodes on SuperTron are:

ChannelSetDSP: 2 - Can't open the file
ChannelCreate: 0 - All is OK

Strange. Error code 2 is BASS_ERROR_FILEOPEN. If one function fails with that then both should. I'm fairly sure BASS.Net adds the BASS_UNICODE flag automatically, but you could try adding it to both calls yourself anyway. Also make sure you're checking the error code immediately after the failed call (any other BASS call in between will change the error code).

kafffee

  • Posts: 273
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #61 on: 25 Aug '23 - 06:22 »
This is driving me insane now: I just tried to add the BASS_UNICODE flags and then I ran into an errror again. So I removed them and still there is some memory error... (see screenshot (AccessViolation when reading at position 0x00000...8)). Yesterday I tried several times and it worked!!! And I did not make any code changes since then...

This is what I have (yes, I put the BASS_VST_ChannelRemoveDSP call somewhere else):

Code: [Select]
For Each PlugInDatei In System.IO.Directory.GetFiles(MainModule.VSTVerzeichnis, "*.dll", IO.SearchOption.AllDirectories)
    Dim ProduktName As String
    Dim vstInfo As New BASS_VST_INFO()

    Dim TestHandle As Integer = BassVst.BASS_VST_ChannelSetDSP(0, PlugInDatei, BASSVSTDsp.BASS_VST_DEFAULT, 0)
    Debug.WriteLine("ChannelSetDSP Error: " & CStr(Bass.BASS_ErrorGetCode))
    If TestHandle = 0 Then
        TestHandle = BassVst.BASS_VST_ChannelCreate(44100, 2, PlugInDatei, BASSFlag.BASS_STREAM_DECODE)
        Debug.WriteLine("ChannelCreate Error: " & CStr(Bass.BASS_ErrorGetCode))
        Debug.WriteLine("Fertig!!")
    End If
    If TestHandle <> 0 Then
        If (BassVst.BASS_VST_GetInfo(TestHandle, vstInfo)) AndAlso (Not String.IsNullOrEmpty(vstInfo.effectName)) Then
            ProduktName = vstInfo.effectName
        Else
            ProduktName = System.IO.Path.GetFileNameWithoutExtension(PlugInDatei)
        End If

        If vstInfo.isInstrument = False Then
            EffektListe.Add(New ViewModel.PlugInsViewModel(Nothing, PlugInDatei, ProduktName, True, 0, Nothing, False, CType(System.Windows.Application.Current.Resources("VordergrundfarbeBrush"), SolidColorBrush), New List(Of Single)))
        Else
            InstrumentenListe.Add(New ViewModel.PlugInsViewModel(Nothing, PlugInDatei, ProduktName, True, 0, Nothing, False, Nothing, New List(Of Single)))
        End If
        BassVst.BASS_VST_ChannelRemoveDSP(0, TestHandle)
    Else
        SindVSTsInvalid = True
    End If

Next

What do you suggest? Do you think we are ever gonna find out what the problem is?

Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #62 on: 25 Aug '23 - 15:12 »
That looks like the "Sketch Trumpet.dll" VST crashed in its UI message handling. I guess it only happens after you call BASS_VST_EmbedEditor on the VST? If so, how is that being called?

kafffee

  • Posts: 273
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #63 on: 25 Aug '23 - 16:27 »
Good News!!

Sketch Trumpet seems to be broken. Even though for some reason, it did (!) work yesterday...

I tried a bunch of other VSTs and they all worked.

The SuperTron VST requires C++ Redistributable, so this is fine as well.

I wrote a little demo program which  repoduces the trouble with Sketch Trumpet. If you want so, I can post it or send it to you, in case you want to evaluate this further.

This would be the link to the VST DLL:

https://plugins4free.com/plugin/2557/

Edit:

By the way, how can I deactivate that MS Symbol Server thing, before I forget :-)
« Last Edit: 25 Aug '23 - 16:57 by kafffee »

Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #64 on: 25 Aug '23 - 17:39 »
I wrote a little demo program which  repoduces the trouble with Sketch Trumpet. If you want so, I can post it or send it to you, in case you want to evaluate this further.

This would be the link to the VST DLL:

https://plugins4free.com/plugin/2557/

Sure, if you upload the little demo project (please include the sources), I'll see if I can spot the cause of the problem.

By the way, how can I deactivate that MS Symbol Server thing, before I forget :-)

You can disable it in Visual Studio's Debugging->Symbols options page.

kafffee

  • Posts: 273
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #65 on: 25 Aug '23 - 17:42 »
Cool.

As of sources you are talking about the source codes?

Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #66 on: 25 Aug '23 - 17:53 »
Yep.

kafffee

  • Posts: 273
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #67 on: 28 Aug '23 - 13:52 »
Okay here it comes  :)

You need to have Visual Studio 2022, it's a .NET Framework 4.8 WinForms app. Visual Studio 2019 should work out as well.

I removed any compiled stuff from the project folder.

You need to first click "Scan VST Folder", then click "Show VST UI".

Let me know about your results respectively if you can't open it :)

Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #68 on: 30 Aug '23 - 13:15 »
Yep, I'm able to reproduce the problem with that. Without seeing the VST's source code, it's hard to be sure what the problem is, but it seems like the VST may be uninitializing when all instances of the VST are freed and then not reinitializing when another instance is created (resulting in the problem). For example, the problem doesn't happen if you don't call BASS_VST_ChannelRemoveDSP in Button3_Click, or if you add an extra BASS_VST_ChannelCreate call there (before BASS_VST_ChannelRemoveDSP), so that there are never no instances of the VST.

Perhaps the VST is expecting to be unloaded when there are no instances and then reloaded when needed, but BASS_VST delays unloading by 10 seconds. The problem doesn't happen if you wait 10 seconds before pressing the "Show VST UI" button. I tried removing the unload delay, and indeed the problem didn't happen then either. But the BASS_VST code contains this comment: "unload the library delayed - otherwise we get some curious crashes here and there". So I guess some other VST require the delay.

   https://github.com/r10s/BASS_VST/blob/0c8bf510f888e12333a5201ff038b12a6111de51/source/bass_vst_handle.cpp#L151

I'm not sure what the answer is.

kafffee

  • Posts: 273
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #69 on: 30 Aug '23 - 17:34 »
Okay so I guess it's hard to catch that error as well (with a Try... Catch-Block?)?

Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #70 on: 31 Aug '23 - 13:33 »
Unfortunately, that doesn't seem to help much. The problem seems to be that the VST is in a dodgy state after freeing all instances, and the only way out of that is to unload/reload it. So here's a BASS_VST update with the option of disabling the unload delay:

   www.un4seen.com/stuff/bass_vst.zip

It adds this new BASS_VST_ChannelSetDSP/BASS_VST_ChannelCreate flag:

Code: [Select]
#define BASS_VST_NODELAYUNLOAD 2

Of course, that isn't in BASS.Net yet, but you can use its value (2) with "CType" for now. For example, like this:

Code: [Select]
            Dim TestHandle As Integer = BassVst.BASS_VST_ChannelSetDSP(0, PlugInDatei, BASSVSTDsp.BASS_VST_DEFAULT Or CType(2, BASSVSTDsp), 0)
            If TestHandle = 0 Then
                TestHandle = BassVst.BASS_VST_ChannelCreate(44100, 2, PlugInDatei, BASSFlag.BASS_STREAM_DECODE Or CType(2, BASSFlag))
            End If

kafffee

  • Posts: 273
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #71 on: 5 Sep '23 - 12:20 »
Quote
The problem doesn't happen if you wait 10 seconds before pressing the "Show VST UI" button.

I have noticed that behavior, too, but I also noticed that you cannot rely on these 10 seconds.

Well anyways, I think we can close this thread for now.

Thanks for the support, that was even more than I expected :)

rv

  • Posts: 387
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #72 on: 5 Sep '23 - 12:35 »
Can you tell me how to disable the unloading delay?

The actual code is :

Quote
   // unload the library delayed - otherwise we get some curious crashes here and there ...
   // if the library is aleady pending, increase the unload counter
   EnterCriticalSection(&s_idleCritical);
      long oldVal = (long)sjhashFind(&s_unloadPendingInstances, this_->hinst,0 /*pKey, not needed*/
         /*nKey*/);

      sjhashInsert(&s_unloadPendingInstances,  /*pKey, not needed*/ this_->hinst,0, /*nKey*/
         (void*)(oldVal+1)/*pData*/);

      s_unloadPendingCountdown = IDLE_UNLOAD_PENDING_COUNTDOWN;
      createIdleTimers();
   LeaveCriticalSection(&s_idleCritical);

Ian @ un4seen

  • Administrator
  • Posts: 26095
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #73 on: 5 Sep '23 - 16:52 »
In the update above, that code is changed to this:

Code: [Select]
if (this_->createFlags & BASS_VST_NODELAYUNLOAD)
{
#ifdef _WIN32
FreeLibrary(this_->hinst);
#elif __linux__
dlclose(this_->hinst);
#else
// CFBundleUnloadExecutable(this_->hinst); // causes a crash with some VST?
CFRelease(this_->hinst);
#endif
}
else
{
// unload the library delayed - otherwise we get some curious crashes here and there ...
// if the library is aleady pending, increase the unload counter
EnterCriticalSection(&s_idleCritical);
long oldVal = (long)sjhashFind(&s_unloadPendingInstances, this_->hinst, 0);

sjhashInsert(&s_unloadPendingInstances, this_->hinst, 0,
(void*)(oldVal + 1)/*pData*/);

s_unloadPendingCountdown = IDLE_UNLOAD_PENDING_COUNTDOWN;
createIdleTimers();
LeaveCriticalSection(&s_idleCritical);
}

Basically copying the unload code from the idleDo function. If you want to always (not optionally) disable the delay then you can change the first line to "if (true)".

rv

  • Posts: 387
Re: Issue with BassVst.BASS_VST_GetInfo
« Reply #74 on: 6 Sep '23 - 01:20 »
Thanks. It seems to work ok with all my vst
If someone has experience with crashing on unload of vst because of this, let us know