I try to build a framework using Unity that allows other developers to add motion cameras like Kinect or the Asus Xtion into their project. For that I use OpenNI2 and a modified version of Zigfu Development Kit to make ONI work with Unity. My problem now is that when I try to enable Zig which in itself seems to load the ONI driver the program will be stuck in an infinite loop if no camera is connected to the computer. After some extensive debugging it seems the source of this loop is the ONI driver itself while waiting for a stream from any motion camera caused by this line:
OniStatus rc = waitForStreams(&stream, 1, &streamIndex, ONI_TIMEOUT_FOREVER);
What I'm looking for is a simple method to prevent ONI from freezing my program. I already tried to wrap the code that causes Zig to start the ONI driver inside a Thread but that didn't work. I could also just add a warning to my framework preventing other devs to at least know what might go wrong when their program freezes, but that might really not be the best choice, I guess.