From aa76292f4ceb8bfa94066bd035dda81c95bc9052 Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 26 Jul 2005 16:16:56 +0000 Subject: Added fullscreen functionality. --- src/player.cc | 75 +++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 30 deletions(-) (limited to 'src/player.cc') diff --git a/src/player.cc b/src/player.cc index 8556ce6..f98b9a0 100644 --- a/src/player.cc +++ b/src/player.cc @@ -39,6 +39,10 @@ /* * $Log$ + * Revision 1.31 2005/07/26 16:16:56 deva + * + * Added fullscreen functionality. + * * Revision 1.30 2005/07/25 16:18:34 deva * *** empty log message *** * @@ -80,6 +84,9 @@ #include +// For sleep +#include + Player::Player(Info *ginfo, int w, int h, volatile int *grunning, @@ -104,8 +111,7 @@ Player::Player(Info *ginfo, initSDL(); - doresize = false; - dopause = false; + bypass = false; } Player::~Player() @@ -137,10 +143,12 @@ void Player::initSDL() return; } - screen = SDL_SetVideoMode(720,//width, - 576,//height, + screen = SDL_SetVideoMode(width, + height, 0, // 0 bpp means 'use current display depth' - SDL_HWSURFACE | SDL_ANYFORMAT | SDL_HWACCEL); + SDL_HWSURFACE | + SDL_ANYFORMAT | + SDL_HWACCEL ); if(!screen) { info->error("Unable to set %dx%d video: %s.", @@ -150,8 +158,8 @@ void Player::initSDL() return; } - overlay = SDL_CreateYUVOverlay(720,//width, - 576,//height, + overlay = SDL_CreateYUVOverlay(720, + 576, SDL_YUY2_OVERLAY, // Match for the libdv decoder output screen); if(!overlay) { @@ -160,13 +168,19 @@ void Player::initSDL() printf("failed!\n"); return; } + + // Setup the displayarea. + rect.x = 0; + rect.y = 0; + rect.w = width; + rect.h = height; + printf("done!\n"); } void Player::player() { SDL_Event event; - SDL_Rect rect; Frame *frame; int pitches[3]; @@ -174,12 +188,6 @@ void Player::player() struct timespec ts; if(!noErrors) return; // FIXME: Gracefully exit... - - // Setup the displayarea. - rect.x = 0; - rect.y = 0; - rect.w = width; - rect.h = height; bool first = true; dv_decoder_t *decoder = dv_decoder_new(FALSE/*this value is unused*/, FALSE, FALSE); @@ -190,15 +198,7 @@ void Player::player() sem_wait(&play_sem); sem_post(&play_sem); - if(doresize) { - width = new_width; - height = new_height; - reinitSDL(); - doresize = false; - dopause = false; - } - - if(dopause) continue; + if(bypass) continue; if(!SDL_WaitEvent(&event)) break; // FIXME: Gracefully exit... @@ -283,16 +283,31 @@ void Player::stop() sem_wait(&play_sem); } +// FIXME: Worst case genario: the loop takes more than 1 second +// to stop displaying => crash, due to deinitialization +// of SDL, while calling it.! void Player::resize(int w, int h) { - new_width = w; - new_height = h; - doresize = true; -} + printf("Resizing to: %d x %d\n", w, h); -void Player::pause() -{ - dopause = true; + // Tell loop to stop + bypass = true; + + // Wait to ensure the current frame is done being displayed + sleep(1); + + // Deinitialize SDL + deinitSDL(); + + // Set new size + width = w; + height = h; + + // Initialize SDL + initSDL(); + + // Tell loop to go on. + bypass = false; } #endif /* USE_GUI */ -- cgit v1.2.3