summaryrefslogtreecommitdiff
path: root/receiver.c
blob: 6ddbaa6415c6d3bbc7b786f192204701e9a07de2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * receiver.c: The basic receiver interface
 *
 * See the main source file 'vdr.c' for copyright information and
 * how to reach the author.
 *
 * $Id: receiver.c 1.1 2002/06/10 16:30:00 kls Exp $
 */

#include <stdarg.h>
#include <stdio.h>
#include "receiver.h"

cReceiver::cReceiver(int Ca, int Priority, int NumPids, ...)
{
  device = NULL;
  ca = Ca;
  priority = Priority;
  if (NumPids) {
     va_list ap;
     va_start(ap, NumPids);
     int n = 0;
     while (n < MAXRECEIVEPIDS && NumPids--) {
           if ((pids[n] = va_arg(ap, int)) != 0)
              n++;
           }
     va_end(ap);
     }
  else
     esyslog("ERROR: cReceiver called without a PID!");
}

cReceiver::~cReceiver()
{
  Detach();
}

bool cReceiver::WantsPid(int Pid)
{
  if (Pid) {
     for (int i = 0; i < MAXRECEIVEPIDS; i++) {
         if (pids[i] == Pid)
            return true;
         if (!pids[i])
            break;
         }
     }
  return false;
}

void cReceiver::Detach(void)
{
  if (device)
     device->Detach(this);
}