MythTV  0.26-pre
backendutil.cpp
Go to the documentation of this file.
00001 #include <cstdlib> // for llabs
00002 
00003 #include "mythconfig.h"
00004 #if CONFIG_DARWIN || defined(__FreeBSD__)
00005 #include <sys/param.h>
00006 #include <sys/mount.h>
00007 #elif __linux__
00008 #include <sys/vfs.h>
00009 #endif
00010 
00011 #include <QMutex>
00012 #include <QFile>
00013 #include <QMap>
00014 
00015 #include "backendutil.h"
00016 #include "programinfo.h"
00017 
00018 QMutex recordingPathLock;
00019 QMap <QString, QString> recordingPathCache;
00020 
00021 QString GetPlaybackURL(ProgramInfo *pginfo, bool storePath)
00022 {
00023     QString result = "";
00024     QMutexLocker locker(&recordingPathLock);
00025     QString cacheKey = QString("%1:%2").arg(pginfo->GetChanID())
00026         .arg(pginfo->GetRecordingStartTime(ISODate));
00027     if ((recordingPathCache.contains(cacheKey)) &&
00028         (QFile::exists(recordingPathCache[cacheKey])))
00029     {
00030         result = recordingPathCache[cacheKey];
00031         if (!storePath)
00032             recordingPathCache.remove(cacheKey);
00033     }
00034     else
00035     {
00036         locker.unlock();
00037         result = pginfo->GetPlaybackURL(false, true);
00038         locker.relock();
00039         if (storePath && result.left(1) == "/")
00040             recordingPathCache[cacheKey] = result;
00041     }
00042 
00043     return result;
00044 }
00045 
00046 /* vim: set expandtab tabstop=4 shiftwidth=4: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends