none
LockRect and the C++ SkeletalViewer RRS feed

  • Question

  • Hi guys,

    I'm still running into the issue where my two separate kinect processing processes crash if spawned simultaneously, but do not if I have a large enough gap between their creation.

    If they both start at the same time, either one or both crash on the LockRect function.

    I notice that the C++ SkeletalViewer example does not allow you to show two video streams at once, perhaps for this purpose? As a result, I am at a loss to figure out how I would access my video frames simultaneously from two processes. I realise that the C# example has done this properly, but I don't really know where to start looking there. And everything is so abstracted anyway, that I don't think that it will be very useful.

    The question is this: do I need to implement a semaphore in shared memory in order to bypass this issue, or is there a separate version of LockRect which doesn't spit the dummy when I access it at roughly the same time from two processes?

    Wednesday, January 18, 2012 11:06 PM

Answers

  • Do you check the HRESULT of the locking operation before you try to access the memory that it points to?  Why would you want to set up your code to have more than one thread accessing the frame at the same time?

    I think in general that it is safe to assume that if the manual doesn't explicitly say that the API is thread safe then it probably isn't!

    • Marked as answer by Emile Victor Friday, January 20, 2012 6:34 AM
    Thursday, January 19, 2012 9:03 PM

All replies

  • So... I implemented a semaphore which wraps around the LockRect stuff, but I think this should be already implemented in the API, or at documented. Perhaps you could provide a separate version of it which doesn't have issues with multiple processes accessing it simultaneously?

    It *kind-of* works now.


    Clever, witty forum signature.
    Thursday, January 19, 2012 1:12 AM
  • Do you check the HRESULT of the locking operation before you try to access the memory that it points to?  Why would you want to set up your code to have more than one thread accessing the frame at the same time?

    I think in general that it is safe to assume that if the manual doesn't explicitly say that the API is thread safe then it probably isn't!

    • Marked as answer by Emile Victor Friday, January 20, 2012 6:34 AM
    Thursday, January 19, 2012 9:03 PM
  • Turns out I wasn't returning from my HRESULT checker; therefore it was just continuing with the application and a useless pointer. Once it tried to access that pointer it was crashing.

    I've currently gotten to the point of having independent signals being shared via shared memory from two kinects doing individual skeleton tracking.

     

    I'm a happy camper.


    Clever, witty forum signature.
    Friday, January 20, 2012 6:34 AM