diff --git a/fallback/windows-nui/src/sensor.cpp b/fallback/windows-nui/src/sensor.cpp index 4b6a8ad..39671e6 100644 --- a/fallback/windows-nui/src/sensor.cpp +++ b/fallback/windows-nui/src/sensor.cpp @@ -367,21 +367,26 @@ HRESULT VirtualKinectSensor::ImageStreamGetNextFrame( } EnterCriticalSection(&lock_); - static unsigned img_calls = 0; - const bool has = stream->has_frame; - const int stype = static_cast(stream->type); - if (img_calls < 6 || (img_calls % 150u) == 0u) { - ShimLog("ImageStreamGetNextFrame call#%u type=%d has_frame=%d", img_calls, - stype, has ? 1 : 0); - } - ++img_calls; - if (!has) { + if (!stream->has_frame) { LeaveCriticalSection(&lock_); return E_NUI_FRAME_NO_DATA; } + const uint32_t frame_no = stream->frames[stream->latest_index].dwFrameNumber; + if (frame_no == stream->last_delivered_frame_number) { + LeaveCriticalSection(&lock_); + return E_NUI_FRAME_NO_DATA; + } + stream->last_delivered_frame_number = frame_no; stream->outstanding = true; *ppcImageFrame = &stream->frames[stream->latest_index]; + const int stype = static_cast(stream->type); LeaveCriticalSection(&lock_); + static unsigned img_delivered = 0; + if (img_delivered < 6 || (img_delivered % 150u) == 0u) { + ShimLog("ImageStreamGetNextFrame delivered#%u type=%d frame=%u", + img_delivered, stype, frame_no); + } + ++img_delivered; return S_OK; } diff --git a/fallback/windows-nui/src/sensor.h b/fallback/windows-nui/src/sensor.h index 0918328..17d700e 100644 --- a/fallback/windows-nui/src/sensor.h +++ b/fallback/windows-nui/src/sensor.h @@ -37,6 +37,7 @@ struct ImageStream { std::size_t latest_index = 0; bool has_frame = false; bool outstanding = false; + uint32_t last_delivered_frame_number = 0; }; class VirtualKinectSensor {