summaryrefslogtreecommitdiff
path: root/device.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2015-09-01 11:14:27 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2015-09-01 11:14:27 +0200
commit3cd5294d8a337ee5cd2ec894c9fbe04ad3a7690d (patch)
treeda57ce74189de9bfb27e1a747063c37cd62de501 /device.c
parent8a7bc6a0bbf60cae8b6391a630880aad5cba3363 (diff)
downloadvdr-3cd5294d8a337ee5cd2ec894c9fbe04ad3a7690d.tar.gz
vdr-3cd5294d8a337ee5cd2ec894c9fbe04ad3a7690d.tar.bz2
Implemented strict locking of global lists
Diffstat (limited to 'device.c')
-rw-r--r--device.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/device.c b/device.c
index 14ab07d3..6ae9d5ac 100644
--- a/device.c
+++ b/device.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: device.c 3.20 2015/01/30 12:11:30 kls Exp $
+ * $Id: device.c 4.1 2015/08/29 12:41:08 kls Exp $
*/
#include "device.h"
@@ -722,20 +722,21 @@ bool cDevice::SwitchChannel(int Direction)
cControl::Shutdown(); // prevents old channel from being shown too long if GetDevice() takes longer
int n = CurrentChannel() + Direction;
int first = n;
- cChannel *channel;
- while ((channel = Channels.GetByNumber(n, Direction)) != NULL) {
+ LOCK_CHANNELS_READ;
+ const cChannel *Channel;
+ while ((Channel = Channels->GetByNumber(n, Direction)) != NULL) {
// try only channels which are currently available
- if (GetDevice(channel, LIVEPRIORITY, true, true))
+ if (GetDevice(Channel, LIVEPRIORITY, true, true))
break;
- n = channel->Number() + Direction;
+ n = Channel->Number() + Direction;
}
- if (channel) {
+ if (Channel) {
int d = n - first;
if (abs(d) == 1)
dsyslog("skipped channel %d", first);
else if (d)
dsyslog("skipped channels %d..%d", first, n - sgn(d));
- if (PrimaryDevice()->SwitchChannel(channel, true))
+ if (PrimaryDevice()->SwitchChannel(Channel, true))
result = true;
}
else if (n != first)
@@ -777,7 +778,6 @@ eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView)
Result = scrNotAvailable;
}
else {
- Channels.Lock(false);
// Stop section handling:
if (sectionHandler) {
sectionHandler->SetStatus(false);
@@ -790,7 +790,8 @@ eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView)
if (SetChannelDevice(Channel, LiveView)) {
// Start section handling:
if (sectionHandler) {
- patFilter->Trigger(Channel->Sid());
+ if (patFilter)
+ patFilter->Trigger(Channel->Sid());
sectionHandler->SetChannel(Channel);
sectionHandler->SetStatus(true);
}
@@ -800,7 +801,6 @@ eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView)
}
else
Result = scrFailed;
- Channels.Unlock();
}
if (Result == scrOk) {
@@ -829,8 +829,8 @@ eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView)
void cDevice::ForceTransferMode(void)
{
if (!cTransferControl::ReceiverDevice()) {
- cChannel *Channel = Channels.GetByNumber(CurrentChannel());
- if (Channel)
+ LOCK_CHANNELS_READ;
+ if (const cChannel *Channel = Channels->GetByNumber(CurrentChannel()))
SetChannelDevice(Channel, false); // this implicitly starts Transfer Mode
}
}