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