[vlc-commits] V4L2: fix poll() error handling

Rémi Denis-Courmont git at videolan.org
Sun Jan 23 17:02:35 CET 2011


vlc/vlc-1.1 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jan 23 17:44:51 2011 +0200| [66d0503e15c79b57dc042bffd339b5c8756ce176] | committer: Rémi Denis-Courmont

V4L2: fix poll() error handling

Do not read revents in case of error.
Do not busy loop if POLLERR or POLLHUP get set.
(cherry picked from commit f2757e09a8d867ac936372e80e22f760b8513d84)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=66d0503e15c79b57dc042bffd339b5c8756ce176
---

 modules/access/v4l2.c |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/modules/access/v4l2.c b/modules/access/v4l2.c
index 4259a61..c3cb584 100644
--- a/modules/access/v4l2.c
+++ b/modules/access/v4l2.c
@@ -1264,13 +1264,8 @@ static block_t *AccessRead( access_t * p_access )
     fd.revents = 0;
 
     /* Wait for data */
-    if( poll( &fd, 1, 500 ) ) /* Timeout after 0.5 seconds since I don't know if pf_demux can be blocking. */
-    {
-        if( fd.revents & (POLLIN|POLLPRI) )
-        {
-            return GrabVideo( VLC_OBJECT(p_access), p_sys );
-        }
-    }
+    if( poll( &fd, 1, 500 ) > 0 ) /* Timeout after 0.5 seconds since I don't know if pf_demux can be blocking. */
+        return GrabVideo( VLC_OBJECT(p_access), p_sys );
 
     return NULL;
 }
@@ -1328,16 +1323,21 @@ static int Demux( demux_t *p_demux )
     fd.revents = 0;
 
     /* Wait for data */
-    if( poll( &fd, 1, 500 ) ) /* Timeout after 0.5 seconds since I don't know if pf_demux can be blocking. */
-    {
-        if( fd.revents & (POLLIN|POLLPRI) )
+    /* Timeout after 0.5 seconds since I don't know if pf_demux can be blocking. */
+    while( poll( &fd, 1, 500 ) == -1 )
+        if( errno != EINTR )
         {
-            block_t *p_block = GrabVideo( VLC_OBJECT(p_demux), p_sys );
-            if( p_block )
-            {
-                es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts );
-                es_out_Send( p_demux->out, p_sys->p_es, p_block );
-            }
+            msg_Err( p_demux, "poll error: %m" );
+            return -1;
+        }
+
+    if( fd.revents )
+    {
+         block_t *p_block = GrabVideo( VLC_OBJECT(p_demux), p_sys );
+         if( p_block )
+         {
+             es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts );
+             es_out_Send( p_demux->out, p_sys->p_es, p_block );
         }
     }
 



More information about the vlc-commits mailing list