X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fvisualization%2Fgalaktos%2Fplugin.c;h=c02b23c37d3f7040176bd93d1d7e7fc633c6bef6;hb=cc1d1e62c5dd636338ac45a560486dfcc05f2de9;hp=7d8327ec84f3d7490b68f388f98774b8f77fd5aa;hpb=9025fab9931ecc35fe247b0a63d0cea166dee88d;p=vlc diff --git a/modules/visualization/galaktos/plugin.c b/modules/visualization/galaktos/plugin.c index 7d8327ec84..c02b23c37d 100644 --- a/modules/visualization/galaktos/plugin.c +++ b/modules/visualization/galaktos/plugin.c @@ -36,6 +36,7 @@ #include #include +#include /***************************************************************************** * Module descriptor @@ -43,26 +44,38 @@ static int Open ( vlc_object_t * ); static void Close ( vlc_object_t * ); -vlc_module_begin(); - set_description( _("GaLaktos visualization plugin") ); - set_capability( "visualization", 0 ); - set_callbacks( Open, Close ); - add_shortcut( "galaktos" ); -vlc_module_end(); + +#define WIDTH_TEXT N_("Video width") +#define WIDTH_LONGTEXT N_("The width of the video window, in pixels.") + +#define HEIGHT_TEXT N_("Video height") +#define HEIGHT_LONGTEXT N_("The height of the video window, in pixels.") + + +vlc_module_begin () + set_description( N_("GaLaktos visualization") ) + set_capability( "visualization", 0 ) + set_callbacks( Open, Close ) + add_shortcut( "galaktos" ) + add_integer( "galaktos-width", 640, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, + false ) + add_integer( "galaktos-height", 480, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, + false ) +vlc_module_end () /***************************************************************************** * Local prototypes *****************************************************************************/ -typedef struct aout_filter_sys_t +struct aout_filter_sys_t { galaktos_thread_t *p_thread; -} aout_filter_sys_t; +}; static void DoWork ( aout_instance_t *, aout_filter_t *, aout_buffer_t *, aout_buffer_t * ); -static void Thread ( vlc_object_t * ); +static void* Thread ( vlc_object_t * ); static char *TitleGet( vlc_object_t * ); @@ -78,8 +91,8 @@ static int Open( vlc_object_t *p_this ) aout_filter_sys_t *p_sys; galaktos_thread_t *p_thread; - if ( p_filter->input.i_format != VLC_FOURCC('f','l','3','2' ) - || p_filter->output.i_format != VLC_FOURCC('f','l','3','2') ) + if( p_filter->input.i_format != VLC_CODEC_FL32 || + p_filter->output.i_format != VLC_CODEC_FL32 ) { msg_Warn( p_filter, "bad input or output format" ); return VLC_EGENERIC; @@ -101,17 +114,11 @@ static int Open( vlc_object_t *p_this ) vlc_object_create( p_filter, sizeof( galaktos_thread_t ) ); vlc_object_attach( p_thread, p_this ); -/* - var_Create( p_thread, "galaktos-width", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); - var_Get( p_thread, "galaktos-width", &width ); - var_Create( p_thread, "galaktos-height", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); - var_Get( p_thread, "galaktos-height", &height ); -*/ p_thread->i_cur_sample = 0; bzero( p_thread->p_data, 2*2*512 ); - p_thread->i_width = 600; - p_thread->i_height = 600; + p_thread->i_width = var_CreateGetInteger( p_thread, "galaktos-width" ); + p_thread->i_height = var_CreateGetInteger( p_thread, "galaktos-height" ); p_thread->b_fullscreen = 0; galaktos_init( p_thread ); @@ -120,12 +127,12 @@ static int Open( vlc_object_t *p_this ) p_thread->psz_title = TitleGet( VLC_OBJECT( p_filter ) ); if( vlc_thread_create( p_thread, "galaktos update thread", Thread, - VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) ) + VLC_THREAD_PRIORITY_LOW ) ) { msg_Err( p_filter, "cannot lauch galaktos thread" ); - if( p_thread->psz_title ) free( p_thread->psz_title ); + free( p_thread->psz_title ); vlc_object_detach( p_thread ); - vlc_object_destroy( p_thread ); + vlc_object_release( p_thread ); free( p_sys ); return VLC_EGENERIC; } @@ -187,7 +194,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, /***************************************************************************** * Thread: *****************************************************************************/ -static void Thread( vlc_object_t *p_this ) +static void* Thread( vlc_object_t *p_this ) { galaktos_thread_t *p_thread = (galaktos_thread_t*)p_this; @@ -196,41 +203,41 @@ static void Thread( vlc_object_t *p_this ) int timed=0; int timestart=0; int mspf=0; + int canc = vlc_savecancel (); /* Get on OpenGL provider */ p_thread->p_opengl = - (vout_thread_t *)vlc_object_create( p_this, VLC_OBJECT_OPENGL ); + (vout_thread_t *)vlc_object_create( p_this, sizeof( vout_thread_t ) ); if( p_thread->p_opengl == NULL ) { - msg_Err( p_thread, "out of memory" ); - return; + vlc_restorecancel (canc); + return NULL; } vlc_object_attach( p_thread->p_opengl, p_this ); /* Initialize vout parameters */ - vout_InitFormat( &p_thread->p_opengl->fmt_in, - VLC_FOURCC('R','V','3','2'), - p_thread->i_width, p_thread->i_height, 1 ); + video_format_Setup( &p_thread->p_opengl->fmt_in, + VLC_CODEC_RGB32, p_thread->i_width, p_thread->i_height, 1 ); p_thread->p_opengl->i_window_width = p_thread->i_width; p_thread->p_opengl->i_window_height = p_thread->i_height; p_thread->p_opengl->render.i_width = p_thread->i_width; p_thread->p_opengl->render.i_height = p_thread->i_width; p_thread->p_opengl->render.i_aspect = VOUT_ASPECT_FACTOR; - p_thread->p_opengl->b_scale = VLC_TRUE; - p_thread->p_opengl->b_fullscreen = VLC_FALSE; + p_thread->p_opengl->b_fullscreen = false; p_thread->p_opengl->i_alignment = 0; p_thread->p_opengl->fmt_in.i_sar_num = 1; p_thread->p_opengl->fmt_in.i_sar_den = 1; p_thread->p_opengl->fmt_render = p_thread->p_opengl->fmt_in; p_thread->p_module = - module_Need( p_thread->p_opengl, "opengl provider", NULL, 0 ); + module_need( p_thread->p_opengl, "opengl provider", NULL, false ); if( p_thread->p_module == NULL ) { msg_Err( p_thread, "unable to initialize OpenGL" ); vlc_object_detach( p_thread->p_opengl ); - vlc_object_destroy( p_thread->p_opengl ); - return; + vlc_object_release( p_thread->p_opengl ); + vlc_restorecancel (canc); + return NULL; } p_thread->p_opengl->pf_init( p_thread->p_opengl ); @@ -240,27 +247,25 @@ static void Thread( vlc_object_t *p_this ) timestart=mdate()/1000; - while( !p_thread->b_die ) + while( vlc_object_alive (p_thread) ) { mspf = 1000 / 60; if( galaktos_update( p_thread ) == 1 ) { vlc_object_kill( p_thread ); } - if( p_thread->psz_title ) - { - free( p_thread->psz_title ); - p_thread->psz_title = NULL; - } + free( p_thread->psz_title ); + p_thread->psz_title = NULL; + mtime_t now = mdate(); if (++count%100==0) { - realfps=100/((mdate()/1000-fpsstart)/1000); + realfps=100/((now/1000-fpsstart)/1000); // printf("%f\n",realfps); - fpsstart=mdate()/1000; + fpsstart=now/1000; } //framerate limiter - timed=mspf-(mdate()/1000-timestart); + timed=mspf-(now/1000-timestart); // printf("%d,%d\n",time,mspf); if (timed>0) msleep(1000*timed); // printf("Limiter %d\n",(mdate()/1000-timestart)); @@ -268,9 +273,11 @@ static void Thread( vlc_object_t *p_this ) } /* Free the openGL provider */ - module_Unneed( p_thread->p_opengl, p_thread->p_module ); + module_unneed( p_thread->p_opengl, p_thread->p_module ); vlc_object_detach( p_thread->p_opengl ); - vlc_object_destroy( p_thread->p_opengl ); + vlc_object_release( p_thread->p_opengl ); + vlc_restorecancel (canc); + return NULL; } /***************************************************************************** @@ -290,7 +297,7 @@ static void Close( vlc_object_t *p_this ) /* Free data */ vlc_object_detach( p_sys->p_thread ); - vlc_object_destroy( p_sys->p_thread ); + vlc_object_release( p_sys->p_thread ); free( p_sys ); } @@ -303,7 +310,8 @@ static char *TitleGet( vlc_object_t *p_this ) if( p_input ) { - char *psz = strrchr( input_GetItem(p_input)->psz_uri, '/' ); + char *psz_orig = input_item_GetURI( input_GetItem( p_input ) ); + char *psz = strrchr( psz_orig, '/' ); if( psz ) { @@ -311,12 +319,13 @@ static char *TitleGet( vlc_object_t *p_this ) } else { - psz = input_GetItem(p_input)->psz_uri; + psz = psz_orig; } if( psz && *psz ) { psz_title = strdup( psz ); } + free( psz_orig ); vlc_object_release( p_input ); }