-
Notifications
You must be signed in to change notification settings - Fork 0
/
radiocheck.c
165 lines (149 loc) · 5.79 KB
/
radiocheck.c
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
* radiocheck.c
*
* Created on: 27.05.2018
* Author: uli
*/
// --- cRadioCheck -------------------------------------------------------
#include <vdr/plugin.h>
#include <vdr/status.h>
#include <vdr/config.h>
#include <vdr/interface.h>
#include <vdr/transfer.h>
#include "radiocheck.h"
#include "radioepg.h"
#include "inforx.h"
extern int IsRadioOrReplay;
extern int S_Verbose;
extern int InfoTimeout;
extern bool DoInfoReq, InfoRequest;
extern const cChannel *chan;
cRadioCheck *cRadioCheck::RadioCheck = NULL;
cRadioCheck::cRadioCheck(void)
: cThread("radiocheck")
{
IsRadioOrReplay = 0;
}
cRadioCheck::~cRadioCheck() {
if (Running()) {
Stop();
}
}
void cRadioCheck::Init(void) {
if (RadioCheck == NULL) {
RadioCheck = new cRadioCheck;
RadioCheck->Start();
}
}
void cRadioCheck::Exit(void) {
if (RadioCheck != NULL) {
RadioCheck->Stop();
DELETENULL(RadioCheck);
}
}
void cRadioCheck::Stop(void) {
Cancel(10);
}
void cRadioCheck::Action(void)
{
if ((S_Verbose & 0x0f) >= 2) {
printf("vdr-radio: background-checking starts\n");
}
while (Running()) {
cCondWait::SleepMs(2000);
// check Live-Radio
if ((IsRadioOrReplay == 1) && (chan != NULL)) {
if (chan->Vpid()) {
isyslog("radio: channnel '%s' got Vpid= %d", chan->Name(),
chan->Vpid());
IsRadioOrReplay = 0;
#if VDRVERSNUM >= 20300
LOCK_CHANNELS_READ
Channels->SwitchTo(cDevice::CurrentChannel());
#else
Channels.SwitchTo(cDevice::CurrentChannel());
#endif
//cDevice::PrimaryDevice()->SwitchChannel(chan, true);
} else {
if ((InfoTimeout -= 2) <= 0) {
InfoTimeout = 20;
int chtid = chan->Tid();
// Kanal-EPG PresentEvent
if (chan->Apid(0) > 0
&& (chtid == PREMIERERADIO_TID
|| chtid == KDRADIO_TID
|| chtid == UMRADIO_TID1
|| chtid == UMRADIO_TID2
|| chtid == UMRADIO_TID3
|| chtid == UMRADIO_TID4
|| chtid == UMRADIO_TID5)) {
#if VDRVERSNUM >= 20300
LOCK_SCHEDULES_READ
static cStateKey SchedulesStateKey;
const cSchedules *scheds = cSchedules::GetSchedulesRead(
SchedulesStateKey);
#else
cSchedulesLock schedLock;
const cSchedules *scheds = cSchedules::Schedules(schedLock);
#endif
if (scheds != NULL) {
const cSchedule *sched = scheds->GetSchedule(
chan->GetChannelID());
if (sched != NULL) {
const cEvent *present =
sched->GetPresentEvent();
if (present != NULL) {
if (chtid == PREMIERERADIO_TID) { // Premiere
InfoTimeout = epg_premiere(
present->Title(),
present->Description(),
present->StartTime(),
present->EndTime());
}
else if (chtid == KDRADIO_TID) {// Kabel Deutschland
InfoTimeout = epg_kdg(
present->Description(),
present->StartTime(),
present->EndTime());
}
else {
// Unity Media Kabel
InfoTimeout = epg_unitymedia(
present->Description(),
present->StartTime(),
present->EndTime());
}
InfoRequest = true;
}
else {
dsyslog("radio: no event.present (Tid= %d, Apid= %d)",
chtid, chan->Apid(0));
}
}
else {
dsyslog("radio: no schedule (Tid= %d, Apid= %d)",
chtid, chan->Apid(0));
}
}
}
// Artist/Title with external script?
else if (chan->Apid(0) > 0 && DoInfoReq) {
InfoTimeout = info_request(chtid, chan->Apid(0));
InfoRequest = (InfoTimeout > 0);
}
}
}
}
// temp. OSD-CloseTimeout
(RT_OsdTOTemp > 0) ? RT_OsdTOTemp -= 2 : RT_OsdTOTemp = 0; // in sec like this cycletime
// Radiotext-Autodisplay
if ((S_RtDispl == 2) && (RT_Info >= 0) && !RT_OsdTO
&& (RT_OsdTOTemp == 0) && RT_ReOpen && !Skins.IsOpen()
&& !cOsd::IsOpen()) {
cRemote::CallPlugin("radio");
}
}
if ((S_Verbose & 0x0f) >= 2) {
printf("vdr-radio: background-checking ends\n");
}
}