--- szap.c.orig 2006-04-14 05:15:00.000000000 +0200 +++ szap.c 2006-04-14 04:59:02.117612424 +0200 @@ -298,7 +298,7 @@ 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, dmxfd, dmxfd2,audiofd = -1, patfd, pmtfd; int pmtpid; uint32_t ifreq; int hiband, result; @@ -334,6 +334,12 @@ close(fefd); return FALSE; } + if ((dmxfd2 = open(dmxdev, O_RDWR)) < 0) { + perror("opening video demux failed"); + close(fefd); + close(dmxfd); + return FALSE; + } if (dvr == 0) /* DMX_OUT_DECODER */ audiofd = open(auddev, O_RDWR); @@ -343,6 +349,7 @@ perror("opening audio demux failed"); close(audiofd); close(dmxfd); + close(dmxfd2); close(fefd); return FALSE; } @@ -352,6 +359,7 @@ close(patfd); close(audiofd); close(dmxfd); + close(dmxfd2); close(fefd); return FALSE; } @@ -378,7 +386,7 @@ if (set_demux(dmxfd, 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(dmxfd2, apid, DMX_PES_AUDIO, dvr)) { if (rec_psi) { pmtpid = get_pmt_pid(dmxdev, sid); if (pmtpid < 0) { @@ -404,6 +412,7 @@ if (audiofd >= 0) close(audiofd); close(dmxfd); + close(dmxfd2); close(fefd); }