Commit dfe2b31c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Rewrite V4L2 controls to keep a list of them (fix #5269)

The V4L2 plug-in is a bit peculiar with dynamically generated object
variables. We need to keep track of which controls/variables we have,
so that we can remove the variables callbacks later. The only other
way to solve this bug, that I could think of, consisted of extending
the VLC variables subsystem (which would be worse in code freeze).

This rewrite also fixes a few other bugs:
 * Support menu with non-zero based minumum choice
 * Support menu with discontinuous choices range
 * Redumdant use the extended controls API as fallback
   (This only makes sense to set more than one control at a time,
    or to set 64-bits and string controls. VLC does none of that.)
 * Unused "controls-update" and "allcontrols" variables.
 * Skipping disabled, read-only and volatile controls.

Support for the legacy control enumeration API (pre-2.6.18 kernel) is
removed; and the code is now independent of the VLC object type (it
could easily be reused for say, a V4L2 video output).
parent fd1218a3
...@@ -73,6 +73,7 @@ void AccessClose( vlc_object_t *obj ) ...@@ -73,6 +73,7 @@ void AccessClose( vlc_object_t *obj )
access_t *access = (access_t *)obj; access_t *access = (access_t *)obj;
demux_sys_t *sys = (demux_sys_t *)access->p_sys; demux_sys_t *sys = (demux_sys_t *)access->p_sys;
ControlsDeinit( obj, sys->controls );
v4l2_close( sys->i_fd ); v4l2_close( sys->i_fd );
free( sys ); free( sys );
} }
......
This diff is collapsed.
...@@ -116,6 +116,7 @@ void DemuxClose( vlc_object_t *obj ) ...@@ -116,6 +116,7 @@ void DemuxClose( vlc_object_t *obj )
free( sys->p_buffers ); free( sys->p_buffers );
} }
ControlsDeinit( obj, sys->controls );
v4l2_close( fd ); v4l2_close( fd );
free( sys ); free( sys );
} }
......
...@@ -41,8 +41,6 @@ ...@@ -41,8 +41,6 @@
#define CFG_PREFIX "v4l2-" #define CFG_PREFIX "v4l2-"
int ControlList(vlc_object_t *, int fd, bool b_demux);
/* TODO: remove this, use callbacks */ /* TODO: remove this, use callbacks */
typedef enum { typedef enum {
IO_METHOD_READ=1, IO_METHOD_READ=1,
...@@ -50,7 +48,9 @@ typedef enum { ...@@ -50,7 +48,9 @@ typedef enum {
IO_METHOD_USERPTR, IO_METHOD_USERPTR,
} io_method; } io_method;
/* TODO: move this to .c */ typedef struct vlc_v4l2_ctrl vlc_v4l2_ctrl_t;
/* TODO: move this to access.c and demux.c (separately) */
struct demux_sys_t struct demux_sys_t
{ {
int i_fd; int i_fd;
...@@ -67,6 +67,8 @@ struct demux_sys_t ...@@ -67,6 +67,8 @@ struct demux_sys_t
es_out_id_t *p_es; es_out_id_t *p_es;
vlc_v4l2_ctrl_t *controls;
#ifdef HAVE_LIBV4L2 #ifdef HAVE_LIBV4L2
bool b_libv4l2; bool b_libv4l2;
#endif #endif
...@@ -93,3 +95,7 @@ void GetMaxDimensions(vlc_object_t *, int fd, uint32_t fmt, float fps_min, ...@@ -93,3 +95,7 @@ void GetMaxDimensions(vlc_object_t *, int fd, uint32_t fmt, float fps_min,
/* access.c */ /* access.c */
int AccessOpen(vlc_object_t *); int AccessOpen(vlc_object_t *);
void AccessClose(vlc_object_t *); void AccessClose(vlc_object_t *);
/* controls.c */
vlc_v4l2_ctrl_t *ControlsInit(vlc_object_t *, int fd);
void ControlsDeinit(vlc_object_t *, vlc_v4l2_ctrl_t *);
...@@ -1036,7 +1036,7 @@ static int InitVideo( vlc_object_t *p_obj, int i_fd, demux_sys_t *p_sys, ...@@ -1036,7 +1036,7 @@ static int InitVideo( vlc_object_t *p_obj, int i_fd, demux_sys_t *p_sys,
/* TODO: Move the resolution stuff up here */ /* TODO: Move the resolution stuff up here */
/* if MPEG encoder card, no need to do anything else after this */ /* if MPEG encoder card, no need to do anything else after this */
ControlList( p_obj, i_fd, b_demux ); p_sys->controls = ControlsInit( p_obj, i_fd );
/* Reset Cropping */ /* Reset Cropping */
memset( &cropcap, 0, sizeof(cropcap) ); memset( &cropcap, 0, sizeof(cropcap) );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment