I am using the desktop duplication API right now to record my desktop. I want it to record at at least 30FPS. I noticed that AcquireNextFrame would often return DXGI_ERROR_WAIT_TIMEOUT if I set the time out period to be 33 (33ms is approximately equal to 30FPS) while there is nothing happening on the screen (or even very little). What I have been doing to avoid this is I draw a pixel to the bottom left hand corner of the screen every 30FPS. Like so:
HDC hdc = GetDC(0);
SetPixel(hdc, 0, height, (light_black) ? 0x2 : 0x4);
light_black = !light_black;
ReleaseDC(0, hdc);
This works actually fairly well, but it will still occasionally return DXGI_ERROR_WAIT_TIMEOUT, which is hurting my performance. Considering my solution to this problem is a bit hacky, and it is not even quite working I'd like to figure out how I can resolve this. How can I force AcquireNextFrame to return successfully at a minimum rate of 30FPS?