X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fvideo_output%2Fvout_intf.c;h=4aefc6729a889489cc50d9b2e77561f83f522bcf;hb=1290cd7ea4fb2e980f223da3d4812daef48c2550;hp=f210f5b57a36c1da0d50d4a2a344ff291536234c;hpb=859436564cd0b85e76b888a88205424ede9cb412;p=vlc diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c index f210f5b57a..4aefc6729a 100644 --- a/src/video_output/vout_intf.c +++ b/src/video_output/vout_intf.c @@ -29,7 +29,7 @@ # include "config.h" #endif -#include +#include #include #include /* free() */ @@ -104,9 +104,22 @@ void *vout_RequestWindow( vout_thread_t *p_vout, *pi_height_hint = p_vout->i_window_height; /* Check whether someone provided us with a window ID */ - var_Get( p_vout->p_libvlc, "drawable", &val ); - if( val.i_int ) return (void *)(intptr_t)val.i_int; - + int drawable = var_CreateGetInteger( p_vout, "drawable" ); + if( drawable ) return (void *)(intptr_t)drawable; + +#if 0 + /* FIXME: + * This code is utter crap w.r.t. threading. And it has always been. + * First, one cannot invoke callbacks from another thread's object. + * Not without a well-defined locking convention. + * + * Second, this would need to "wait" for the interface to be ready. + * Otherwise, the availability of the embded window would become + * time-dependent. + * + * In the past, this kind of things worked by accident. This time is over. + * -- Courmisch, 12 Jun 2008 + */ /* Find if the main interface supports embedding */ p_list = vlc_list_find( p_vout, VLC_OBJECT_INTF, FIND_ANYWHERE ); if( !p_list ) return NULL; @@ -134,6 +147,9 @@ void *vout_RequestWindow( vout_thread_t *p_vout, else p_vout->p_parent_intf = p_intf; return p_window; +#else + return NULL; +#endif } void vout_ReleaseWindow( vout_thread_t *p_vout, void *p_window ) @@ -264,7 +280,7 @@ static void AddCustomRatios( vout_thread_t *p_vout, const char *psz_var, void vout_IntfInit( vout_thread_t *p_vout ) { vlc_value_t val, text, old_val; - vlc_bool_t b_force_par = VLC_FALSE; + bool b_force_par = false; char *psz_buf; int i; @@ -287,6 +303,9 @@ void vout_IntfInit( vout_thread_t *p_vout ) var_Create( p_vout, "video-x", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "video-y", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); + var_Create( p_vout, "mouse-hide-timeout", + VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); + p_vout->b_title_show = var_CreateGetBool( p_vout, "video-title-show" ); p_vout->i_title_timeout = (mtime_t)var_CreateGetInteger( p_vout, "video-title-timeout" ); @@ -348,7 +367,7 @@ void vout_IntfInit( vout_thread_t *p_vout ) } /* update triggered every time the vout's crop parameters are changed */ - var_Create( p_vout, "crop-update", VLC_VAR_VOID ); + var_Create( p_vout, "crop-update", VLC_VAR_VOID ); /* Add custom crop ratios */ psz_buf = config_GetPsz( p_vout, "custom-crop-ratios" ); @@ -390,7 +409,7 @@ void vout_IntfInit( vout_thread_t *p_vout ) msg_Dbg( p_vout, "overriding monitor pixel aspect-ratio: %i:%i", p_vout->i_par_num, p_vout->i_par_den ); - b_force_par = VLC_TRUE; + b_force_par = true; } free( val.psz_string ); @@ -460,7 +479,7 @@ void vout_IntfInit( vout_thread_t *p_vout ) var_Create( p_vout, "mouse-clicked", VLC_VAR_INTEGER ); var_Create( p_vout, "intf-change", VLC_VAR_BOOL ); - var_SetBool( p_vout, "intf-change", VLC_TRUE ); + var_SetBool( p_vout, "intf-change", true ); } /***************************************************************************** @@ -481,7 +500,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) memset( &fmt_out, 0, sizeof(video_format_t) ); var_Get( p_vout, "snapshot-path", &val ); - if( !*val.psz_string ) + if( val.psz_string && !*val.psz_string ) { free( val.psz_string ); val.psz_string = 0; @@ -502,7 +521,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) /* Destination object-id is following object: */ i_id = atoi( &val.psz_string[7] ); - p_dest = ( vlc_object_t* )vlc_current_object( i_id ); + p_dest = ( vlc_object_t* )vlc_object_get( i_id ); if( !p_dest ) { msg_Err( p_vout, "Cannot find calling object" ); @@ -573,15 +592,15 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) } #if defined(__APPLE__) || defined(SYS_BEOS) - if( !val.psz_string && p_vout->p_libvlc->psz_homedir ) + if( !val.psz_string ) { if( asprintf( &val.psz_string, "%s/Desktop", - p_vout->p_libvlc->psz_homedir ) == -1 ) + config_GetHomeDir() ) == -1 ) val.psz_string = NULL; } #elif defined(WIN32) && !defined(UNDER_CE) - if( !val.psz_string && p_vout->p_libvlc->psz_homedir ) + if( !val.psz_string ) { /* Get the My Pictures folder path */ @@ -619,8 +638,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) if( p_mypicturesdir == NULL ) { - if( asprintf( &val.psz_string, "%s", - p_vout->p_libvlc->psz_homedir ) == -1 ) + if( asprintf( &val.psz_string, "%s", config_GetHomeDir() ) == -1 ) val.psz_string = NULL; } else @@ -634,17 +652,19 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) #else /* XXX: This saves in the data directory. Shouldn't we try saving * to psz_homedir/Desktop or something nicer ? */ - if( !val.psz_string && p_vout->p_libvlc->psz_datadir ) + char *psz_datadir = config_GetUserDataDir(); + if( !val.psz_string && psz_datadir ) { - if( asprintf( &val.psz_string, "%s", - p_vout->p_libvlc->psz_datadir ) == -1 ) + if( asprintf( &val.psz_string, "%s", psz_datadir ) == -1 ) val.psz_string = NULL; } + free( psz_datadir ); #endif if( !val.psz_string ) { msg_Err( p_vout, "no path specified for snapshots" ); + image_HandlerDelete( p_image ); return VLC_EGENERIC; } var_Get( p_vout, "snapshot-format", &format ); @@ -672,7 +692,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) } closedir( path ); - if( var_GetBool( p_vout, "snapshot-sequential" ) == VLC_TRUE ) + if( var_GetBool( p_vout, "snapshot-sequential" ) == true ) { int i_num = var_GetInteger( p_vout, "snapshot-num" ); FILE *p_file; @@ -717,19 +737,23 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) fmt_out.i_width = var_GetInteger( p_vout, "snapshot-width" ); fmt_out.i_height = var_GetInteger( p_vout, "snapshot-height" ); + fmt_in = p_vout->fmt_in; + if( fmt_out.i_width == 0 && fmt_out.i_height > 0 ) { - float f = (float)p_vout->fmt_in.i_height / fmt_out.i_height; - fmt_out.i_width = p_vout->fmt_in.i_width / f; + fmt_out.i_width = (fmt_in.i_width * fmt_out.i_height) / fmt_in.i_height; } else if( fmt_out.i_height == 0 && fmt_out.i_width > 0 ) { - float f = (float)p_vout->fmt_in.i_width / fmt_out.i_width; - fmt_out.i_height = p_vout->fmt_in.i_height / f; + fmt_out.i_height = (fmt_in.i_height * fmt_out.i_width) / fmt_in.i_width; + } + else + { + fmt_out.i_width = fmt_in.i_width; + fmt_out.i_height = fmt_in.i_height; } /* Save the snapshot */ - fmt_in = p_vout->fmt_in; fmt_out.i_sar_num = fmt_out.i_sar_den = 1; i_ret = image_WriteUrl( p_image, p_pic, &fmt_in, &fmt_out, psz_filename ); if( i_ret != VLC_SUCCESS ) @@ -764,8 +788,8 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) p_subpic->i_channel = 0; p_subpic->i_start = mdate(); p_subpic->i_stop = mdate() + 4000000; - p_subpic->b_ephemer = VLC_TRUE; - p_subpic->b_fade = VLC_TRUE; + p_subpic->b_ephemer = true; + p_subpic->b_fade = true; p_subpic->i_original_picture_width = p_vout->render.i_width * 4; p_subpic->i_original_picture_height = p_vout->render.i_height * 4; @@ -789,7 +813,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic ) *****************************************************************************/ void vout_EnableFilter( vout_thread_t *p_vout, char *psz_name, - vlc_bool_t b_add, vlc_bool_t b_setconfig ) + bool b_add, bool b_setconfig ) { char *psz_parser; char *psz_string = config_GetPsz( p_vout, "vout-filter" ); @@ -860,7 +884,7 @@ int vout_vaControlDefault( vout_thread_t *p_vout, int i_query, va_list args ) break; case VOUT_SNAPSHOT: - p_vout->b_snapshot = VLC_TRUE; + p_vout->b_snapshot = true; return VLC_SUCCESS; break; @@ -1194,7 +1218,7 @@ static int FullscreenCallback( vlc_object_t *p_this, char const *psz_cmd, var_Set( p_playlist, "fullscreen", newval ); pl_Release( p_playlist ); - val.b_bool = VLC_TRUE; + val.b_bool = true; var_Set( p_vout, "intf-change", val ); return VLC_SUCCESS; }