]> git.sesse.net Git - vlc/blobdiff - modules/access/v4l2.c
Merge branch 1.0-bugfix into master
[vlc] / modules / access / v4l2.c
index c6688d6b1114bd4fbc5bdfcf084cd3097b684708..705eb66c41e53993a26f7e5325e0a92ee9aa6f95 100644 (file)
@@ -393,7 +393,7 @@ static int AccessControlResetCallback( vlc_object_t *p_this,
 static const struct
 {
     unsigned int i_v4l2;
-    int i_fourcc;
+    vlc_fourcc_t i_fourcc;
     int i_rmask;
     int i_gmask;
     int i_bmask;
@@ -1945,22 +1945,18 @@ static int OpenVideoDev( vlc_object_t *p_obj, demux_sys_t *p_sys, bool b_demux )
 
     /* Test and set Chroma */
     fmt.fmt.pix.pixelformat = 0;
-    if( p_sys->psz_requested_chroma && strlen( p_sys->psz_requested_chroma ) > 0 )
+    if( p_sys->psz_requested_chroma && *p_sys->psz_requested_chroma )
     {
         /* User specified chroma */
-        if( strlen( p_sys->psz_requested_chroma ) >= 4 )
+        const vlc_fourcc_t i_requested_fourcc =
+            vlc_fourcc_GetCodecFromString( VIDEO_ES, p_sys->psz_requested_chroma );
+
+        for( int i = 0; v4l2chroma_to_fourcc[i].i_v4l2 != 0; i++ )
         {
-            int i_requested_fourcc = vlc_fourcc_GetCodec( VIDEO_ES,
-                                                          VLC_FOURCC(
-                p_sys->psz_requested_chroma[0], p_sys->psz_requested_chroma[1],
-                p_sys->psz_requested_chroma[2], p_sys->psz_requested_chroma[3] ) );
-            for( int i = 0; v4l2chroma_to_fourcc[i].i_v4l2 != 0; i++ )
+            if( v4l2chroma_to_fourcc[i].i_fourcc == i_requested_fourcc )
             {
-                if( v4l2chroma_to_fourcc[i].i_fourcc == i_requested_fourcc )
-                {
-                    fmt.fmt.pix.pixelformat = v4l2chroma_to_fourcc[i].i_v4l2;
-                    break;
-                }
+                fmt.fmt.pix.pixelformat = v4l2chroma_to_fourcc[i].i_v4l2;
+                break;
             }
         }
         /* Try and set user chroma */
@@ -2913,6 +2909,7 @@ static void SetAvailControlsByString( vlc_object_t *p_obj, demux_sys_t *p_sys,
                 Control( p_obj, p_sys, i_fd, psz_name, i_cid,
                          strtol( ++psz_assign, &psz_parser, 0) );
             }
+            free( name.psz_string );
         }
 
         if( psz_parser < psz_assign )
@@ -2923,6 +2920,7 @@ static void SetAvailControlsByString( vlc_object_t *p_obj, demux_sys_t *p_sys,
             psz_parser = ( *psz_delim ) ? ( psz_delim + 1 ) : psz_delim;
         }
     }
+    var_FreeList( &val, &text );
 }
 
 /*****************************************************************************
@@ -2958,7 +2956,8 @@ static int ControlReset( vlc_object_t *p_obj, demux_sys_t *p_sys, int i_fd )
                     if( controls[i].i_cid == queryctrl.id ) break;
                 name2var( queryctrl.name );
                 Control( p_obj, p_sys, i_fd,
-                         controls[i].psz_name ? : (const char *)queryctrl.name,
+                         controls[i].psz_name ? controls[i].psz_name
+                          : (const char *)queryctrl.name,
                          queryctrl.id, queryctrl.default_value );
             }
             queryctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL;
@@ -2988,7 +2987,8 @@ static int ControlReset( vlc_object_t *p_obj, demux_sys_t *p_sys, int i_fd )
                         if( controls[i].i_cid == queryctrl.id ) break;
                     name2var( queryctrl.name );
                     Control( p_obj, p_sys, i_fd,
-                             controls[i].psz_name ? : (const char *)queryctrl.name,
+                             controls[i].psz_name ? controls[i].psz_name
+                              : (const char *)queryctrl.name,
                              queryctrl.id, queryctrl.default_value );
                 }
             }