The reason is:
The ddrawsurface is lost, and the ddraw surface is lost in many cases (for example, when other full-screen exclusive programs, screen saver, or screen lock programs are started ), surface loss is actually the memory or video memory used on the surface is released by the DirectDraw system and allocated to other programs. if the surface is lost, all operations on the surface will return dderr_surfacelost. At this time, you should call the idirectdrawsurface interface method restore to restore the surface (re-apply for memory or display memory ).
The pseudocode is as follows:
HR = m_lpddsoffscreen-> lock (rcdest, & ddsd, ddlock_surfacememoryptr | ddlock_wait, null );
If (hR = dderr_surfacelost)
{
HR = m_lpddsoffscreen-> restore ();
HR = m_lpddsoffscreen-> lock (rcdest, & ddsd, ddlock_wait, null );
}
If (failed (HR ))
{
Return dd_false;
}
// Copy the data to the off-screen surface and transmit it to the main surface using BLT blocks.
Hresult ddrval;
Ddrval = lpddsprimary-> BLT (null, lpddsoffscreen, null, ddblt_wait, null );
If (ddrval = dderr_surfacelost)
{
Lpddsprimary-> restore ();
}
In this way, when the screen saver, screen lock, modify the screen resolution, the surface can be restored, and the video is displayed normally
You can also use the ddraw object to restore all surfaces as follows:
Lpdd-> restoreallsurfaces ();
Where
Lpdirectdraw7 lpdd;
DirectDraw displays the YUV video. When Screen Saver is displayed, YUV cannot be displayed and the surface is lost.