| 2521 | } |
| 2522 | |
| 2523 | XnStatus xnWaitForCondition(XnContext* pContext, XnConditionFunc pConditionFunc, void* pConditionData) |
| 2524 | { |
| 2525 | XnStatus nRetVal = XN_STATUS_OK; |
| 2526 | |
| 2527 | xnMarkFPSFrame(pContext, &pContext->readFPS); |
| 2528 | |
| 2529 | // check if we have players in this context |
| 2530 | // TODO: handle the case in which we have more than one player |
| 2531 | if (pContext->hPlayerNode != NULL) |
| 2532 | { |
| 2533 | // play until condition is met |
| 2534 | while (!pConditionFunc(pConditionData)) |
| 2535 | { |
| 2536 | if (xnIsPlayerAtEOF(pContext->hPlayerNode)) |
| 2537 | { |
| 2538 | return XN_STATUS_EOF; |
| 2539 | } |
| 2540 | else |
| 2541 | { |
| 2542 | nRetVal = xnPlayerReadNext(pContext->hPlayerNode); |
| 2543 | XN_IS_STATUS_OK(nRetVal); |
| 2544 | } |
| 2545 | } |
| 2546 | } |
| 2547 | else |
| 2548 | { |
| 2549 | // no players, just wait for the event |
| 2550 | nRetVal = xnOSWaitForCondition(pContext->hNewDataEvent, XN_NODE_WAIT_FOR_DATA_TIMEOUT, pConditionFunc, pConditionData); |
| 2551 | if (nRetVal == XN_STATUS_OS_EVENT_TIMEOUT) |
| 2552 | { |
| 2553 | return (XN_STATUS_WAIT_DATA_TIMEOUT); |
| 2554 | } |
| 2555 | XN_IS_STATUS_OK(nRetVal); |
| 2556 | } |
| 2557 | |
| 2558 | return (XN_STATUS_OK); |
| 2559 | } |
| 2560 | |
| 2561 | XN_C_API XnStatus xnWaitAndUpdateAll(XnContext* pContext) |
| 2562 | { |
no test coverage detected