summaryrefslogtreecommitdiff
path: root/videodir.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 /videodir.c
parent8a7bc6a0bbf60cae8b6391a630880aad5cba3363 (diff)
downloadvdr-3cd5294d8a337ee5cd2ec894c9fbe04ad3a7690d.tar.gz
vdr-3cd5294d8a337ee5cd2ec894c9fbe04ad3a7690d.tar.bz2
Implemented strict locking of global lists
Diffstat (limited to 'videodir.c')
-rw-r--r--videodir.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/videodir.c b/videodir.c
index 932f8ce3..b2257fa6 100644
--- a/videodir.c
+++ b/videodir.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: videodir.c 3.4 2013/10/11 09:38:07 kls Exp $
+ * $Id: videodir.c 4.1 2015/08/11 13:39:59 kls Exp $
*/
#include "videodir.h"
@@ -19,24 +19,31 @@
#include "recording.h"
#include "tools.h"
+cMutex cVideoDirectory::mutex;
cString cVideoDirectory::name;
cVideoDirectory *cVideoDirectory::current = NULL;
cVideoDirectory::cVideoDirectory(void)
{
+ mutex.Lock();
delete current;
current = this;
+ mutex.Unlock();
}
cVideoDirectory::~cVideoDirectory()
{
+ mutex.Lock();
current = NULL;
+ mutex.Unlock();
}
cVideoDirectory *cVideoDirectory::Current(void)
{
+ mutex.Lock();
if (!current)
- current = new cVideoDirectory;
+ new cVideoDirectory;
+ mutex.Unlock();
return current;
}
@@ -141,7 +148,8 @@ int cVideoDirectory::VideoDiskSpace(int *FreeMB, int *UsedMB)
{
int used = 0;
int free = Current()->FreeMB(&used);
- int deleted = DeletedRecordings.TotalFileSizeMB();
+ LOCK_DELETEDRECORDINGS_READ;
+ int deleted = DeletedRecordings->TotalFileSizeMB();
if (deleted > used)
deleted = used; // let's not get beyond 100%
free += deleted;
@@ -202,7 +210,8 @@ bool cVideoDiskUsage::HasChanged(int &State)
if (FreeMB != freeMB) {
usedPercent = UsedPercent;
freeMB = FreeMB;
- double MBperMinute = Recordings.MBperMinute();
+ LOCK_RECORDINGS_READ;
+ double MBperMinute = Recordings->MBperMinute();
if (MBperMinute <= 0)
MBperMinute = MB_PER_MINUTE;
freeMinutes = int(double(FreeMB) / MBperMinute);