forked from FernetMenta/vdr-plugin-vnsiserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecordingscache.c
69 lines (57 loc) · 1.9 KB
/
recordingscache.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
/*
* vdr-plugin-vnsi - XBMC server plugin for VDR
*
* Copyright (C) 2011 Alexander Pipelka
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#include "config.h"
#include "recordingscache.h"
#include "hash.h"
cRecordingsCache::cRecordingsCache() {
}
cRecordingsCache::~cRecordingsCache() {
}
cRecordingsCache& cRecordingsCache::GetInstance() {
static cRecordingsCache singleton;
return singleton;
}
uint32_t cRecordingsCache::Register(cRecording* recording) {
cString filename = recording->FileName();
uint32_t uid = CreateStringHash(filename);
m_mutex.Lock();
if(m_recordings.find(uid) == m_recordings.end())
{
DEBUGLOG("%s - uid: %08x '%s'", __FUNCTION__, uid, (const char*)filename);
m_recordings[uid] = filename;
}
m_mutex.Unlock();
return uid;
}
cRecording* cRecordingsCache::Lookup(uint32_t uid) {
DEBUGLOG("%s - lookup uid: %08x", __FUNCTION__, uid);
if(m_recordings.find(uid) == m_recordings.end()) {
DEBUGLOG("%s - not found !", __FUNCTION__);
return NULL;
}
m_mutex.Lock();
cString filename = m_recordings[uid];
DEBUGLOG("%s - filename: %s", __FUNCTION__, (const char*)filename);
cRecording* r = Recordings.GetByName(filename);
DEBUGLOG("%s - recording %s", __FUNCTION__, (r == NULL) ? "not found !" : "found");
m_mutex.Unlock();
return r;
}