I don't know if you have solved this problem by now and as several people have told you, there is not enough information in your question to really help you out. However, I will take a stab at what could be going on as I fixed something similar 10-11 years ago and if this post does not help you at all, maybe somebody else can bring it to good use some day.
My advice is based on the following guesses:
- You are using DirectDraw to display the video.
- Your video display is in full-screen mode before Windows is locked.
If this is the case, I am betting your DD surfaces are "lost" and you need to restore them again. Basically, Windows takes control of the display, leaving you to do some error handling. See
IDirectDrawSurface7::Restore()[
^] "Remarks" section.
If am wrong and you are not using DirectDraw, it is probably a similar issue, but a different technology.
You should always check the state of your DD surfaces before operating on them. In DirectDraw based video applications, the video frame is normally written to an off-screen surface and later that surface is "blitted" to the primary (visible) surface - you need to check all your surfaces.
The code below is my quick mix of real and pseudo code without all the actual function parameters and with other standard operations (such as valid pointer checks) eliminated for readability.
Typically, you call PrepareVideoFrame() when you receive a video frame. When it is time to paint it, you call DisplayVideoFrame(). The functions are called from somewhere in your program and you should check the return values to see if there are problems.
The important part is this: When we have to write the video data to the off-screen surface, we first try to lock the surface. If that fails because the surface is lost, we try to restore it and lock it again. If we were unable to lock it on this attempt, we give up - it is very likely that Windows is displaying its "lock screen" and we just have to wait until it releases its hold on the display.
BOOL PrepareVideoFrame(BYTE* pFrame)
{
HRESULT ddErr = m_pOffScreen->Lock();
if (ddErr != DD_OK)
{
if (ddErr == DDERR_SURFACELOST)
{
m_pOffScreen->Restore();
if (m_pOffScreen->Lock() == DDERR_SURFACELOST)
{
return FALSE;
}
}
else
{
return FALSE;
}
}
m_pOffScreen->Unlock();
return TRUE;
}
BOOL DisplayVideoFrame()
{
HRESULT ddErr = m_pOffScreen->GetBltStatus(DDGBS_CANBLT);
if (ddErr != DD_OK && ddErr != DDERR_WASSTILLDRAWING)
{
return FALSE;
}
if (m_pPrimary->IsLost())
{
m_pPrimary->Restore();
}
ddErr = m_pPrimary->Blt(m_pOffScreen);
if (ddErr != DD_OK)
{
return FALSE;
}
return TRUE;
}
I hope this helps somebody out there.
Soren Madsen