This project has moved and is read-only. For the latest updates, please go here.

Implementing GetTimeInfo Causes Crash

Topics: Host Development, Host Processing, Midi, Plugin Development, VST.NET Core
Dec 7, 2015 at 9:15 AM
For a long time I left this method unimplemented but recently I started passing through the time info from the DAW that my plugin is hosted in to a plugin that my plugin is hosting. I do this so that the hosted plugin has access to the midi clock for sequencing.

But, I just remembered that this was causing crashes. I was getting a crash, and sure enough, when I return a new VstTimeInfo, it works fine.

Some more info is that actually it doesn't disturb my plugin when the transport is not running, but on about the 3rd or 4th loop, Ableton comes down. The funny thing is that the sound gets more distorted on every loop. It's a sine wave at first, and becomes something more like a sawtooth until Ableton crashes.

Any thoughts on what I should be doing? Or, what I might be doing wrong. This is the offending code:
        public core.VstTimeInfo GetTimeInfo(core.VstTimeInfoFlags filterFlags)
                return _DAWCommandStub.GetTimeInfo(filterFlags);
Dec 7, 2015 at 9:23 AM
For some reason I have VstTimeInfo backed up as a property in my host. If you create VstTimeInfo on the fly and lose managed reference of it, the structure can get garbage collected before it's content is inspected by the plugin/host. ________________________________________
Dec 7, 2015 at 9:25 AM
You could try to get the TimeInfo in the Process (audio processor) and assign it to an instance member. Return that value to your clients.
Dec 7, 2015 at 10:47 AM
@Yuri: Managed Host with an unmanaged plugin?
The interoplayer simply copies the values from the managed time info to a permanent unmanaged time info object.
See "case audioMasterGetTime:"

Any error messages or does the host simple crash (corrupted memory usually)...?
Dec 7, 2015 at 9:01 PM
These are some things to think about...

Managed Host with an unmanaged plugin?
The scenario is that my .Net plugin is hosted in Ableton, and my plugin hosts FM8 (an unmanaged plugin). So, this is who asks for what (time info)

FM8->My Synth->Ableton

Any error messages or does the host simple crash (corrupted memory usually)...?
I think it's corrupted memory but will check.

I'm starting to think that this has something to do with canDo. I think that I might be telling FM8 that my synth can do something it can't...
Dec 8, 2015 at 6:36 AM
When the unmanaged plugin you host calls GetTimeInfo it ends up at the (Interop.Host)VstHostCommandProxy where the unmanaged VstTimeInfo structure is a member of the host command proxy instance. It calls into the managed IVstHostCommandStub interface (you implement) to retrieve the managed values and copies them into the unmanaged struct.

Then your plugin (acting as the managed host) calls into the (unmanaged Ableton) Host using (Interop.Plugin)HostCommandStub with the GetTimeInfo call. (GetTimeInfo)

Here too the (managed) VstTimeInfo structure is a member of the command stub instance. Only its values are copied over each time.

So the values are copied twice (cant be helped) but all instances of the VstTimeInfo - managed and unmanaged - are preallocated and fixed.
The values themselves are simple blitable types copied by assignment...

Based on this information I can not predict what the problem is and it would require some debugging to get to the bottom of this...
Dec 8, 2015 at 8:22 PM
No problem. I'll do some further investigation and try some new permutations of code. If I can't solve the problem I'll try to put something together to repro the problem. The thing is, this may only happen in Ableton. Such is the joy of subtle differences in hosts...