From 63ac729b32331438a607ec5b8be046143c7592e6 Mon Sep 17 00:00:00 2001 From: deva Date: Sat, 26 Mar 2005 10:32:50 +0000 Subject: Added an error object for genereic error message handling. --- src/player.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/player.cc') diff --git a/src/player.cc b/src/player.cc index a860afa..9a697f9 100644 --- a/src/player.cc +++ b/src/player.cc @@ -25,11 +25,15 @@ #include "player.h" -Player::Player(volatile int *grunning, +Player::Player(Error *err, + volatile int *grunning, sem_t *gsem, Queue *gqueue, pthread_mutex_t *gmutex) { + char errbuf[256]; + errobj = err; + running = grunning; sem = gsem; queue = gqueue; @@ -38,17 +42,19 @@ Player::Player(volatile int *grunning, sem_init(&play_sem, 0, 1); if(SDL_Init(SDL_INIT_VIDEO) < 0) { - fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); - exit(1); + sprintf(errbuf, "Unable to init SDL: %s\n", SDL_GetError()); + errobj->setError(errbuf); + return; } screen = SDL_SetVideoMode(DISPLAYWIDTH, DISPLAYHEIGHT, 16, SDL_HWSURFACE|SDL_ANYFORMAT|SDL_HWACCEL); if(!screen) { - fprintf(stderr, "Unable to set %dx%d video: %s\n", + sprintf(errbuf, "Unable to set %dx%d video: %s\n", DISPLAYWIDTH, DISPLAYHEIGHT, SDL_GetError()); - exit(1); + errobj->setError(errbuf); + return; } overlay = SDL_CreateYUVOverlay(DISPLAYWIDTH, DISPLAYHEIGHT, SDL_IYUV_OVERLAY, screen); -- cgit v1.2.3