summaryrefslogtreecommitdiff
path: root/src/player.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/player.cc')
-rw-r--r--src/player.cc35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/player.cc b/src/player.cc
index 85a961a..db5b108 100644
--- a/src/player.cc
+++ b/src/player.cc
@@ -31,6 +31,9 @@ Player::Player(Error *err,
Queue<FFFrame> *gqueue,
pthread_mutex_t *gmutex)
{
+ // No errors has ocurred... yet!
+ noErrors = true;
+
char errbuf[256];
errobj = err;
@@ -42,28 +45,39 @@ Player::Player(Error *err,
sem_init(&play_sem, 0, 1);
if(SDL_Init(SDL_INIT_VIDEO) < 0) {
- sprintf(errbuf, "Unable to init SDL: %s\n", SDL_GetError());
+ sprintf(errbuf, "Unable to init SDL: %s.", SDL_GetError());
errobj->pushError(errbuf);
+ noErrors = false;
return;
}
+
screen = SDL_SetVideoMode(DISPLAYWIDTH,
DISPLAYHEIGHT,
- 16,
- SDL_HWSURFACE|SDL_ANYFORMAT|SDL_HWACCEL);
+ 0, // 0 bpp means 'use current display depth'
+ SDL_HWSURFACE | SDL_ANYFORMAT | SDL_HWACCEL);
+
if(!screen) {
- sprintf(errbuf, "Unable to set %dx%d video: %s\n",
+ sprintf(errbuf, "Unable to set %dx%d video: %s.",
DISPLAYWIDTH, DISPLAYHEIGHT, SDL_GetError());
errobj->pushError(errbuf);
+ noErrors = false;
return;
}
- overlay = SDL_CreateYUVOverlay(DISPLAYWIDTH, DISPLAYHEIGHT, SDL_IYUV_OVERLAY, screen);
+ overlay = SDL_CreateYUVOverlay(DISPLAYWIDTH,
+ DISPLAYHEIGHT,
+ SDL_IYUV_OVERLAY, screen);
+ if(!overlay) {
+ sprintf(errbuf, "Unable to create SDL overlay: %s.", SDL_GetError());
+ errobj->pushError(errbuf);
+ noErrors = false;
+ return;
+ }
}
Player::~Player()
{
- if(overlay)
- SDL_FreeYUVOverlay(overlay);
+ SDL_FreeYUVOverlay(overlay);
SDL_Quit();
}
@@ -76,8 +90,9 @@ void Player::player()
int i;
struct timespec ts;
- // rect.x = 20;
- // rect.y = 182;
+ if(!noErrors) return; // FIXME: Gracefully exit...
+
+ // Setup the displayarea.
rect.x = 0;
rect.y = 0;
rect.w = DISPLAYWIDTH;
@@ -94,7 +109,7 @@ void Player::player()
sem_wait(&play_sem);
sem_post(&play_sem);
- if(!SDL_WaitEvent(&event)) break; // FIXME: Gracefull exit...
+ if(!SDL_WaitEvent(&event)) break; // FIXME: Gracefully exit...
switch(event.type) {
case SDL_KEYDOWN: