diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/xine-engine/tvmode.c | 118 |
1 files changed, 83 insertions, 35 deletions
diff --git a/src/xine-engine/tvmode.c b/src/xine-engine/tvmode.c index 653b1eba9..e0434523f 100644 --- a/src/xine-engine/tvmode.c +++ b/src/xine-engine/tvmode.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: tvmode.c,v 1.3 2002/06/25 14:42:58 mroi Exp $ + * $Id: tvmode.c,v 1.4 2002/07/09 12:45:18 f1rmb Exp $ * * tvmode - TV output selection * @@ -35,6 +35,8 @@ #include "nvtvd.h" /* FIXME: how to include that? */ /*#include "xine.h" */ +#include "xine_internal.h" +#include "xineutils.h" /* @@ -51,6 +53,9 @@ static double current_fps; static TVCrtRegs old_crt; static TVRegs old_tv; +static int tvmode_enabled; +static int was_enabled = 0; + /* TODO: config, and better */ static TVSystem opt_system = TV_SYSTEM_PAL; @@ -81,10 +86,25 @@ static int opt_flicker = -1; static double opt_aspect = 4.0 / 3.0; /* Just turn off warnings */ -void xine_tvmode_exit (void); +static void _tvmode_init(xine_t *this); +void xine_tvmode_exit (xine_t *this); + +/* + * Config callback for tvmode enability. + */ +static void nvtvmode_enable_cb(void *this_gen, cfg_entry_t *entry) { + xine_t *this = (xine_t *) this_gen; + + tvmode_enabled = entry->num_value; + + if(!tvmode_enabled && was_enabled) { + xine_tvmode_exit(this); + was_enabled = 0; + } +} /* Try to connect to nvtvd server */ -static void tvmode_connect () { +static void tvmode_connect(xine_t *this) { CardInfo *card = 0; @@ -98,35 +118,37 @@ static void tvmode_connect () { back_card = 0; } - if (back_card) - back_card->openCard (card); + if (back_card) { + back_card->openCard (card); + was_enabled = 1; + } else - printf("tvmode: cannot connect to nvtvd - no TV mode switching available\n"); + printf("tvmode: cannot connect to nvtvd - no TV mode switching available\n"); } /* Disconnect from server */ -static void tvmode_disconnect () { +static void tvmode_disconnect (xine_t *this) { back_card->closeCard (); back_card = 0; } /* Save current CRT and TV register configuration */ -static void tvmode_savestate () { +static void tvmode_savestate (xine_t *this) { back_card->getMode (&old_crt, &old_tv); } /* Restore CRT and TV register configuration */ -static void tvmode_restorestate () { +static void tvmode_restorestate (xine_t *this) { back_card->setMode (0, &old_crt, &old_tv); current_type = 0; } /* Set CRT and TV registers to given TV-Out configuration */ -static void tvmode_settvstate (int width, int height, double fps) { +static void tvmode_settvstate (xine_t *this, int width, int height, double fps) { TVSettings settings; TVMode mode; @@ -169,7 +191,7 @@ static void tvmode_settvstate (int width, int height, double fps) { current_type = 1; } else { printf("tvmode: cannot find any valid TV mode - TV output disabled\n"); - xine_tvmode_exit (); + xine_tvmode_exit (this); } } @@ -179,59 +201,85 @@ static void tvmode_settvstate (int width, int height, double fps) { */ /* Set to 'regular'(0) or 'tv'(1) state, that is if it is enabled */ -int xine_tvmode_switch (int type, int width, int height, double fps) { - +int xine_tvmode_switch (xine_t *this, int type, int width, int height, double fps) { + + if(tvmode_enabled) { + + /* + * Wasn't initialized + */ + if(!was_enabled) + _tvmode_init(this); + if (back_card) { printf("tvmode: switching to %s\n", type ? "TV" : "default"); switch (type) { case 0: - tvmode_restorestate (); - break; + tvmode_restorestate (this); + break; case 1: - tvmode_settvstate (width, height, fps); + tvmode_settvstate (this, width, height, fps); break; default: printf("tvmode: illegal type for switching\n"); - tvmode_restorestate (); + tvmode_restorestate (this); } } else { printf("tvmode: not connected to nvtvd for switching\n"); } - return current_type; + + } + + return current_type; } /* Addapt (maximum) output size to visible area and set pixel aspect and fps */ -void xine_tvmode_size (int *width, int *height, +void xine_tvmode_size (xine_t *this, int *width, int *height, double *pixelratio, double *fps) { + if(tvmode_enabled) { + switch (current_type) { case 1: - if (width && *width > current_width) - *width = current_width; - if (height && *height > current_height) - *height = current_height; - if (pixelratio) - *pixelratio = ((double) current_width / current_height) / opt_aspect; - if (fps) - *fps = current_fps; - break; + if (width && *width > current_width) + *width = current_width; + if (height && *height > current_height) + *height = current_height; + if (pixelratio) + *pixelratio = ((double) current_width / current_height) / opt_aspect; + if (fps) + *fps = current_fps; + break; } + + } } /* Connect to nvtvd server if possible and fetch settings */ -void xine_tvmode_init () { - tvmode_connect (); +static void _tvmode_init(xine_t *this) { + if(tvmode_enabled) { + tvmode_connect (this); if (back_card) - tvmode_savestate (); + tvmode_savestate (this); + } +} +void xine_tvmode_init (xine_t *this) { + + tvmode_enabled = this->config->register_bool(this->config, "misc.nv_tvmode", 0, + _("Show status on play, pause, ff, ..."), NULL, + nvtvmode_enable_cb, this); + _tvmode_init(this); } - /* Restore old CRT and TV registers and close nvtvd connection */ -void xine_tvmode_exit () { +void xine_tvmode_exit (xine_t *this) { + + if(tvmode_enabled || was_enabled) { if (back_card) { - tvmode_restorestate (); - tvmode_disconnect (); + tvmode_restorestate (this); + tvmode_disconnect (this); } + } } |