Changeset 392a5a40770759eb8b350a838e8766adace52316

Show
Ignore:
Timestamp:
27/04/04 11:28:25 (4 years ago)
Author:
Sam Hocevar <sam@videolan.org>
git-committer:
Sam Hocevar <sam@videolan.org> 1083058105 +0000
git-parent:

[5ba84a43aab674f0946af0a1c06190677a6a8c73]

git-author:
Sam Hocevar <sam@videolan.org> 1083058105 +0000
Message:
  • modules/access/v4l/v4l.c:
    + Fixed possible deadlocks.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/access/v4l/v4l.c

    r753e14b r392a5a4  
    12931293 
    12941294    p_sys->vid_mmap.frame = (p_sys->i_frame_pos + 1) % p_sys->vid_mbuf.frames; 
    1295     for( ;; ) 
    1296     { 
    1297         if( ioctl( p_sys->fd_video, VIDIOCMCAPTURE, &p_sys->vid_mmap ) >= 0 ) 
    1298         { 
    1299             break; 
    1300         } 
    1301  
     1295 
     1296    while( ioctl( p_sys->fd_video, VIDIOCMCAPTURE, &p_sys->vid_mmap ) < 0 ) 
     1297    { 
    13021298        if( errno != EAGAIN ) 
    13031299        { 
    1304             msg_Err( p_input, "failed while grabbing new frame" ); 
    1305             return( NULL ); 
    1306         } 
    1307         msg_Dbg( p_input, "another try ?" ); 
    1308     } 
    1309  
    1310     while( ioctl(p_sys->fd_video, VIDIOCSYNC, &p_sys->i_frame_pos) < 0 && 
    1311            ( errno == EAGAIN || errno == EINTR ) ); 
     1300            msg_Err( p_input, "failed capturing new frame" ); 
     1301            return NULL; 
     1302        } 
     1303 
     1304        if( p_input->b_die ) 
     1305        { 
     1306            return NULL; 
     1307        } 
     1308 
     1309        msg_Dbg( p_input, "grab failed, trying again" ); 
     1310    } 
     1311 
     1312    while( ioctl(p_sys->fd_video, VIDIOCSYNC, &p_sys->i_frame_pos) < 0 ) 
     1313    { 
     1314        if( errno != EAGAIN && errno != EINTR )     
     1315        { 
     1316            msg_Err( p_input, "failed syncing new frame" ); 
     1317            return NULL; 
     1318        } 
     1319    } 
    13121320 
    13131321    p_sys->i_frame_pos = p_sys->vid_mmap.frame; 
     
    13271335    /* re-queue the last frame we sync'd */ 
    13281336    if( p_sys->i_frame_pos != -1 ) 
    1329         while( ioctl( p_sys->fd_video, MJPIOC_QBUF_CAPT, &p_sys->i_frame_pos ) < 0 && 
    1330                 ( errno == EAGAIN || errno == EINTR ) ); 
     1337    { 
     1338        while( ioctl( p_sys->fd_video, MJPIOC_QBUF_CAPT, 
     1339                                       &p_sys->i_frame_pos ) < 0 ) 
     1340        { 
     1341            if( errno != EAGAIN && errno != EINTR )     
     1342            { 
     1343                msg_Err( p_input, "failed capturing new frame" ); 
     1344                return NULL; 
     1345            } 
     1346        } 
     1347    } 
    13311348 
    13321349    /* sync on the next frame */ 
    1333     while( ioctl( p_sys->fd_video, MJPIOC_SYNC, &sync ) < 0 && 
    1334             ( errno == EAGAIN || errno == EINTR ) ); 
     1350    while( ioctl( p_sys->fd_video, MJPIOC_SYNC, &sync ) < 0 ) 
     1351    { 
     1352        if( errno != EAGAIN && errno != EINTR )     
     1353        { 
     1354            msg_Err( p_input, "failed syncing new frame" ); 
     1355            return NULL; 
     1356        } 
     1357    } 
    13351358 
    13361359    p_sys->i_frame_pos = sync.frame;