Esempio n. 1
0
static void DVRMuteCb(struct ev_loop *loop, struct ev_timer *w, int revents)
{
    msg_Warn( NULL, "no DVR output, resetting" );
    ev_timer_stop(loop, w);

    switch (i_print_type) {
    case PRINT_XML:
        fprintf(print_fh, "<EVENT type=\"reset\" cause=\"dvr\" />\n");
        break;
    case PRINT_TEXT:
        fprintf(print_fh, "reset cause: dvr\n");
        break;
    default:
        break;
    }
    if ( i_frequency )
        FrontendSet(false);
    en50221_Reset();
}
Esempio n. 2
0
/*****************************************************************************
 * dvb_Read
 *****************************************************************************/
block_t *dvb_Read( mtime_t i_poll_timeout )
{
    struct pollfd ufds[4];
    int i_ret, i_nb_fd = 2;
    block_t *p_blocks = NULL;

    memset( ufds, 0, sizeof(ufds) );
    ufds[0].fd = i_dvr;
    ufds[0].events = POLLIN;
    ufds[1].fd = i_frontend;
    ufds[1].events = POLLERR | POLLPRI;
    if ( i_comm_fd != -1 )
    {
        ufds[i_nb_fd].fd = i_comm_fd;
        ufds[i_nb_fd].events = POLLIN;
        i_nb_fd++;
    }
    if ( i_ca_handle && i_ca_type == CA_CI_LINK )
    {
        ufds[i_nb_fd].fd = i_ca_handle;
        ufds[i_nb_fd].events = POLLIN;
        i_nb_fd++;
    }

    i_ret = poll( ufds, i_nb_fd, (i_poll_timeout + 999) / 1000 );

    i_wallclock = mdate();

    if ( i_ret < 0 )
    {
        if( errno != EINTR )
            msg_Err( NULL, "poll error: %s", strerror(errno) );
        return NULL;
    }

    if ( ufds[1].revents )
        FrontendPoll();

    if ( ufds[0].revents )
    {
        p_blocks = DVRRead();
        i_wallclock = mdate();
    }

    if ( p_blocks != NULL )
        i_last_packet = i_wallclock;
    else if ( !i_frontend_timeout
              && i_wallclock > i_last_packet + DVR_READ_TIMEOUT )
    {
        msg_Warn( NULL, "no DVR output, resetting" );
        FrontendSet(false);
        en50221_Reset();
    }

    if ( i_ca_handle && i_ca_type == CA_CI_LINK )
    {
        if ( ufds[i_nb_fd - 1].revents )
        {
            en50221_Read();
            i_ca_next_event = i_wallclock + CA_POLL_PERIOD;
        }
        else if ( i_wallclock > i_ca_next_event )
        {
            en50221_Poll();
            i_ca_next_event = i_wallclock + CA_POLL_PERIOD;
        }
    }

    if ( i_frontend_timeout && i_wallclock > i_frontend_timeout )
    {
        if ( i_quit_timeout_duration )
        {
            msg_Err( NULL, "no lock" );
            switch (i_print_type) {
            case PRINT_XML:
                printf("</TS>\n");
                break;
            default:
                break;
            }
            exit(EXIT_STATUS_FRONTEND_TIMEOUT);
        }
        msg_Warn( NULL, "no lock, tuning again" );
        FrontendSet(false);
    }

    if ( i_comm_fd != -1 && ufds[2].revents )
        comm_Read();

    return p_blocks;
}