X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fvideo_output%2Fcaca.c;h=63e437f26379b75a97d17b34263c03502d217d0a;hb=6dce48f670a1d404fa09898d6e97562d9944c239;hp=f68f4f84ee4a7eab31725821284f9c0d04f86a47;hpb=f4fd4afc62069f34a88d7be3c3b316fea97d73a1;p=vlc diff --git a/modules/video_output/caca.c b/modules/video_output/caca.c index f68f4f84ee..63e437f263 100644 --- a/modules/video_output/caca.c +++ b/modules/video_output/caca.c @@ -1,7 +1,7 @@ /***************************************************************************** * caca.c: Color ASCII Art video output plugin using libcaca ***************************************************************************** - * Copyright (C) 2003, 2004 the VideoLAN team + * Copyright (C) 2003-2009 the VideoLAN team * $Id$ * * Authors: Sam Hocevar @@ -24,9 +24,17 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include /* ENOMEM */ -#include /* free() */ -#include /* strerror() */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include +#include +#include #include @@ -53,11 +61,6 @@ # define caca_set_display_title(x,y) caca_set_window_title(y) #endif -#include -#include -#include -#include - /***************************************************************************** * Local prototypes *****************************************************************************/ @@ -73,14 +76,14 @@ static void Display ( vout_thread_t *, picture_t * ); /***************************************************************************** * Module descriptor *****************************************************************************/ -vlc_module_begin(); - set_shortname( "Caca" ); - set_category( CAT_VIDEO ); - set_subcategory( SUBCAT_VIDEO_VOUT ); - set_description( _("Color ASCII art video output") ); - set_capability( "video output", 12 ); - set_callbacks( Create, Destroy ); -vlc_module_end(); +vlc_module_begin () + set_shortname( "Caca" ) + set_category( CAT_VIDEO ) + set_subcategory( SUBCAT_VIDEO_VOUT ) + set_description( N_("Color ASCII art video output") ) + set_capability( "video output", 12 ) + set_callbacks( Create, Destroy ) +vlc_module_end () /***************************************************************************** * vout_sys_t: libcaca video output method descriptor @@ -161,7 +164,9 @@ static int Create( vlc_object_t *p_this ) p_vout->p_sys = malloc( sizeof( vout_sys_t ) ); if( p_vout->p_sys == NULL ) { - msg_Err( p_vout, "out of memory" ); +#if defined( WIN32 ) && !defined( UNDER_CE ) + FreeConsole(); +#endif return VLC_ENOMEM; } @@ -169,6 +174,9 @@ static int Create( vlc_object_t *p_this ) if( !p_vout->p_sys->p_cv ) { msg_Err( p_vout, "cannot initialize libcucul" ); +#if defined( WIN32 ) && !defined( UNDER_CE ) + FreeConsole(); +#endif free( p_vout->p_sys ); return VLC_EGENERIC; } @@ -178,6 +186,9 @@ static int Create( vlc_object_t *p_this ) { msg_Err( p_vout, "cannot initialize libcaca" ); cucul_free_canvas( p_vout->p_sys->p_cv ); +#if defined( WIN32 ) && !defined( UNDER_CE ) + FreeConsole(); +#endif free( p_vout->p_sys ); return VLC_EGENERIC; } @@ -306,14 +317,22 @@ static int Manage( vout_thread_t *p_vout ) vlc_value_t val; #ifdef CACA_API_VERSION_1 +#ifdef CACA_EVENT_OPAQUE + switch( caca_get_event_type( &ev ) ) +#else switch( ev.type ) +#endif /* CACA_EVENT_OPAQUE */ #else switch( ev ) #endif { case CACA_EVENT_KEY_RELEASE: #ifdef CACA_API_VERSION_1 +#ifdef CACA_EVENT_OPAQUE + switch( caca_get_event_key_ch( &ev ) ) +#else switch( ev.data.key.ch ) +#endif /* CACA_EVENT_OPAQUE */ #else switch( ev & 0x00ffffff ) #endif @@ -336,29 +355,38 @@ static int Manage( vout_thread_t *p_vout ) break; #ifdef CACA_API_VERSION_1 case CACA_EVENT_MOUSE_MOTION: - val.i_int = ev.data.mouse.x * p_vout->render.i_width + val.i_int = +#ifdef CACA_EVENT_OPAQUE + caca_get_event_mouse_x( &ev ) +#else + ev.data.mouse.x +#endif /* CACA_EVENT_OPAQUE */ + * p_vout->render.i_width / cucul_get_canvas_width( p_vout->p_sys->p_cv ); var_Set( p_vout, "mouse-x", val ); - val.i_int = ev.data.mouse.y * p_vout->render.i_height + val.i_int = +#ifdef CACA_EVENT_OPAQUE + caca_get_event_mouse_y( &ev ) +#else + ev.data.mouse.y +#endif /* CACA_EVENT_OPAQUE */ + * p_vout->render.i_height / cucul_get_canvas_height( p_vout->p_sys->p_cv ); var_Set( p_vout, "mouse-y", val ); - val.b_bool = VLC_TRUE; - var_Set( p_vout, "mouse-moved", val ); + var_SetBool( p_vout, "mouse-moved", true ); break; case CACA_EVENT_MOUSE_RELEASE: - val.b_bool = VLC_TRUE; - var_Set( p_vout, "mouse-clicked", val ); + var_SetBool( p_vout, "mouse-clicked", true ); break; case CACA_EVENT_QUIT: { - p_playlist = vlc_object_find( p_vout, - VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); + p_playlist = pl_Hold( p_vout ); if( p_playlist ) { playlist_Stop( p_playlist ); - vlc_object_release( p_playlist ); + pl_Release( p_vout ); } - p_vout->p_libvlc->b_die = VLC_TRUE; + libvlc_Quit( p_vout->p_libvlc ); break; } #endif @@ -375,7 +403,7 @@ static int Manage( vout_thread_t *p_vout ) *****************************************************************************/ static void Render( vout_thread_t *p_vout, picture_t *p_pic ) { - cucul_set_color( p_vout->p_sys->p_cv, + cucul_set_color_ansi( p_vout->p_sys->p_cv, CUCUL_COLOR_DEFAULT, CUCUL_COLOR_BLACK ); cucul_clear_canvas( p_vout->p_sys->p_cv ); cucul_dither_bitmap( p_vout->p_sys->p_cv, 0, 0, @@ -389,6 +417,7 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic ) *****************************************************************************/ static void Display( vout_thread_t *p_vout, picture_t *p_pic ) { + VLC_UNUSED(p_pic); caca_refresh_display( p_vout->p_sys->p_dp ); }