Commit 66d0503e authored by Rémi Denis-Courmont's avatar 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)
parent bbb16084
...@@ -1264,13 +1264,8 @@ static block_t *AccessRead( access_t * p_access ) ...@@ -1264,13 +1264,8 @@ static block_t *AccessRead( access_t * p_access )
fd.revents = 0; fd.revents = 0;
/* Wait for data */ /* 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( poll( &fd, 1, 500 ) > 0 ) /* 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 ); return GrabVideo( VLC_OBJECT(p_access), p_sys );
}
}
return NULL; return NULL;
} }
...@@ -1328,9 +1323,15 @@ static int Demux( demux_t *p_demux ) ...@@ -1328,9 +1323,15 @@ static int Demux( demux_t *p_demux )
fd.revents = 0; fd.revents = 0;
/* Wait for data */ /* Wait for data */
if( poll( &fd, 1, 500 ) ) /* Timeout after 0.5 seconds since I don't know if pf_demux can be blocking. */ /* 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 )
{ {
if( fd.revents & (POLLIN|POLLPRI) ) msg_Err( p_demux, "poll error: %m" );
return -1;
}
if( fd.revents )
{ {
block_t *p_block = GrabVideo( VLC_OBJECT(p_demux), p_sys ); block_t *p_block = GrabVideo( VLC_OBJECT(p_demux), p_sys );
if( p_block ) if( p_block )
...@@ -1339,7 +1340,6 @@ static int Demux( demux_t *p_demux ) ...@@ -1339,7 +1340,6 @@ static int Demux( demux_t *p_demux )
es_out_Send( p_demux->out, p_sys->p_es, p_block ); es_out_Send( p_demux->out, p_sys->p_es, p_block );
} }
} }
}
return 1; return 1;
} }
......
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