mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-27 15:33:00 +02:00
cDemux: fix removePid / pesfds usage
This commit is contained in:
@@ -162,14 +162,6 @@ void cDemux::Close(void)
|
||||
return;
|
||||
}
|
||||
|
||||
for (std::vector<pes_pids>::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i)
|
||||
{
|
||||
lt_debug("%s stopping and closing demux fd %d pid 0x%04x\n", __FUNCTION__, (*i).fd, (*i).pid);
|
||||
if (ioctl((*i).fd, DMX_STOP) < 0)
|
||||
perror("DEMUX_STOP");
|
||||
if (close((*i).fd) < 0)
|
||||
perror("close");
|
||||
}
|
||||
pesfds.clear();
|
||||
ioctl(fd, DMX_STOP);
|
||||
close(fd);
|
||||
@@ -195,13 +187,6 @@ bool cDemux::Start(bool)
|
||||
lt_info("%s #%d: not open!\n", __FUNCTION__, num);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (std::vector<pes_pids>::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i)
|
||||
{
|
||||
lt_debug("%s starting demux fd %d pid 0x%04x\n", __FUNCTION__, (*i).fd, (*i).pid);
|
||||
if (ioctl((*i).fd, DMX_START) < 0)
|
||||
perror("DMX_START");
|
||||
}
|
||||
ioctl(fd, DMX_START);
|
||||
return true;
|
||||
}
|
||||
@@ -214,12 +199,6 @@ bool cDemux::Stop(void)
|
||||
lt_info("%s #%d: not open!\n", __FUNCTION__, num);
|
||||
return false;
|
||||
}
|
||||
for (std::vector<pes_pids>::const_iterator i = pesfds.begin(); i != pesfds.end(); ++i)
|
||||
{
|
||||
lt_debug("%s stopping demux fd %d pid 0x%04x\n", __FUNCTION__, (*i).fd, (*i).pid);
|
||||
if (ioctl((*i).fd, DMX_STOP) < 0)
|
||||
perror("DMX_STOP");
|
||||
}
|
||||
ioctl(fd, DMX_STOP);
|
||||
return true;
|
||||
}
|
||||
@@ -474,7 +453,6 @@ bool cDemux::addPid(unsigned short Pid)
|
||||
lt_debug("%s: pid 0x%04hx\n", __func__, Pid);
|
||||
pes_pids pfd;
|
||||
int ret;
|
||||
struct dmx_pes_filter_params p;
|
||||
if (dmx_type != DMX_TP_CHANNEL)
|
||||
{
|
||||
lt_info("%s pes_type %s not implemented yet! pid=%hx\n", __FUNCTION__, DMX_T[dmx_type], Pid);
|
||||
@@ -482,6 +460,9 @@ bool cDemux::addPid(unsigned short Pid)
|
||||
}
|
||||
if (fd == -1)
|
||||
lt_info("%s bucketfd not yet opened? pid=%hx\n", __FUNCTION__, Pid);
|
||||
pfd.fd = fd; /* dummy */
|
||||
pfd.pid = Pid;
|
||||
pesfds.push_back(pfd);
|
||||
ret = (ioctl(fd, DMX_ADD_PID, &Pid));
|
||||
if (ret < 0)
|
||||
lt_info("%s: DMX_ADD_PID (%m)\n", __func__);
|
||||
@@ -498,11 +479,9 @@ void cDemux::removePid(unsigned short Pid)
|
||||
for (std::vector<pes_pids>::iterator i = pesfds.begin(); i != pesfds.end(); ++i)
|
||||
{
|
||||
if ((*i).pid == Pid) {
|
||||
lt_debug("removePid: removing demux fd %d pid 0x%04x\n", (*i).fd, Pid);
|
||||
if (ioctl((*i).fd, DMX_STOP) < 0)
|
||||
perror("DMX_STOP");
|
||||
if (close((*i).fd) < 0)
|
||||
perror("close");
|
||||
lt_debug("removePid: removing demux fd %d pid 0x%04x\n", fd, Pid);
|
||||
if (ioctl(fd, DMX_REMOVE_PID, Pid) < 0)
|
||||
lt_info("%s: (DMX_REMOVE_PID, 0x%04hx): %m\n", __func__, Pid);
|
||||
pesfds.erase(i);
|
||||
return; /* TODO: what if the same PID is there multiple times */
|
||||
}
|
||||
|
Reference in New Issue
Block a user