--- main.orig/libmpdemux/dvbin.c 2004-01-29 10:36:33.000000000 +0000 +++ main/libmpdemux/dvbin.c 2004-02-25 00:19:20.000000000 +0000 @@ -195,6 +195,7 @@ ptr->freq *= 1000UL; ptr->srate *= 1000UL; ptr->tone = -1; + ptr->inv = INVERSION_AUTO; mp_msg(MSGT_DEMUX, MSGL_V, "NUM: %d, NUM_FIELDS: %d, NAME: %s, FREQ: %d, SRATE: %d, POL: %c, DISEQC: %d, TONE: %d, VPID: %d, APID1: %d, APID2: %d, TPID: %d, PROGID: %d\n", list->NUM_CHANNELS, fields, ptr->name, ptr->freq, ptr->srate, ptr->pol, ptr->diseqc, ptr->tone, ptr->vpid, ptr->apid1, ptr->apid2, ptr->tpid, ptr->progid); --- main.orig/libmpdemux/dvb_tune.c 2004-01-29 10:36:33.000000000 +0000 +++ main/libmpdemux/dvb_tune.c 2004-02-25 21:17:15.000000000 +0000 @@ -95,7 +95,7 @@ int dvb_open_fe(dvb_priv_t *priv) { - priv->fe_fd = open(dvb_frontenddev[priv->card], O_RDWR); + priv->fe_fd = open(dvb_frontenddev[priv->card], O_RDWR | O_NONBLOCK); if(priv->fe_fd < 0) { mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR IN OPENING FRONTEND DEVICE %s: ERRNO %d\n", dvb_frontenddev[priv->card], errno); @@ -221,9 +221,7 @@ #ifndef HAVE_DVB_HEAD static int OSTSelftest(int fd) { - int ans; - - if ((ans = ioctl(fd, FE_SELFTEST,0) < 0)) + if(ioctl(fd, FE_SELFTEST,0) < 0) { mp_msg(MSGT_DEMUX, MSGL_ERR, "FE SELF TEST: "); return -1; @@ -234,9 +232,7 @@ static int OSTSetPowerState(int fd, uint32_t state) { - int ans; - - if ((ans = ioctl(fd,FE_SET_POWER_STATE,state) < 0)) + if (ioctl(fd,FE_SET_POWER_STATE,state) < 0) { mp_msg(MSGT_DEMUX, MSGL_ERR, "OST SET POWER STATE: "); return -1; @@ -247,9 +243,7 @@ static int OSTGetPowerState(int fd, uint32_t *state) { - int ans; - - if ((ans = ioctl(fd,FE_GET_POWER_STATE,state) < 0)) + if(ioctl(fd,FE_GET_POWER_STATE,state) < 0) { mp_msg(MSGT_DEMUX, MSGL_ERR, "OST GET POWER STATE: "); return -1; @@ -280,9 +274,7 @@ static int SecGetStatus (int fd, struct secStatus *state) { - int ans; - - if ((ans = ioctl(fd, SEC_GET_STATUS, state) < 0)) + if(ioctl(fd, SEC_GET_STATUS, state) < 0) { mp_msg(MSGT_DEMUX, MSGL_ERR, ("SEC GET STATUS: ")); return -1; @@ -367,6 +359,12 @@ struct dvb_frontend_info fe_info; struct pollfd pfd[1]; + while(1) + { + if (ioctl(fd_frontend, FE_GET_EVENT, &event) < 0) //EMPTY THE EVENT QUEUE + break; + } + if (ioctl(fd_frontend,FE_SET_FRONTEND,feparams) < 0) { mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR tuning channel\n"); @@ -374,15 +372,15 @@ } pfd[0].fd = fd_frontend; - pfd[0].events = POLLIN; + pfd[0].events = POLLPRI; event.status=0; while (((event.status & FE_TIMEDOUT)==0) && ((event.status & FE_HAS_LOCK)==0)) { mp_msg(MSGT_DEMUX, MSGL_V, "polling....\n"); - if (poll(pfd,1,10000)) + if(poll(pfd,1,10000) > 0) { - if (pfd[0].revents & POLLIN) + if (pfd[0].revents & POLLPRI) { mp_msg(MSGT_DEMUX, MSGL_V, "Getting frontend event\n"); if ( ioctl(fd_frontend, FE_GET_EVENT, &event) < 0) @@ -418,24 +416,24 @@ } strength=0; - ioctl(fd_frontend,FE_READ_BER,&strength); + if(ioctl(fd_frontend,FE_READ_BER,&strength) >= 0) mp_msg(MSGT_DEMUX, MSGL_V, "Bit error rate: %d\n",strength); strength=0; - ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength); + if(ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength) >= 0) mp_msg(MSGT_DEMUX, MSGL_V, "Signal strength: %d\n",strength); strength=0; - ioctl(fd_frontend,FE_READ_SNR,&strength); + if(ioctl(fd_frontend,FE_READ_SNR,&strength) >= 0) mp_msg(MSGT_DEMUX, MSGL_V, "SNR: %d\n",strength); festatus=0; - ioctl(fd_frontend,FE_READ_STATUS,&festatus); + if(ioctl(fd_frontend,FE_READ_STATUS,&festatus) >= 0) print_status(festatus); } else { - mp_msg(MSGT_DEMUX, MSGL_V, "Not able to lock to the signal on the given frequency\n"); + mp_msg(MSGT_DEMUX, MSGL_ERR, "Not able to lock to the signal on the given frequency\n"); return -1; } return 0; @@ -462,11 +460,11 @@ } pfd[0].fd = fd_frontend; - pfd[0].events = POLLIN; + pfd[0].events = POLLPRI; - if (poll(pfd,1,10000)) + if(poll(pfd,1,10000) > 0) { - if (pfd[0].revents & POLLIN) + if (pfd[0].revents & POLLPRI) { mp_msg(MSGT_DEMUX, MSGL_V, "Getting frontend event\n"); if ( ioctl(fd_frontend, FE_GET_EVENT, &event) < 0) @@ -534,21 +532,22 @@ } strength=0; - ioctl(fd_frontend,FE_READ_BER,&strength); + if(ioctl(fd_frontend,FE_READ_BER,&strength) >= 0) mp_msg(MSGT_DEMUX, MSGL_V, "Bit error rate: %d\n",strength); strength=0; - ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength); + if(ioctl(fd_frontend,FE_READ_SIGNAL_STRENGTH,&strength) >= 0) mp_msg(MSGT_DEMUX, MSGL_V, "Signal strength: %d\n",strength); strength=0; - ioctl(fd_frontend,FE_READ_SNR,&strength); + if(ioctl(fd_frontend,FE_READ_SNR,&strength) >= 0) mp_msg(MSGT_DEMUX, MSGL_V, "SNR: %d\n",strength); festatus=0; - ioctl(fd_frontend,FE_READ_STATUS,&festatus); - mp_msg(MSGT_DEMUX, MSGL_V, "FE_STATUS:"); + + if(ioctl(fd_frontend,FE_READ_STATUS,&festatus) >= 0) + { if (festatus & FE_HAS_POWER) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_POWER"); if (festatus & FE_HAS_SIGNAL) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_SIGNAL"); if (festatus & FE_SPECTRUM_INV) mp_msg(MSGT_DEMUX, MSGL_V, " FE_SPECTRUM_INV"); @@ -557,6 +556,10 @@ if (festatus & FE_HAS_VITERBI) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_VITERBI"); if (festatus & FE_HAS_SYNC) mp_msg(MSGT_DEMUX, MSGL_V, " FE_HAS_SYNC"); if (festatus & FE_TUNER_HAS_LOCK) mp_msg(MSGT_DEMUX, MSGL_V, " FE_TUNER_HAS_LOCK"); + } + else + mp_msg(MSGT_DEMUX, MSGL_ERR, " ERROR, UNABLE TO READ"); + mp_msg(MSGT_DEMUX, MSGL_V, "\n"); } else @@ -575,18 +578,25 @@ uint32_t wait; }; -static void diseqc_send_msg(int fd, fe_sec_voltage_t v, struct diseqc_cmd *cmd, +static int diseqc_send_msg(int fd, fe_sec_voltage_t v, struct diseqc_cmd *cmd, fe_sec_tone_mode_t t, fe_sec_mini_cmd_t b) { - ioctl(fd, FE_SET_TONE, SEC_TONE_OFF); - ioctl(fd, FE_SET_VOLTAGE, v); + if(ioctl(fd, FE_SET_TONE, SEC_TONE_OFF) == -1) + return -1; + if(ioctl(fd, FE_SET_VOLTAGE, v) == -1) + return -1; usleep(15 * 1000); - ioctl(fd, FE_DISEQC_SEND_MASTER_CMD, &cmd->cmd); + if(ioctl(fd, FE_DISEQC_SEND_MASTER_CMD, &cmd->cmd) == -1) + return -1; usleep(cmd->wait * 1000); usleep(15 * 1000); - ioctl(fd, FE_DISEQC_SEND_BURST, b); + if(ioctl(fd, FE_DISEQC_SEND_BURST, b) == -1) + return -1; usleep(15 * 1000); - ioctl(fd, FE_SET_TONE, t); + if(ioctl(fd, FE_SET_TONE, t) == -1) + return -1; + + return 0; } @@ -605,11 +615,9 @@ cmd.cmd.msg[3] = 0xf0 | (((sat_no * 4) & 0x0f) | (hi_lo ? 1 : 0) | (pol ? 0 : 2)); - diseqc_send_msg(secfd, pol ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18, + return diseqc_send_msg(secfd, pol ? SEC_VOLTAGE_13 : SEC_VOLTAGE_18, &cmd, hi_lo ? SEC_TONE_ON : SEC_TONE_OFF, (sat_no / 4) % 2 ? SEC_MINI_B : SEC_MINI_A); - - return 1; } #endif @@ -765,13 +773,14 @@ int ipol = (pol == 'V' ? 1 : 0); int hiband = (freq >= SLOF); - if(head_diseqc(fd_frontend, diseqc-1, ipol, hiband)) + if(head_diseqc(fd_frontend, diseqc-1, ipol, hiband) == 0) { mp_msg(MSGT_DEMUX, MSGL_V, "DISEQC SETTING SUCCEDED\n"); } else { mp_msg(MSGT_DEMUX, MSGL_ERR, "DISEQC SETTING FAILED\n"); + return -1; } } #else