/* ** 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 #ifdef CACA_API_VERSION_1 #include #endif #include #include #include #include "common.h" typedef struct { int init; pthread_t loop_thread; } caca_private_t; #if 0 static void *caca_event_loop(void *data) { toxine_t *tox = (toxine_t *) data; toxine_vo_plugin_t *vop = (toxine_vo_plugin_t *) tox->video.cur_plugin; caca_private_t *private = (caca_private_t *) vop->private; while(tox->video.running) { unsigned int event; while((event = caca_get_event(CACA_EVENT_ANY))) { if(event == CACA_EVENT_NONE) pinfo("NONE\n"); else if(event & CACA_EVENT_KEY_PRESS) pinfo("KEYPRESS\n"); else if(event & CACA_EVENT_KEY_RELEASE) pinfo("KEYRELEASE\n"); else if(event & CACA_EVENT_MOUSE_PRESS) pinfo("MOUSE_PRESS\n"); else if(event & CACA_EVENT_MOUSE_RELEASE) pinfo("MOUSERELEASE\n"); else if(event & CACA_EVENT_MOUSE_MOTION) pinfo("MOUSEMOTION\n"); else if(event & CACA_EVENT_RESIZE) pinfo("RESIZE\n"); } } pthread_exit(NULL); } #endif static void init_video_out(toxine_t *tox) { toxine_vo_plugin_t *vop = (toxine_vo_plugin_t *) tox->video.cur_plugin; caca_private_t *private = (caca_private_t *) vop->private; private->init = 1; tox->video.port = xine_open_video_driver(tox->xine, tox->video.name, XINE_VISUAL_TYPE_CACA, NULL); 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; caca_private_t *private = (caca_private_t *) vop->private; xine_close_video_driver(tox->xine, tox->video.port); tox->video.port = NULL; private->init = 0; } static void release_video_out(toxine_t *tox) { toxine_vo_plugin_t *vop = (toxine_vo_plugin_t *) tox->video.last_plugin; caca_private_t *private = (caca_private_t *) vop->private; if(private->init) deinit_video_out(tox); free(private); free(vop); } static const char *get_identifier(void) { return "CACAlib video out"; } static char *_vo_caca_names[] = { "CACA", NULL }; static const char **get_names(void) { return (const char **)_vo_caca_names; } static const char *get_help(void) { return "Video out plugin supporting ColorAsCiiArt driver.\n"; } static int is_fullscreen(toxine_t *tox) { return 0; } static void fullscreen(toxine_t *tox) { } #if 0 static void *event_loop(void *data) { toxine_t *tox = (toxine_t *) data; toxine_vo_plugin_t *vop = (toxine_vo_plugin_t *) tox->video.cur_plugin; caca_private_t *private = (caca_private_t *) vop->private; pthread_detach(pthread_self()); while(tox->video.running) { caca_refresh(); xine_usec_sleep(33000); } pthread_exit(NULL); } #endif toxine_vo_plugin_t *toxine_load_vo_plugin(toxine_t *tox) { toxine_vo_plugin_t *caca; caca_private_t *private; caca = (toxine_vo_plugin_t *) xine_xmalloc(sizeof(toxine_vo_plugin_t)); private = (caca_private_t *) xine_xmalloc(sizeof(caca_private_t)); private->init = 0; caca->video_out_init = init_video_out; caca->video_out_event_loop = NULL; caca->video_out_deinit = deinit_video_out; caca->video_out_release = release_video_out; caca->get_identifier = get_identifier; caca->get_names = get_names; caca->get_help = get_help; caca->is_fullscreen = is_fullscreen; caca->receive_xine_event = NULL; caca->fullscreen = fullscreen; caca->private = (void *) private; return caca; }