/* ** Copyright (C) 2002-2004 Daniel Caujolle-Bert ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include "common.h" typedef struct { aa_context *context; int init; } aa_private_t; static void init_video_out(toxine_t *tox) { toxine_vo_plugin_t *vop = (toxine_vo_plugin_t *) tox->video.cur_plugin; aa_private_t *private = (aa_private_t *) vop->private; private->init = 1; private->context = aa_autoinit(&aa_defparams); if(private->context == NULL) { fprintf(stderr,"Cannot initialize AA-lib. Sorry\n"); exit(1); } if(aa_autoinitkbd(private->context, 0) < 1) { fprintf(stderr, "aa_autoinitkdb() failed.\n"); exit(1); } aa_hidecursor(private->context); tox->video.port = xine_open_video_driver(tox->xine, tox->video.name, XINE_VISUAL_TYPE_AA, (void *) private->context); if(tox->video.port == NULL) { fprintf(stderr, "xine_open_video_driver() failed to load '%s' driver.\n", tox->video.name); exit(1); } else pinfo("video driver '%s' successfully loaded.\n", tox->video.name); } static void deinit_video_out(toxine_t *tox) { toxine_vo_plugin_t *vop = (toxine_vo_plugin_t *) tox->video.cur_plugin; aa_private_t *private = (aa_private_t *) vop->private; xine_close_video_driver(tox->xine, tox->video.port); tox->video.port = NULL; private->init = 0; if(private->context) { aa_showcursor(private->context); aa_uninitkbd(private->context); aa_flush(private->context); aa_close(private->context); } } static void release_video_out(toxine_t *tox) { toxine_vo_plugin_t *vop = (toxine_vo_plugin_t *) tox->video.last_plugin; aa_private_t *private = (aa_private_t *) vop->private; if(private->init) deinit_video_out(tox); free(private); free(vop); } static const char *get_identifier(void) { return "AAlib video out"; } static char *_vo_aa_names[] = { "AA", NULL }; static const char **get_names(void) { return (const char **)_vo_aa_names; } static const char *get_help(void) { return "Video out plugin supporting AsciiArt driver.\n"; } static int is_fullscreen(toxine_t *tox) { return 0; } static void fullscreen(toxine_t *tox) { } toxine_vo_plugin_t *toxine_load_vo_plugin(toxine_t *tox) { toxine_vo_plugin_t *aa; aa_private_t *private; aa = (toxine_vo_plugin_t *) xine_xmalloc(sizeof(toxine_vo_plugin_t)); private = (aa_private_t *) xine_xmalloc(sizeof(aa_private_t)); private->init = 0; aa->video_out_init = init_video_out; aa->video_out_event_loop = NULL; aa->video_out_deinit = deinit_video_out; aa->video_out_release = release_video_out; aa->get_identifier = get_identifier; aa->get_names = get_names; aa->get_help = get_help; aa->is_fullscreen = is_fullscreen; aa->receive_xine_event = NULL; aa->fullscreen = fullscreen; aa->private = (void *) private; return aa; }