some more locks

This commit is contained in:
louis 2015-07-16 18:08:22 +02:00
parent 65b61b4e2b
commit 10e37f6b8e
4 changed files with 31 additions and 3 deletions

View File

@ -224,6 +224,7 @@ void cDisplayMenuListView::Render(void) {
}
int current = -1;
for (int i=0; i<itemCount; i++) {
Lock();
if (menuItems[i] && menuItems[i]->Dirty()) {
menuItems[i]->Clear();
menuItems[i]->SetNumber(i);
@ -236,6 +237,7 @@ void cDisplayMenuListView::Render(void) {
menuItems[i]->Stop();
}
}
Unlock();
}
if (current > -1) {
menuItems[current]->Start();

View File

@ -1191,6 +1191,8 @@ void cViewElement::Action(void) {
DoFlush();
if (scrolling) {
DoSleep(scrollDelay);
if (!Running())
return;
if (scrollOrientation == orHorizontal) {
ScrollHorizontal(scrollingPix, scrollDelay, scrollSpeed, scrollMode);
} else {

View File

@ -32,9 +32,14 @@ cViewHelpers::cViewHelpers(void) {
cViewHelpers::~cViewHelpers() {
if (devicesInit) {
mutexDevices.Lock();
delete[] lastSignalStrength;
lastSignalStrength = NULL;
delete[] lastSignalQuality;
lastSignalQuality = NULL;
delete[] recDevices;
recDevices = NULL;
mutexDevices.Unlock();
}
}
@ -309,11 +314,13 @@ void cViewHelpers::InitDevices(void) {
lastSignalStrength = new int[numDevices];
lastSignalQuality = new int[numDevices];
recDevices = new bool[numDevices];
mutexDevices.Lock();
for (int i=0; i<numDevices; i++) {
lastSignalStrength[i] = 0;
lastSignalQuality[i] = 0;
recDevices[i] = false;
}
mutexDevices.Unlock();
devicesInit = true;
}
@ -330,7 +337,15 @@ bool cViewHelpers::SetDevices(bool initial, bool light, intmap *intTokens, vecto
}
int signalStrength = device->SignalStrength();
int signalQuality = device->SignalQuality();
if ((signalStrength != lastSignalStrength[i]) || (signalQuality != lastSignalQuality[i])) {
int lastSigStr = 0;
int lastSigQual = 0;
mutexDevices.Lock();
if (lastSignalStrength && lastSignalQuality) {
lastSigStr = lastSignalStrength[i];
lastSigQual = lastSignalQuality[i];
}
mutexDevices.Unlock();
if ((signalStrength != lastSigStr) || (signalQuality != lastSigQual)) {
changed = true;
break;
}
@ -356,7 +371,10 @@ bool cViewHelpers::SetDevices(bool initial, bool light, intmap *intTokens, vecto
if (cRecordControl *RecordControl = cRecordControls::GetRecordControl(timer)) {
const cDevice *recDevice = RecordControl->Device();
if (recDevice) {
mutexDevices.Lock();
if (recDevices)
recDevices[recDevice->DeviceNumber()] = true;
mutexDevices.Unlock();
}
}
}
@ -399,7 +417,12 @@ bool cViewHelpers::SetDevices(bool initial, bool light, intmap *intTokens, vecto
deviceVals.insert(pair< string, string >("devices[signalquality]", strQuality.str()));
deviceVals.insert(pair< string, string >("devices[livetv]", i == deviceLiveTV ? "1" : "0"));
deviceVals.insert(pair< string, string >("devices[recording]", recDevices[i] ? "1" : "0"));
string isRecording = "0";
mutexDevices.Lock();
if (recDevices && recDevices[i])
isRecording = "1";
mutexDevices.Unlock();
deviceVals.insert(pair< string, string >("devices[recording]", isRecording));
const cChannel *channel = device->GetCurrentlyTunedTransponder();
const cSource *source = (channel) ? Sources.Get(channel->Source()) : NULL;

View File

@ -9,6 +9,7 @@ typedef pair<string,string> stringpair;
class cViewHelpers {
private:
cMutex mutexDevices;
int numDevices;
bool devicesInit;
int* lastSignalStrength;