summaryrefslogtreecommitdiff
path: root/coreengine
diff options
context:
space:
mode:
authorkamel5 <vdr.kamel5 (at) gmx (dot) net>2021-05-16 13:19:42 +0200
committerkamel5 <vdr.kamel5 (at) gmx (dot) net>2021-05-21 11:46:16 +0200
commit3c7e014dcc43614f9d35642dd25887612b799aad (patch)
tree71462dd41902d13c1ecf6c0300e4beb415e4c4af /coreengine
parentb977e3582adf6bd901bb2ed0849ad9b0bd42afb7 (diff)
downloadvdr-plugin-skindesigner-3c7e014dcc43614f9d35642dd25887612b799aad.tar.gz
vdr-plugin-skindesigner-3c7e014dcc43614f9d35642dd25887612b799aad.tar.bz2
Fix a device is currently recording
The token indicating whether a device is currently recording was not updated correctly
Diffstat (limited to 'coreengine')
-rw-r--r--coreengine/viewelementscommon.c67
-rw-r--r--coreengine/viewelementscommon.h4
2 files changed, 41 insertions, 30 deletions
diff --git a/coreengine/viewelementscommon.c b/coreengine/viewelementscommon.c
index 2df678a..f12bb03 100644
--- a/coreengine/viewelementscommon.c
+++ b/coreengine/viewelementscommon.c
@@ -160,12 +160,12 @@ bool cVeMessage::Parse(bool forced) {
* cVeDevices
******************************************************************/
cVeDevices::cVeDevices(void) {
- lastRefresh = 0;
initial = true;
devicesIndex = -1;
lastSignalStrength = NULL;
lastSignalQuality = NULL;
recDevices = NULL;
+ lastRecDevices = NULL;
}
cVeDevices::~cVeDevices(void) {
@@ -176,6 +176,8 @@ cVeDevices::~cVeDevices(void) {
lastSignalQuality = NULL;
delete[] recDevices;
recDevices = NULL;
+ delete[] lastRecDevices;
+ lastRecDevices = NULL;
mutexDevices.Unlock();
}
@@ -193,11 +195,13 @@ void cVeDevices::Init(void) {
lastSignalStrength = new int[numDevices];
lastSignalQuality = new int[numDevices];
recDevices = new bool[numDevices];
+ lastRecDevices = new bool[numDevices];
mutexDevices.Lock();
for (int i=0; i<numDevices; i++) {
lastSignalStrength[i] = 0;
lastSignalQuality[i] = 0;
recDevices[i] = false;
+ lastRecDevices[i] = false;
}
mutexDevices.Unlock();
}
@@ -205,7 +209,6 @@ void cVeDevices::Init(void) {
void cVeDevices::Close(void) {
devices.clear();
initial = true;
- lastRefresh = 0;
numDevices = 0;
mutexDevices.Lock();
delete[] lastSignalStrength;
@@ -214,6 +217,8 @@ void cVeDevices::Close(void) {
lastSignalQuality = NULL;
delete[] recDevices;
recDevices = NULL;
+ delete[] lastRecDevices;
+ lastRecDevices = NULL;
mutexDevices.Unlock();
cViewElement::Close();
}
@@ -243,17 +248,17 @@ void cVeDevices::SetTokenContainer(void) {
bool cVeDevices::Parse(bool forced) {
if (!cViewElement::Parse(forced))
return false;
+
+ bool changed = false;
if (initial) {
Init();
initial = false;
+ changed = true;
} else {
//in light modus content is static
if (light)
return false;
- //check if drawing is necessary
- if (cTimeMs::Now() - lastRefresh < 500)
- return false;
- bool changed = false;
+
for (int i = 0; i < numDevices; i++) {
const cDevice *device = cDevice::GetDevice(devices[i]);
if (!device || !device->NumProvidedSystems()) {
@@ -272,22 +277,15 @@ bool cVeDevices::Parse(bool forced) {
if ((signalStrength != lastSigStr) || (signalQuality != lastSigQual)) {
changed = true;
break;
- }
- }
- if (!changed) {
- return false;
+ }
}
}
- //check device which currently displays live tv
- int deviceLiveTV = -1;
- cDevice *primaryDevice = cDevice::PrimaryDevice();
- if (primaryDevice) {
- if (!primaryDevice->Replaying() || primaryDevice->Transferring())
- deviceLiveTV = cDevice::ActualDevice()->DeviceNumber();
- else
- deviceLiveTV = primaryDevice->DeviceNumber();
+ // reset recording devices
+ for (int i = 0; i < numDevices; i++) {
+ recDevices[i] = false;
}
+
// check currently recording devices
// BLOCK for LOCK_TIMERS_READ scope !!
{
@@ -305,8 +303,7 @@ bool cVeDevices::Parse(bool forced) {
const cDevice *recDevice = RecordControl->Device();
if (recDevice) {
mutexDevices.Lock();
- if (recDevices)
- {
+ if (recDevices) {
int d = recDevice->DeviceNumber();
for (int i = 0; i < numDevices; i++) {
if (devices[i] == d) {
@@ -319,6 +316,27 @@ bool cVeDevices::Parse(bool forced) {
}
}
}
+ } // LOCK_TIMERS_READ
+
+ for (int i = 0; i < numDevices; i++) {
+ if (recDevices[i] != lastRecDevices[i]) {
+ lastRecDevices[i] = recDevices[i];
+ changed = true;
+ }
+ }
+
+ if (!changed) {
+ return false;
+ }
+
+ //check device which currently displays live tv
+ int deviceLiveTV = -1;
+ cDevice *primaryDevice = cDevice::PrimaryDevice();
+ if (primaryDevice) {
+ if (!primaryDevice->Replaying() || primaryDevice->Transferring())
+ deviceLiveTV = cDevice::ActualDevice()->DeviceNumber();
+ else
+ deviceLiveTV = primaryDevice->DeviceNumber();
}
//create loop container
@@ -356,13 +374,7 @@ bool cVeDevices::Parse(bool forced) {
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::signalstrength, *cString::sprintf("%d", signalStrength));
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::signalquality, *cString::sprintf("%d", signalQuality));
tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::livetv, devices[i] == deviceLiveTV ? "1" : "0");
-
- bool isRecording = false;
- mutexDevices.Lock();
- if (recDevices && recDevices[i])
- isRecording = true;
- mutexDevices.Unlock();
- tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::recording, isRecording ? "1" : "0");
+ tokenContainer->AddLoopToken(devicesIndex, i, (int)eDevicesLT::recording, (recDevices && recDevices[i]) ? "1" : "0");
const cChannel *channel = device->GetCurrentlyTunedTransponder();
const cSource *source = (channel) ? Sources.Get(channel->Source()) : NULL;
@@ -388,7 +400,6 @@ bool cVeDevices::Parse(bool forced) {
}
SetDirty();
- lastRefresh = cTimeMs::Now();
return true;
}
/******************************************************************
diff --git a/coreengine/viewelementscommon.h b/coreengine/viewelementscommon.h
index e0b2870..629a9cc 100644
--- a/coreengine/viewelementscommon.h
+++ b/coreengine/viewelementscommon.h
@@ -51,7 +51,6 @@ public:
class cVeDevices : public cViewElement {
private:
bool light;
- time_t lastRefresh;
vector<int> devices;
bool initial;
int devicesIndex;
@@ -60,6 +59,7 @@ private:
int* lastSignalStrength;
int* lastSignalQuality;
bool* recDevices;
+ bool* lastRecDevices;
void Init(void);
public:
cVeDevices(void);
@@ -107,4 +107,4 @@ public:
void Set(int current, int total, bool mute);
bool Parse(bool forced = false);
};
-#endif //__VIEWELEMENTSCOMMON_H \ No newline at end of file
+#endif //__VIEWELEMENTSCOMMON_H