1
0
mirror of https://github.com/rofafor/vdr-plugin-iptv.git synced 2023-10-10 13:37:03 +02:00

Some cosmetic changes.

This commit is contained in:
Rolf Ahrenberg 2007-09-19 18:02:38 +00:00
parent 30ced52a0c
commit 0ae7eb654e

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: device.c,v 1.24 2007/09/19 15:14:32 ajhseppa Exp $
* $Id: device.c,v 1.25 2007/09/19 18:02:38 rahrenbe Exp $
*/
#include "common.h"
@ -170,26 +170,21 @@ bool cIptvDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
bool cIptvDevice::SetPid(cPidHandle *Handle, int Type, bool On)
{
debug("cIptvDevice::SetPid(%d) Type=%d On=%d\n", deviceIndex, Type, On);
debug("cIptvDevice::SetPid(%d) Pid=%d Type=%d On=%d\n", deviceIndex, Handle->pid, Type, On);
return true;
}
int cIptvDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask)
{
// Search the next free filter slot
for (int i = 0; i < 32; ++i) {
if(!filters[i].active) {
for (unsigned int i = 0; i < (sizeof(filters) / sizeof(filters[0])); ++i) {
if (!filters[i].active) {
debug("cIptvDevice::OpenFilter(): Pid=0x%X Tid=%02X Mask=%02X, filterCount = %d\n", Pid, Tid, Mask, i);
uint8_t mask = Mask;
uint8_t filt = Tid;
int err = set_trans_filt(&filter, i, Pid, &mask, &filt, 0);
if (err < 0)
error("Cannot set filter %d\n", i);
memset(filters[i].pipeName, '\0', sizeof(filters[i].pipeName));
snprintf(filters[i].pipeName, sizeof(filters[i].pipeName),
"/tmp/iptvPipe.%d", i);
@ -199,20 +194,14 @@ int cIptvDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask)
error("ERROR: mknod(): %s", strerror_r(errno, tmp, sizeof(tmp)));
unlink(filters[i].pipeName);
}
// Create descriptors
int fifoDescriptor = open(filters[i].pipeName, O_RDWR | O_NONBLOCK);
int returnDescriptor = open(filters[i].pipeName, O_RDONLY | O_NONBLOCK);
// Store the write pipe and set active flag
filters[i].active = true;
filters[i].fifoDesc = fifoDescriptor;
//++filterCount;
return returnDescriptor;
}
}
// No free filter slot found
return -1;
@ -265,17 +254,11 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
isPacketDelivered = true;
Data = p;
memcpy(filter.packet, p, sizeof(filter.packet));
trans_filt(p, 188, &filter);
for(int i = 0; i < 32; ++i) {
if(filters[i].active) {
trans_filt(p, TS_SIZE, &filter);
for (unsigned int i = 0; i < (sizeof(filters) / sizeof(filters[0])); ++i) {
if (filters[i].active) {
section *filtered = get_filt_sec(&filter, i);
if (filtered->found) {
// Select on the fifo emptyness. Using null timeout to return
// immediately
struct timeval tv;
@ -290,9 +273,8 @@ bool cIptvDevice::GetTSPacket(uchar *&Data)
if (retval < 0) {
char tmp[64];
error("ERROR: select(): %s", strerror_r(errno, tmp, sizeof(tmp)));
// VDR has probably closed the filter file descriptor.
// Clear the filter
// VDR has probably closed the filter file descriptor, so
// clear the filter
close(filters[i].fifoDesc);
unlink(filters[i].pipeName);
memset(filters[i].pipeName, '\0', sizeof(filters[i].pipeName));