Hi everyone,
I’m using SDL 1.2 to play a video stream through an SDL YUV Overlay.
While running under Windows and moving the window (grabbing it by the
frame and moving it all around the desktop) in which I play my video,
the video stops as if the program was frozen until I stop moving the SDL
window. This behaviour is different than under Linux for when I move the
SDL window, the video keeps being displayed normally.
It doesn’t come as a problem to me, except that the program freezes
completely depending on the time I move the window, but I was wondering
if this behaviour was normal or not and if there was a good explanation
to this. Is it related to how the video memory is accessed while being
in Windows or Linux, the type of video card I’m using? Or just something
wrong I’ve done?
Here’s how I initialize / run my SDL YUV Overlay in a mix of code and
pseudo-code, don’t mind about whether it can compile or not, it’s just
for you to understand the way I do this…
// Initialization
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
cerr << "Error: Cannot initialize SDL: " << SDL_GetError() << endl;
return false;
}
screen = SDL_SetVideoMode(width, height, 32, SDL_DOUBLEBUF|
SDL_HWSURFACE|
SDL_HWPALETTE|
SDL_ANYFORMAT|
SDL_RESIZABLE);
if(screen == 0){
cerr << "Error: Cannot set video mode: " << SDL_GetError() << endl;
return false;
}
overlay = SDL_CreateYUVOverlay(width, height, SDL_YV12_OVERLAY,
screen);
if(overlay == 0){
cerr << "Error: Cannot create YUV overlay: " << SDL_GetError()
<< endl;
return false;
}
// Linking the stream to the overlay:
SDL_LockYUVOverlay(overlay);
if(SDL_MUSTLOCK(screen))
SDL_LockSurface(screen);
/*Linking the video stream data to the YUV overlay planes...*/
SDL_UnlockYUVOverlay(overlay);
if(SDL_MUSTLOCK(screen))
SDL_UnlockSurface(screen);
// Displaying the stream on the overlay:
SDL_Rect rectangle;
rectangle.x = rectangle.y = 0;
rectangle.w = (Uint16)screen->w;
rectangle.h = (Uint16)screen->h;
SDL_DisplayYUVOverlay(overlay, &rectangle);
Thanks for the help,
Jerome