]> git.sesse.net Git - vlc/blobdiff - modules/access/v4l.c
Replace strerror() with %m (or Linux DVB: strerror_r) - refs #1297
[vlc] / modules / access / v4l.c
index 6938f6a595b4606d40a11a89e797f3df19ce8b62..f9e534cf70c3391c966d9d1f152b407db1a25969 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#define _GNU_SOURCE
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
 
 #include <vlc/vlc.h>
 #include <vlc_input.h>
@@ -142,7 +138,7 @@ static void Close( vlc_object_t * );
 
 static int i_norm_list[] =
     { VIDEO_MODE_AUTO, VIDEO_MODE_SECAM, VIDEO_MODE_PAL, VIDEO_MODE_NTSC };
-static char *psz_norm_list_text[] =
+static const char *psz_norm_list_text[] =
     { N_("Automatic"), N_("SECAM"), N_("PAL"),  N_("NTSC") };
 
 vlc_module_begin();
@@ -237,7 +233,9 @@ static struct
     { VIDEO_PALETTE_RGB555, VLC_FOURCC( 'R', 'V', '1', '5' ) },
     { VIDEO_PALETTE_RGB24, VLC_FOURCC( 'R', 'V', '2', '4' ) },
     { VIDEO_PALETTE_RGB32, VLC_FOURCC( 'R', 'V', '3', '2' ) },
-    { VIDEO_PALETTE_YUV422, VLC_FOURCC( 'I', '4', '2', '2' ) },
+    { VIDEO_PALETTE_YUV422, VLC_FOURCC( 'Y', 'U', 'Y', '2' ) },
+    { VIDEO_PALETTE_YUV422, VLC_FOURCC( 'Y', 'U', 'Y', 'V' ) },
+    { VIDEO_PALETTE_YUYV, VLC_FOURCC( 'Y', 'U', 'Y', '2' ) },
     { VIDEO_PALETTE_YUYV, VLC_FOURCC( 'Y', 'U', 'Y', 'V' ) },
     { VIDEO_PALETTE_UYVY, VLC_FOURCC( 'U', 'Y', 'V', 'Y' ) },
     { VIDEO_PALETTE_YUV420, VLC_FOURCC( 'I', '4', '2', 'N' ) },
@@ -767,7 +765,7 @@ static void ParseMRL( demux_t *p_demux )
             }
             else if( !strncmp( psz_parser, "hue=", strlen( "hue=" ) ) )
             {
-                p_sys->i_hue = strtol( psz_parser + strlen( "hue=" ), 
+                p_sys->i_hue = strtol( psz_parser + strlen( "hue=" ),
                                        &psz_parser, 0 );
             }
             else if( !strncmp( psz_parser, "contrast=", strlen( "contrast=" ) ) )
@@ -880,13 +878,13 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device )
 
     if( ( i_fd = open( psz_device, O_RDWR ) ) < 0 )
     {
-        msg_Err( p_demux, "cannot open device (%s)", strerror( errno ) );
+        msg_Err( p_demux, "cannot open device (%m)" );
         goto vdev_failed;
     }
 
     if( ioctl( i_fd, VIDIOCGCAP, &p_sys->vid_cap ) < 0 )
     {
-        msg_Err( p_demux, "cannot get capabilities (%s)", strerror( errno ) );
+        msg_Err( p_demux, "cannot get capabilities (%m)" );
         goto vdev_failed;
     }
 
@@ -931,8 +929,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device )
     vid_channel.channel = p_sys->i_channel;
     if( ioctl( i_fd, VIDIOCGCHAN, &vid_channel ) < 0 )
     {
-        msg_Err( p_demux, "cannot get channel infos (%s)",
-                          strerror( errno ) );
+        msg_Err( p_demux, "cannot get channel infos (%m)" );
         goto vdev_failed;
     }
     msg_Dbg( p_demux,
@@ -949,7 +946,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device )
     vid_channel.norm = p_sys->i_norm;
     if( ioctl( i_fd, VIDIOCSCHAN, &vid_channel ) < 0 )
     {
-        msg_Err( p_demux, "cannot set channel (%s)", strerror( errno ) );
+        msg_Err( p_demux, "cannot set channel (%m)" );
         goto vdev_failed;
     }
 
@@ -964,7 +961,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device )
             vid_tuner.tuner = p_sys->i_tuner;
             if( ioctl( i_fd, VIDIOCGTUNER, &vid_tuner ) < 0 )
             {
-                msg_Err( p_demux, "cannot get tuner (%s)", strerror( errno ) );
+                msg_Err( p_demux, "cannot get tuner (%m)" );
                 goto vdev_failed;
             }
             msg_Dbg( p_demux, "tuner %s low=%d high=%d, flags=0x%x "
@@ -979,7 +976,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device )
             //vid_tuner.mode = p_sys->i_norm;
             if( ioctl( i_fd, VIDIOCSTUNER, &vid_tuner ) < 0 )
             {
-                msg_Err( p_demux, "cannot set tuner (%s)", strerror( errno ) );
+                msg_Err( p_demux, "cannot set tuner (%m)" );
                 goto vdev_failed;
             }
         }
@@ -995,8 +992,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device )
             int driver_frequency = p_sys->i_frequency * 16 /1000;
             if( ioctl( i_fd, VIDIOCSFREQ, &driver_frequency ) < 0 )
             {
-                msg_Err( p_demux, "cannot set frequency (%s)",
-                                  strerror( errno ) );
+                msg_Err( p_demux, "cannot set frequency (%m)" );
                 goto vdev_failed;
             }
             msg_Dbg( p_demux, "frequency %d (%d)", p_sys->i_frequency,
@@ -1015,7 +1011,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device )
             vid_audio.audio = p_sys->i_audio;
             if( ioctl( i_fd, VIDIOCGAUDIO, &vid_audio ) < 0 )
             {
-                msg_Err( p_demux, "cannot get audio (%s)", strerror( errno ) );
+                msg_Err( p_demux, "cannot get audio (%m)" );
                 goto vdev_failed;
             }
 
@@ -1024,7 +1020,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device )
 
             if( ioctl( i_fd, VIDIOCSAUDIO, &vid_audio ) < 0 )
             {
-                msg_Err( p_demux, "cannot set audio (%s)", strerror( errno ) );
+                msg_Err( p_demux, "cannot set audio (%m)" );
                 goto vdev_failed;
             }
         }
@@ -1040,8 +1036,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device )
 
         if( ioctl( i_fd, MJPIOC_G_PARAMS, &mjpeg ) < 0 )
         {
-            msg_Err( p_demux, "cannot get mjpeg params (%s)",
-                              strerror( errno ) );
+            msg_Err( p_demux, "cannot get mjpeg params (%m)" );
             goto vdev_failed;
         }
         mjpeg.input = p_sys->i_channel;
@@ -1091,8 +1086,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device )
 
         if( ioctl( i_fd, MJPIOC_S_PARAMS, &mjpeg ) < 0 )
         {
-            msg_Err( p_demux, "cannot set mjpeg params (%s)",
-                              strerror( errno ) );
+            msg_Err( p_demux, "cannot set mjpeg params (%m)" );
             goto vdev_failed;
         }
 
@@ -1108,7 +1102,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device )
 
         if( ioctl( i_fd, VIDIOCGWIN, &vid_win ) < 0 )
         {
-            msg_Err( p_demux, "cannot get win (%s)", strerror( errno ) );
+            msg_Err( p_demux, "cannot get win (%m)" );
             goto vdev_failed;
         }
         p_sys->i_width  = vid_win.width;
@@ -1173,12 +1167,12 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device )
             char *psz;
             int i;
 
-            vid_picture.palette = 0;
             p_sys->i_fourcc = 0;
 
             psz = var_CreateGetString( p_demux, "v4l-chroma" );
             if( strlen( psz ) >= 4 )
             {
+                vid_picture.palette = 0;
                 int i_chroma = VLC_FOURCC( psz[0], psz[1], psz[2], psz[3] );
 
                 /* Find out v4l chroma code */
@@ -1338,7 +1332,7 @@ static int OpenAudioDev( demux_t *p_demux, char *psz_device )
 
     if( (i_fd = open( psz_device, O_RDONLY | O_NONBLOCK )) < 0 )
     {
-        msg_Err( p_demux, "cannot open audio device (%s)", strerror( errno ) );
+        msg_Err( p_demux, "cannot open audio device (%m)" );
         goto adev_fail;
     }
 
@@ -1347,23 +1341,21 @@ static int OpenAudioDev( demux_t *p_demux, char *psz_device )
         || i_format != AFMT_S16_LE )
     {
         msg_Err( p_demux, "cannot set audio format (16b little endian) "
-                 "(%s)", strerror( errno ) );
+                 "(%m)" );
         goto adev_fail;
     }
 
     if( ioctl( i_fd, SNDCTL_DSP_STEREO,
                &p_sys->b_stereo ) < 0 )
     {
-        msg_Err( p_demux, "cannot set audio channels count (%s)",
-                 strerror( errno ) );
+        msg_Err( p_demux, "cannot set audio channels count (%m)" );
         goto adev_fail;
     }
 
     if( ioctl( i_fd, SNDCTL_DSP_SPEED,
                &p_sys->i_sample_rate ) < 0 )
     {
-        msg_Err( p_demux, "cannot set audio sample rate (%s)",
-                 strerror( errno ) );
+        msg_Err( p_demux, "cannot set audio sample rate (%m)" );
         goto adev_fail;
     }
 
@@ -1452,7 +1444,7 @@ static uint8_t *GrabCapture( demux_t *p_demux )
 
     while( ioctl(p_sys->fd_video, VIDIOCSYNC, &p_sys->i_frame_pos) < 0 )
     {
-        if( errno != EAGAIN && errno != EINTR )    
+        if( errno != EAGAIN && errno != EINTR )
         {
             msg_Err( p_demux, "failed syncing new frame" );
             return NULL;
@@ -1490,7 +1482,7 @@ static uint8_t *GrabMJPEG( demux_t *p_demux )
     /* sync on the next frame */
     while( ioctl( p_sys->fd_video, MJPIOC_SYNC, &sync ) < 0 )
     {
-        if( errno != EAGAIN && errno != EINTR )    
+        if( errno != EAGAIN && errno != EINTR )
         {
             msg_Err( p_demux, "failed syncing new frame" );
             return NULL;