]> git.sesse.net Git - vlc/blobdiff - modules/video_output/fb.c
Revert "Prefer setenv to putenv (evenmore with local variables)."
[vlc] / modules / video_output / fb.c
index 2667fd129d0fa3b5f96f20f69ce815117a92dfe9..95ea2fe1a317b5df5284080e885488a52eb07b65 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <errno.h>                                                 /* ENOMEM */
 #include <signal.h>                                      /* SIGUSR1, SIGUSR2 */
 #include <fcntl.h>                                                 /* open() */
 #include <linux/vt.h>                                                /* VT_* */
 #include <linux/kd.h>                                                 /* KD* */
 
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_vout.h>
 
 /*****************************************************************************
@@ -106,17 +108,17 @@ vlc_module_begin();
     set_category( CAT_VIDEO );
     set_subcategory( SUBCAT_VIDEO_VOUT );
     add_file( FB_DEV_VAR, "/dev/fb0", NULL, DEVICE_TEXT, DEVICE_LONGTEXT,
-              VLC_FALSE );
-    add_bool( "fb-tty", 1, NULL, TTY_TEXT, TTY_LONGTEXT, VLC_TRUE );
+              false );
+    add_bool( "fb-tty", 1, NULL, TTY_TEXT, TTY_LONGTEXT, true );
     add_string( "fb-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT,
-                VLC_TRUE );
+                true );
     add_string( "fb-aspect-ratio", NULL, NULL, ASPECT_RATIO_TEXT,
-                ASPECT_RATIO_LONGTEXT, VLC_TRUE );
+                ASPECT_RATIO_LONGTEXT, true );
     add_integer( "fb-mode", 4, NULL, FB_MODE_TEXT, FB_MODE_LONGTEXT,
-                 VLC_TRUE );
-    add_bool( "fb-hw-accel", VLC_TRUE, NULL, HW_ACCEL_TEXT, HW_ACCEL_LONGTEXT,
-              VLC_TRUE );
-    set_description( _("GNU/Linux console framebuffer video output") );
+                 true );
+    add_bool( "fb-hw-accel", true, NULL, HW_ACCEL_TEXT, HW_ACCEL_LONGTEXT,
+              true );
+    set_description( N_("GNU/Linux console framebuffer video output") );
     set_capability( "video output", 30 );
     set_callbacks( Create, Destroy );
 vlc_module_end();
@@ -131,7 +133,7 @@ struct vout_sys_t
 {
     /* System information */
     int                 i_tty;                          /* tty device handle */
-    vlc_bool_t          b_tty;
+    bool                b_tty;
     struct termios      old_termios;
 
     /* Original configuration information */
@@ -143,27 +145,27 @@ struct vout_sys_t
     int                         i_fd;                       /* device handle */
     struct fb_var_screeninfo    old_info;       /* original mode information */
     struct fb_var_screeninfo    var_info;        /* current mode information */
-    vlc_bool_t                  b_pan;     /* does device supports panning ? */
+    bool                        b_pan;     /* does device supports panning ? */
     struct fb_cmap              fb_cmap;                /* original colormap */
     uint16_t                    *p_palette;              /* original palette */
-    vlc_bool_t                  b_hw_accel;          /* has hardware support */
+    bool                        b_hw_accel;          /* has hardware support */
 
     /* Video information */
     uint32_t i_width;
     uint32_t i_height;
-    int i_aspect;
-    int i_bytes_per_pixel;
-    vlc_bool_t   b_auto;       /* Automatically adjust video size to fb size */
+    int      i_aspect;
+    int      i_bytes_per_pixel;
+    bool     b_auto;       /* Automatically adjust video size to fb size */
     vlc_fourcc_t i_chroma;
 
     /* Video memory */
-    byte_t *    p_video;                                      /* base adress */
+    uint8_t    *p_video;                                      /* base adress */
     size_t      i_page_size;                                    /* page size */
 };
 
 struct picture_sys_t
 {
-    byte_t *    p_data;                                       /* base adress */
+    uint8_t *    p_data;                                      /* base adress */
 };
 
 /*****************************************************************************
@@ -185,10 +187,7 @@ static int Create( vlc_object_t *p_this )
     /* Allocate instance and initialize some members */
     p_vout->p_sys = p_sys = malloc( sizeof( vout_sys_t ) );
     if( p_vout->p_sys == NULL )
-    {
-        msg_Err( p_vout, "out of memory" );
         return VLC_ENOMEM;
-    };
     memset( p_sys, 0, sizeof(vout_sys_t) );
 
     p_vout->pf_init = Init;
@@ -199,7 +198,7 @@ static int Create( vlc_object_t *p_this )
     p_vout->pf_control = Control;
 
     /* Does the framebuffer uses hw acceleration? */
-    p_sys->b_hw_accel = p_sys->b_tty = var_CreateGetBool( p_vout, "fb-hw-accel" );
+    p_sys->b_hw_accel = var_CreateGetBool( p_vout, "fb-hw-accel" );
 
     /* Set tty and fb devices */
     p_sys->i_tty = 0; /* 0 == /dev/tty0 == current console */
@@ -259,7 +258,7 @@ static int Create( vlc_object_t *p_this )
         psz_aspect = NULL;
     }
 
-    p_sys->b_auto = VLC_FALSE;
+    p_sys->b_auto = false;
     i_mode = var_CreateGetInteger( p_vout, "fb-mode" );
     switch( i_mode )
     {
@@ -281,7 +280,7 @@ static int Create( vlc_object_t *p_this )
             break;
         case 4:
         default:
-            p_sys->b_auto = VLC_TRUE;
+            p_sys->b_auto = true;
             break;
      }
 
@@ -483,6 +482,11 @@ static int Init( vout_thread_t *p_vout )
 
     I_OUTPUTPICTURES = 0;
 
+    p_vout->output.i_width  = p_vout->render.i_width;
+    p_vout->output.i_height = p_vout->render.i_height;
+    p_vout->output.i_aspect = p_vout->render.i_aspect;
+
+    p_vout->fmt_out = p_vout->fmt_in;
     if( p_sys->i_chroma == 0 )
     {
         /* Initialize the output structure: RGB with square pixels, whatever
@@ -521,13 +525,12 @@ static int Init( vout_thread_t *p_vout )
     }
     p_vout->fmt_out.i_chroma = p_vout->output.i_chroma;
 
-    if( !p_sys->b_auto )
-    {
-        p_vout->render.i_width = p_sys->i_width;
-        p_vout->render.i_height = p_sys->i_height;
-    }
-    p_vout->output.i_width  = p_sys->i_width;
-    p_vout->output.i_height = p_sys->i_height;
+    p_vout->output.i_width =
+    p_vout->fmt_out.i_width =
+    p_vout->fmt_out.i_visible_width = p_sys->i_width;
+    p_vout->output.i_height =
+    p_vout->fmt_out.i_height =
+    p_vout->fmt_out.i_visible_height = p_sys->i_height;
 
     /* Assume we have square pixels */
     if( p_sys->i_aspect < 0 )
@@ -539,6 +542,7 @@ static int Init( vout_thread_t *p_vout )
 
     p_vout->fmt_out.i_sar_num = p_vout->fmt_out.i_sar_den = 1;
     p_vout->fmt_out.i_aspect  = p_vout->render.i_aspect = p_vout->output.i_aspect;
+    p_vout->fmt_out.i_x_offset= p_vout->fmt_out.i_y_offset = 0;
 
     /* Clear the screen */
     memset( p_sys->p_video, 0, p_sys->i_page_size );
@@ -745,8 +749,8 @@ static int panned=0;
 
     if( !p_vout->p_sys->b_hw_accel )
     {
-        p_vout->p_libvlc->pf_memcpy( p_vout->p_sys->p_video, p_pic->p->p_pixels,
-                                     p_vout->p_sys->i_page_size );
+        vlc_memcpy( p_vout->p_sys->p_video, p_pic->p->p_pixels,
+                    p_vout->p_sys->i_page_size );
     }
 }
 
@@ -840,7 +844,7 @@ static int OpenDisplay( vout_thread_t *p_vout )
     if( (p_sys->i_height != p_sys->var_info.yres) ||
         (p_sys->i_width != p_sys->var_info.xres) )
     {
-        p_sys->b_auto = VLC_TRUE;
+        p_sys->b_auto = true;
         msg_Warn( p_vout,
                   "using framebuffer native resolution instead of requested (%ix%i)",
                   p_sys->i_width, p_sys->i_height );
@@ -867,8 +871,6 @@ static int OpenDisplay( vout_thread_t *p_vout )
         p_sys->p_palette = malloc( 8 * 256 * sizeof( uint16_t ) );
         if( !p_sys->p_palette )
         {
-            msg_Err( p_vout, "out of memory" );
-
             /* Restore fb config */
             ioctl( p_sys->i_fd, FBIOPUT_VSCREENINFO, &p_sys->old_info );