- p_block = block_New( p_access, SATELLITE_READ_ONCE * TS_PACKET_SIZE );
- if( ( p_block->i_buffer = read( p_sys->i_handle, p_block->p_buffer, SATELLITE_READ_ONCE * TS_PACKET_SIZE ) ) <= 0 )
- {
- msg_Err( p_access, "read failed (%s)", strerror(errno) );
- block_Release( p_block );
- return NULL;
+ msg_Err( p_access, "poll error: %s", strerror(errno) );
+ return NULL;
+ }
+
+ if ( p_sys->i_ca_handle && mdate() > p_sys->i_ca_next_event )
+ {
+ E_(CAMPoll)( p_access );
+ p_sys->i_ca_next_event = mdate() + p_sys->i_ca_timeout;
+ }
+
+ if ( ufds[1].revents )
+ {
+ E_(FrontendPoll)( p_access );
+ }
+
+#ifdef ENABLE_HTTPD
+ if ( p_sys->i_httpd_timeout && mdate() > p_sys->i_httpd_timeout )
+ {
+ vlc_mutex_lock( &p_sys->httpd_mutex );
+ if ( p_sys->b_request_frontend_info )
+ {
+ msg_Warn( p_access, "frontend timeout for HTTP interface" );
+ p_sys->b_request_frontend_info = VLC_FALSE;
+ p_sys->psz_frontend_info = strdup( "Timeout getting info\n" );
+ }
+ if ( p_sys->b_request_mmi_info )
+ {
+ msg_Warn( p_access, "MMI timeout for HTTP interface" );
+ p_sys->b_request_mmi_info = VLC_FALSE;
+ p_sys->psz_mmi_info = strdup( "Timeout getting info\n" );
+ }
+ vlc_cond_signal( &p_sys->httpd_cond );
+ vlc_mutex_unlock( &p_sys->httpd_mutex );
+ }
+
+ if ( p_sys->b_request_frontend_info )
+ {
+ E_(FrontendStatus)( p_access );
+ }
+
+ if ( p_sys->b_request_mmi_info )
+ {
+ E_(CAMStatus)( p_access );
+ }
+#endif
+
+ if ( p_sys->i_frontend_timeout && mdate() > p_sys->i_frontend_timeout )
+ {
+ msg_Warn( p_access, "no lock, tuning again" );
+ E_(FrontendSet)( p_access );
+ }
+
+ if ( ufds[0].revents )
+ {
+ p_block = block_New( p_access,
+ p_sys->i_read_once * TS_PACKET_SIZE );
+ if( ( p_block->i_buffer = read( p_sys->i_handle, p_block->p_buffer,
+ p_sys->i_read_once * TS_PACKET_SIZE ) ) <= 0 )
+ {
+ msg_Warn( p_access, "read failed (%s)", strerror(errno) );
+ block_Release( p_block );
+ continue;
+ }
+ break;
+ }