Descructors are never called in Unity Editor, so streams never get closed
jackbrookes opened this issue · comments
For example, this line:
https://github.com/labstreaminglayer/liblsl-Csharp/blob/master/LSL.cs#L323
Is never called in the Unity Editor. Therefore, the stream stays alive after stopping playing.
I modified the code to manually close the stream, by adding a method:
public void close_stream() { dll.lsl_destroy_outlet(obj); }
But when I call this, the next time I press play, it crashes the editor. Any way forward with this?
A solution is to re-open a stream with the same ID.
We currently have a pull request that adds an implementation of IDisosable.Dispose to all the LSL objects. This may (no promises) solve your problem. It will be a day or two before we finish merging, but I would suggest checking out the latest version once it's completed. I'd be curious to know if it does in fact help with your issue.
@jackbrookes , with the merge of #10 I think your issue is now solved so I'm going to close it.
If you're still experiencing trouble then please let us know.