[Mplayer-cvslog] CVS: main/libmpdemux dvbin.c, 1.4, 1.5 dvbin.h, 1.4, 1.5 dvb_tune.c, 1.4, 1.5
Attila Kinali CVS
attila at mplayerhq.hu
Thu Jan 29 11:36:36 CET 2004
Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv28080/libmpdemux
Modified Files:
dvbin.c dvbin.h dvb_tune.c
Log Message:
Compliance with the DVB power management specification (doesn't close
the tuner after having tuned).
This permits to remove the parameter dvb_shutdown_timeout=0 to the
module dvb-core and ultimately
shuts down the card when the tuner isn't used.
patch by Nico <nsabbi at tiscali.it>
Index: dvbin.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/dvbin.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- dvbin.c 1 Nov 2003 15:17:01 -0000 1.4
+++ dvbin.c 29 Jan 2004 10:36:33 -0000 1.5
@@ -113,7 +113,7 @@
extern int dvb_tune(dvb_priv_t *priv, int freq, char pol, int srate, int diseqc, int tone,
fe_spectral_inversion_t specInv, fe_modulation_t modulation, fe_guard_interval_t guardInterval,
fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, fe_code_rate_t HP_CodeRate);
-extern char *dvb_dvrdev[4], *dvb_demuxdev[4];
+extern char *dvb_dvrdev[4], *dvb_demuxdev[4], *dvb_frontenddev[4];
dvb_channels_list *dvb_list_ptr = NULL;
@@ -348,15 +348,14 @@
}
if(channel->vpid)
- if(! dvb_set_ts_filt(priv->demux_fd[0], channel->vpid, DMX_PES_VIDEO))
+ if(! dvb_set_ts_filt(priv->demux_fd[0], channel->vpid, DMX_PES_OTHER))
return 0;
- //dvb_demux_start(priv->demux_fd[0]);
if(channel->apid1)
- if(! dvb_set_ts_filt(priv->demux_fd[1], channel->apid1, DMX_PES_AUDIO))
+ if(! dvb_set_ts_filt(priv->demux_fd[1], channel->apid1, DMX_PES_OTHER))
return 0;
- printf("RESET DEMUXERS SUCCEDED, errno=%d\n\n\n", errno);
+ return 1;
}
@@ -440,14 +439,12 @@
//sets demux filters and restart the stream
if(channel->vpid)
- if(! dvb_set_ts_filt(priv->demux_fd[0], channel->vpid, DMX_PES_VIDEO))
+ if(! dvb_set_ts_filt(priv->demux_fd[0], channel->vpid, DMX_PES_OTHER))
return 0;
- //dvb_demux_start(priv->demux_fd[0]);
if(channel->apid1)
- if(! dvb_set_ts_filt(priv->demux_fd[1], channel->apid1, DMX_PES_AUDIO))
+ if(! dvb_set_ts_filt(priv->demux_fd[1], channel->apid1, DMX_PES_OTHER))
return 0;
- //dvb_demux_start(priv->demux_fd[1]);
return 1;
}
@@ -505,6 +502,12 @@
close(priv->dvr_fd);
close(priv->demux_fd[0]);
close(priv->demux_fd[1]);
+
+ close(priv->fe_fd);
+#ifdef HAVE_DVB
+ close(priv->sec_fd);
+#endif
+
priv->is_on = 0;
priv->stream = NULL;
if(dvb_list_ptr)
@@ -572,7 +575,7 @@
{
pids[npids] = channel->vpid;
}
- pestypes[npids] = DMX_PES_VIDEO;
+ pestypes[npids] = DMX_PES_OTHER;
npids++;
if(opts->aid > 0)
@@ -583,7 +586,7 @@
{
pids[npids] = channel->apid1;
}
- pestypes[npids] = DMX_PES_AUDIO;
+ pestypes[npids] = DMX_PES_OTHER;
npids++;
@@ -634,12 +637,11 @@
// I don't force the file format bacause, although it's almost always TS,
// there are some providers that stream an IP multicast with M$ Mpeg4 inside
struct stream_priv_s* p = (struct stream_priv_s*)opts;
- char *name = NULL, *filename;
+ char *filename;
dvb_priv_t *priv;
int tuner_type = 0;
-
if(mode != STREAM_READ)
return STREAM_UNSUPORTED;
@@ -650,16 +652,13 @@
priv = (dvb_priv_t *)stream->priv;
priv->stream = stream;
- name = malloc(sizeof(char)*128);
-
- if(name == NULL)
- {
- mp_msg(MSGT_DEMUX, MSGL_ERR, "COULDN'T MALLOC SOME TMP MEMORY, EXIT!\n");
- return STREAM_ERROR;
- }
-
priv->card = p->card - 1;
-
+ if(! dvb_open_fe(priv))
+ {
+ mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR OPENING FRONTEND DEVICE %s: %d\n", dvb_frontenddev[priv->card], errno);
+ return STREAM_ERROR;
+ }
+
if(!strncmp(p->type, "CBL", 3))
{
tuner_type = TUNER_CBL;
Index: dvbin.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/dvbin.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- dvbin.h 11 Aug 2003 00:02:46 -0000 1.4
+++ dvbin.h 29 Jan 2004 10:36:33 -0000 1.5
@@ -81,8 +81,8 @@
extern int dvb_step_channel(dvb_priv_t *, int);
extern int dvb_set_channel(dvb_priv_t *, int);
+extern int dvb_open_fe(dvb_priv_t *priv);
-extern dvb_channels_list *dvb_get_channels(char *, int);
extern dvb_history_t dvb_prev_next;
Index: dvb_tune.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/dvb_tune.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- dvb_tune.c 1 Nov 2003 15:17:01 -0000 1.4
+++ dvb_tune.c 29 Jan 2004 10:36:33 -0000 1.5
@@ -33,7 +33,7 @@
#ifdef HAVE_DVB_HEAD
#include <linux/dvb/dmx.h>
#include <linux/dvb/frontend.h>
- static char* dvb_frontenddev[4]={"/dev/dvb/adapter0/frontend0","/dev/dvb/adapter1/frontend0","/dev/dvb/adapter2/frontend0","/dev/dvb/adapter3/frontend0"};
+ char* dvb_frontenddev[4]={"/dev/dvb/adapter0/frontend0","/dev/dvb/adapter1/frontend0","/dev/dvb/adapter2/frontend0","/dev/dvb/adapter3/frontend0"};
char* dvb_dvrdev[4]={"/dev/dvb/adapter0/dvr0","/dev/dvb/adapter1/dvr0","/dev/dvb/adapter2/dvr0","/dev/dvb/adapter3/dvr0"};
char* dvb_demuxdev[4]={"/dev/dvb/adapter0/demux0","/dev/dvb/adapter1/demux0","/dev/dvb/adapter2/demux0","/dev/dvb/adapter3/demux0"};
static char* dvb_secdev[4]={"","","",""}; //UNUSED, ONLY FOR UNIFORMITY
@@ -41,7 +41,7 @@
#include <ost/dmx.h>
#include <ost/sec.h>
#include <ost/frontend.h>
- static char* dvb_frontenddev[4]={"/dev/ost/frontend0","/dev/ost/frontend1","/dev/ost/frontend2","/dev/ost/frontend3"};
+ char* dvb_frontenddev[4]={"/dev/ost/frontend0","/dev/ost/frontend1","/dev/ost/frontend2","/dev/ost/frontend3"};
char* dvb_dvrdev[4]={"/dev/ost/dvr0","/dev/ost/dvr1","/dev/ost/dvr2","/dev/ost/dvr3"};
static char* dvb_secdev[4]={"/dev/ost/sec0","/dev/ost/sec1","/dev/ost/sec2","/dev/ost/sec3"};
char* dvb_demuxdev[4]={"/dev/ost/demux0","/dev/ost/demux1","/dev/ost/demux2","/dev/ost/demux3"};
@@ -60,22 +60,16 @@
FrontendInfo fe_info;
#endif
- int res, fe_fd = -1;
-
- fe_fd = open(dvb_frontenddev[priv->card], O_RDWR);
- if(fe_fd < 0)
- {
- mp_msg(MSGT_DEMUX, MSGL_ERR, "get_tuner_type(card %d), ERROR IN OPENING FRONTEND DEVICE %s: ERRNO %d\n", priv->card, dvb_frontenddev[priv->card], errno);
- return 0;
- }
-
+ int res, fe_fd;
+
+ fe_fd = priv->fe_fd;
+
res = ioctl(fe_fd, FE_GET_INFO, &fe_info);
if(res < 0)
{
mp_msg(MSGT_DEMUX, MSGL_ERR, "FE_GET_INFO error: %d, FD: %d\n\n", errno, fe_fd);
return 0;
}
- close(fe_fd);
switch(fe_info.type)
{
@@ -86,20 +80,20 @@
case FE_QPSK:
mp_msg(MSGT_DEMUX, MSGL_INFO, "TUNER TYPE SEEMS TO BE DVB-S\n");
return TUNER_SAT;
-
+
case FE_QAM:
mp_msg(MSGT_DEMUX, MSGL_INFO, "TUNER TYPE SEEMS TO BE DVB-C\n");
return TUNER_CBL;
-
+
default:
mp_msg(MSGT_DEMUX, MSGL_ERR, "UNKNOWN TUNER TYPE\n");
- return 0;
+ return 0;
}
-
-}
+
+}
-static int open_fe(dvb_priv_t *priv)
+int dvb_open_fe(dvb_priv_t *priv)
{
priv->fe_fd = open(dvb_frontenddev[priv->card], O_RDWR);
if(priv->fe_fd < 0)
@@ -201,29 +195,23 @@
fe_spectral_inversion_t specInv, fe_modulation_t modulation, fe_guard_interval_t guardInterval,
fe_transmit_mode_t TransmissionMode, fe_bandwidth_t bandWidth, fe_code_rate_t HP_CodeRate)
{
+ int ris;
+
mp_msg(MSGT_DEMUX, MSGL_INFO, "dvb_tune Freq: %lu\n", freq);
- if(! open_fe(priv))
- {
- return 0;
- }
-
+
if(freq > 100000000)
{
- tune_it(priv->fe_fd, 0, freq, srate, 0, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth);
+ ris = tune_it(priv->fe_fd, 0, freq, srate, 0, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth);
}
else if(freq != 0)
{
- tune_it(priv->fe_fd, priv->sec_fd, freq, srate, pol, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth);
+ ris = tune_it(priv->fe_fd, priv->sec_fd, freq, srate, pol, tone, specInv, diseqc, modulation, HP_CodeRate, TransmissionMode, guardInterval, bandWidth);
}
-
- close(priv->fe_fd);
-
-#ifdef HAVE_DVB_HEAD
-#else
- close(priv->sec_fd);
-#endif
- return 1;
+ if(ris != 0)
+ mp_msg(MSGT_DEMUX, MSGL_INFO, "dvb_tune, TUNING FAILED\n");
+
+ return (ris == 0);
}
@@ -670,7 +658,7 @@
#ifdef HAVE_DVB_HEAD
if (freq < 1000000) freq*=1000UL;
feparams.frequency=freq;
- feparams.inversion=INVERSION_OFF;
+ feparams.inversion=specInv;
feparams.u.ofdm.bandwidth=bandwidth;
feparams.u.ofdm.code_rate_HP=HP_CodeRate;
feparams.u.ofdm.code_rate_LP=LP_CODERATE_DEFAULT;
@@ -681,7 +669,7 @@
#else
if (freq < 1000000) freq*=1000UL;
feparams.Frequency=freq;
- feparams.Inversion=INVERSION_OFF;
+ feparams.Inversion=specInv;
feparams.u.ofdm.bandWidth=bandwidth;
feparams.u.ofdm.HP_CodeRate=HP_CodeRate;
feparams.u.ofdm.LP_CodeRate=LP_CODERATE_DEFAULT;
@@ -823,16 +811,16 @@
mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-C to %d, srate=%d\n",freq,srate);
#ifdef HAVE_DVB_HEAD
feparams.frequency=freq;
- feparams.inversion=INVERSION_OFF;
+ feparams.inversion=specInv;
feparams.u.qam.symbol_rate = srate;
- feparams.u.qam.fec_inner = FEC_AUTO;
- feparams.u.qam.modulation = QAM_64;
+ feparams.u.qam.fec_inner = HP_CodeRate;
+ feparams.u.qam.modulation = modulation;
#else
feparams.Frequency=freq;
- feparams.Inversion=INVERSION_OFF;
+ feparams.Inversion=specInv;
feparams.u.qam.SymbolRate = srate;
- feparams.u.qam.FEC_inner = FEC_AUTO;
- feparams.u.qam.QAM = QAM_64;
+ feparams.u.qam.FEC_inner = HP_CodeRate;
+ feparams.u.qam.QAM = modulation;
#endif
break;
default:
More information about the MPlayer-cvslog
mailing list