[linux-dvb] [PATCH] szap uses same fd for audio and video

Andreas Oberritter obi at linuxtv.org
Tue Mar 14 18:42:31 CET 2006


Hi Johannes,

szap uses a single file descriptor for both audio and video demux. I
wonder if anybody ever used it to watch TV. I guess it worked in an
older revision. :-)

There are also two copied and pasted error message which I corrected.
See the patch below.

Best regards,
Andreas

---

diff -r 5b3ff270c3e8 util/szap/szap.c
--- a/util/szap/szap.c	Mon Mar 13 09:28:03 2006 +0000
+++ b/util/szap/szap.c	Tue Mar 14 18:33:52 2006 +0100
@@ -298,7 +298,7 @@ int zap_to(unsigned int adapter, unsigne
       int dvr, int rec_psi, int bypass)
 {
    char fedev[128], dmxdev[128], auddev[128];
-   static int fefd, dmxfd, audiofd = -1, patfd, pmtfd;
+   static int fefd, dmxfda, dmxfdv, audiofd = -1, patfd, pmtfd;
    int pmtpid;
    uint32_t ifreq;
    int hiband, result;
@@ -329,29 +329,38 @@ int zap_to(unsigned int adapter, unsigne
 	 return FALSE;
       }
 
-      if ((dmxfd = open(dmxdev, O_RDWR)) < 0) {
+      if ((dmxfdv = open(dmxdev, O_RDWR)) < 0) {
 	 perror("opening video demux failed");
 	 close(fefd);
 	 return FALSE;
       }
 
+      if ((dmxfda = open(dmxdev, O_RDWR)) < 0) {
+	 perror("opening audio demux failed");
+	 close(dmxfdv);
+	 close(fefd);
+	 return FALSE;
+      }
+
       if (dvr == 0)	/* DMX_OUT_DECODER */
 	 audiofd = open(auddev, O_RDWR);
 
       if (rec_psi){
          if ((patfd = open(dmxdev, O_RDWR)) < 0) {
-	    perror("opening audio demux failed");
+	    perror("opening pat demux failed");
 	    close(audiofd);
-	    close(dmxfd);
+	    close(dmxfda);
+	    close(dmxfdv);
 	    close(fefd);
 	    return FALSE;
          }
 
          if ((pmtfd = open(dmxdev, O_RDWR)) < 0) {
-	    perror("opening audio demux failed");
+	    perror("opening pmt demux failed");
 	    close(patfd);
 	    close(audiofd);
-	    close(dmxfd);
+	    close(dmxfda);
+	    close(dmxfdv);
 	    close(fefd);
 	    return FALSE;
          }
@@ -375,10 +384,10 @@ int zap_to(unsigned int adapter, unsigne
 
    if (diseqc(fefd, sat_no, pol, hiband))
       if (do_tune(fefd, ifreq, sr))
-	 if (set_demux(dmxfd, vpid, DMX_PES_VIDEO, dvr))
+	 if (set_demux(dmxfdv, vpid, DMX_PES_VIDEO, dvr))
 	    if (audiofd >= 0)
 	       (void)ioctl(audiofd, AUDIO_SET_BYPASS_MODE, bypass);
-	    if (set_demux(dmxfd, apid, DMX_PES_AUDIO, dvr)) {
+	    if (set_demux(dmxfda, apid, DMX_PES_AUDIO, dvr)) {
 	       if (rec_psi) {
 	          pmtpid = get_pmt_pid(dmxdev, sid);
 		  if (pmtpid < 0) {
@@ -403,7 +412,8 @@ int zap_to(unsigned int adapter, unsigne
       close(pmtfd);
       if (audiofd >= 0)
 	 close(audiofd);
-      close(dmxfd);
+      close(dmxfda);
+      close(dmxfdv);
       close(fefd);
    }
 





More information about the linux-dvb mailing list