- char filename[128];
-#if HAVE_DVB_API_VERSION < 3
- snprintf(filename, 128, "/dev/dvb/card%d/demux%d", m_demux->adapter, m_demux->demux);
-#else
- snprintf(filename, 128, "/dev/dvb/adapter%d/demux%d", m_demux->adapter, m_demux->demux);
-#endif
- int fd = ::open(filename, O_RDWR);
- if (fd < 0)
- {
- eDebug("FAILED to open demux (%s) in ts recoder (%m)", filename);
- return -1;
- }
-
-#if HAVE_DVB_API_VERSION < 3
- dmxPesFilterParams flt;
-
- flt.pesType = DMX_PES_OTHER;
-#else
- dmx_pes_filter_params flt;
-
- flt.pes_type = DMX_PES_OTHER;
-#endif
-
- flt.pid = pid;
- flt.input = DMX_IN_FRONTEND;
- flt.output = DMX_OUT_TS_TAP;
-
- flt.flags = DMX_IMMEDIATE_START;
-
- int res = ::ioctl(fd, DMX_SET_PES_FILTER, &flt);
- if (res < 0)
- {
- eDebug("set pes filter failed!");
- ::close(fd);
- return -1;
+ while(true) {
+ __u16 p = pid;
+ if (::ioctl(m_source_fd, DMX_ADD_PID, &p) < 0) {
+ perror("DMX_ADD_PID");
+ if (errno == EAGAIN || errno == EINTR) {
+ eDebug("retry!");
+ continue;
+ }
+ } else
+ m_pids[pid] = 1;
+ break;