Test this [PATCH], please

Nico <[email protected]>
Newsgroups gmane.comp.video.mplayer.user.dvb
Message-ID <[email protected]>
Hi,

this patch should make mplayer compatible with the (silly, IMHO) P.M. 
specified in the Linuxtv Api,
so it doesn't close the frontend during playback; consequently you don't 
need anymore
dvb_shutdown_timeout=0 as parameter to dvb-core.

In addition I made the code respect the  modulation and inversion 
specified in
the channel.conf  file, rather than hardcoding them to default values 
(affects only -T and -C users).


Please, test this patch extensively after having removed 
dvb_shutdown_timeout=0,
and report both success and failure; if all works well I will post the 
patch to -dev-eng.

Thanks,
    Nico

_______________________________________________
Mplayer-dvb mailing list
[email protected]
http://mplayerhq.hu/mailman/listinfo/mplayer-dvb
dvb-20031123.diff (text/plain, 8.9 KB)
diff -Naur MPlayer-20031123/libmpdemux/dvbin.c MPlayer-20031123.new/libmpdemux/dvbin.c
--- MPlayer-20031123/libmpdemux/dvbin.c	2003-11-01 16:17:01.000000000 +0100
+++ MPlayer-20031123.new/libmpdemux/dvbin.c	2003-11-23 10:43:34.000000000 +0100
@@ -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;
diff -Naur MPlayer-20031123/libmpdemux/dvbin.h MPlayer-20031123.new/libmpdemux/dvbin.h
--- MPlayer-20031123/libmpdemux/dvbin.h	2003-08-11 02:02:46.000000000 +0200
+++ MPlayer-20031123.new/libmpdemux/dvbin.h	2003-11-23 10:44:09.000000000 +0100
@@ -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;
 
 
diff -Naur MPlayer-20031123/libmpdemux/dvb_tune.c MPlayer-20031123.new/libmpdemux/dvb_tune.c
--- MPlayer-20031123/libmpdemux/dvb_tune.c	2003-11-01 16:17:01.000000000 +0100
+++ MPlayer-20031123.new/libmpdemux/dvb_tune.c	2003-11-23 11:10:59.000000000 +0100
@@ -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:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.