Commit dc0a3896 authored by Laurent Aimar's avatar Laurent Aimar

* v4l: patch from Carsten Gottbeh�t (gottbehuet at active-elements dot de)

 -> Untested.

 Original message:
    Hi there,

    I have done another small modification. If you remove a hot-pluggable video
    device, like an usb web cam, during capturing, vlc floods the driver with
    ioctls. This leads to Kernel Ooops in some drivers.

    The modified v4l.c module does the following now:
    "GrabVideo" returns "VLC_ETIMEOUT" if the question "Did we wait long enough"
    can be answered with yes. If there is a real error in "GrabCapture" or
    "GrabMJPEG", the code "VLC_EGENERIC" is returned. So the calling function
    can distinguish between these two situations. "VLC_EGENERIC" was always
    returned before.
    The function "Read" uses this information to leave the while-loop in case of
    an error, and it returns a "-1" to the calling function. "Read" calls
    "msleep", as it was before, in case of a VLC_ETIMEOUT.

    The brightness-control stuff described below is still in the code. Please
    feel free to use, modify or ignore this file. A short feedback would be
    nice.

    Bye,
parent cd05b67f
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* v4l.c : Video4Linux input module for vlc * v4l.c : Video4Linux input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2004 VideoLAN * Copyright (C) 2002-2004 VideoLAN
* $Id: v4l.c,v 1.40 2004/02/04 20:13:55 fenrir Exp $ * $Id: v4l.c,v 1.41 2004/02/12 17:52:48 fenrir Exp $
* *
* Author: Laurent Aimar <fenrir@via.ecp.fr> * Author: Laurent Aimar <fenrir@via.ecp.fr>
* Paul Forgey <paulf at aphrodite dot com> * Paul Forgey <paulf at aphrodite dot com>
...@@ -1416,10 +1416,10 @@ static int GrabVideo( input_thread_t * p_input, ...@@ -1416,10 +1416,10 @@ static int GrabVideo( input_thread_t * p_input,
{ {
mtime_t i_dur = (mtime_t)((double)1000000 / (double)p_sys->f_fps); mtime_t i_dur = (mtime_t)((double)1000000 / (double)p_sys->f_fps);
/* Dif we wait long enougth ? */ /* Did we wait long enougth ? */
if( p_sys->i_video_pts + i_dur > mdate() ) if( p_sys->i_video_pts + i_dur > mdate() )
{ {
return VLC_EGENERIC; return VLC_ETIMEOUT;
} }
} }
...@@ -1510,17 +1510,29 @@ static int Read( input_thread_t * p_input, byte_t * p_buffer, size_t i_len ) ...@@ -1510,17 +1510,29 @@ static int Read( input_thread_t * p_input, byte_t * p_buffer, size_t i_len )
GrabAudio( p_input, &p_sys->p_data, GrabAudio( p_input, &p_sys->p_data,
&p_sys->i_data_size, &i_pts ) != VLC_SUCCESS ) &p_sys->i_data_size, &i_pts ) != VLC_SUCCESS )
{ {
int i_ret = VLC_ETIMEOUT;
/* Try grabbing video frame */ /* Try grabbing video frame */
i_stream = 0; i_stream = 0;
if( p_sys->fd_video < 0 || if( p_sys->fd_video > 0 )
GrabVideo( p_input, &p_sys->p_data, {
&p_sys->i_data_size, &i_pts ) != VLC_SUCCESS ) i_ret = GrabVideo( p_input, &p_sys->p_data,
&p_sys->i_data_size, &i_pts );
}
/* No video or timeout */
if( i_ret == VLC_ETIMEOUT )
{ {
/* Sleep so we do not consume all the cpu, 10ms seems /* Sleep so we do not consume all the cpu, 10ms seems
* like a good value (100fps) */ * like a good value (100fps) */
msleep( 10000 ); msleep( 10000 );
continue; continue;
} }
else if( i_ret != VLC_SUCCESS )
{
msg_Err( p_input, "Error during capture!" );
return -1;
}
} }
/* create pseudo header */ /* create pseudo header */
......
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