]> git.sesse.net Git - vlc/blobdiff - src/video_output/vout_intf.c
Remove libvlc->psz_homedir and use config_GetHomeDir() instead
[vlc] / src / video_output / vout_intf.c
index a9bfa473083d27fba513ab71219cdf9376939186..9103b22a3c5335972670144efe16db4a2852f219 100644 (file)
  * Preamble
  *****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
 
 #include <stdio.h>
@@ -260,7 +264,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;
 
@@ -283,6 +287,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" );
@@ -343,6 +350,9 @@ void vout_IntfInit( vout_thread_t *p_vout )
         var_Change( p_vout, "crop", VLC_VAR_ADDCHOICE, &val, &text );
     }
 
+    /* update triggered every time the vout's crop parameters are changed */
+    var_Create( p_vout, "crop-update", VLC_VAR_VOID );
+
     /* Add custom crop ratios */
     psz_buf = config_GetPsz( p_vout, "custom-crop-ratios" );
     AddCustomRatios( p_vout, "crop", psz_buf );
@@ -352,7 +362,7 @@ void vout_IntfInit( vout_thread_t *p_vout )
     var_Get( p_vout, "crop", &old_val );
     if( old_val.psz_string && *old_val.psz_string )
         var_Change( p_vout, "crop", VLC_VAR_TRIGGER_CALLBACKS, 0, 0 );
-    if( old_val.psz_string ) free( old_val.psz_string );
+    free( old_val.psz_string );
 
     /* Monitor pixel aspect-ratio */
     var_Create( p_vout, "monitor-par", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
@@ -383,9 +393,9 @@ 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;
     }
-    if( val.psz_string ) free( val.psz_string );
+    free( val.psz_string );
 
     /* Aspect-ratio object var */
     var_Create( p_vout, "aspect-ratio", VLC_VAR_STRING | VLC_VAR_ISCOMMAND |
@@ -413,7 +423,7 @@ void vout_IntfInit( vout_thread_t *p_vout )
     var_Get( p_vout, "aspect-ratio", &old_val );
     if( (old_val.psz_string && *old_val.psz_string) || b_force_par )
         var_Change( p_vout, "aspect-ratio", VLC_VAR_TRIGGER_CALLBACKS, 0, 0 );
-    if( old_val.psz_string ) free( old_val.psz_string );
+    free( old_val.psz_string );
 
     /* Initialize the dimensions of the video window */
     InitWindowSize( p_vout, &p_vout->i_window_width,
@@ -453,7 +463,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 );
 }
 
 /*****************************************************************************
@@ -566,15 +576,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 */
 
@@ -612,8 +622,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
@@ -627,12 +636,13 @@ 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 )
@@ -643,7 +653,7 @@ int vout_Snapshot( vout_thread_t *p_vout, picture_t *p_pic )
     var_Get( p_vout, "snapshot-format", &format );
     if( !format.psz_string || !*format.psz_string )
     {
-        if( format.psz_string ) free( format.psz_string );
+        free( format.psz_string );
         format.psz_string = strdup( "png" );
     }
 
@@ -665,7 +675,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;
@@ -710,19 +720,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 )
@@ -757,8 +771,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;
 
@@ -782,7 +796,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" );
@@ -853,7 +867,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;
 
@@ -1097,6 +1111,8 @@ static int CropCallback( vlc_object_t *p_this, char const *psz_cmd,
              p_vout->fmt_in.i_visible_width,
              p_vout->fmt_in.i_visible_height );
 
+    var_SetVoid( p_vout, "crop-update" );
+
     return VLC_SUCCESS;
 }
 
@@ -1185,7 +1201,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;
 }
@@ -1193,6 +1209,8 @@ static int FullscreenCallback( vlc_object_t *p_this, char const *psz_cmd,
 static int SnapshotCallback( vlc_object_t *p_this, char const *psz_cmd,
                        vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
+    VLC_UNUSED(newval); VLC_UNUSED(p_data);
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
     vout_Control( p_vout, VOUT_SNAPSHOT );
     return VLC_SUCCESS;
@@ -1201,6 +1219,8 @@ static int SnapshotCallback( vlc_object_t *p_this, char const *psz_cmd,
 static int TitleShowCallback( vlc_object_t *p_this, char const *psz_cmd,
                        vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
+    VLC_UNUSED(p_data);
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
     p_vout->b_title_show = newval.b_bool;
     return VLC_SUCCESS;
@@ -1209,6 +1229,7 @@ static int TitleShowCallback( vlc_object_t *p_this, char const *psz_cmd,
 static int TitleTimeoutCallback( vlc_object_t *p_this, char const *psz_cmd,
                        vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
     p_vout->i_title_timeout = (mtime_t) newval.i_int;
     return VLC_SUCCESS;
@@ -1217,6 +1238,8 @@ static int TitleTimeoutCallback( vlc_object_t *p_this, char const *psz_cmd,
 static int TitlePositionCallback( vlc_object_t *p_this, char const *psz_cmd,
                        vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
+    VLC_UNUSED(p_data);
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
     p_vout->i_title_position = newval.i_int;
     return VLC_SUCCESS;