Ticket #8962: 8962_0.27_v2.patch

File 8962_0.27_v2.patch, 8.1 KB (added by Jim Stichnoth, 4 years ago)

Add fixes from master

  • mythtv/libs/libmythtv/jobqueue.cpp

    diff --git a/mythtv/libs/libmythtv/jobqueue.cpp b/mythtv/libs/libmythtv/jobqueue.cpp
    index f426309..ff79a47 100644
    a b int JobQueue::GetRunningJobID(uint chanid, const QDateTime &recstartts) 
    10621062    return 0;
    10631063}
    10641064
    1065 bool JobQueue::IsJobRunning(int jobType,
    1066                             uint chanid, const QDateTime &recstartts)
     1065bool JobQueue::IsJobStatusQueued(int status)
    10671066{
    1068     int tmpStatus = GetJobStatus(jobType, chanid, recstartts);
     1067    return (status == JOB_QUEUED);
     1068}
    10691069
    1070     if ((tmpStatus != JOB_UNKNOWN) && (tmpStatus != JOB_QUEUED) &&
    1071         (!(tmpStatus & JOB_DONE)))
    1072         return true;
     1070bool JobQueue::IsJobStatusRunning(int status)
     1071{
     1072    return ((status != JOB_UNKNOWN) && (status != JOB_QUEUED) &&
     1073            (!(status & JOB_DONE)));
     1074}
    10731075
    1074     return false;
     1076bool JobQueue::IsJobRunning(int jobType,
     1077                            uint chanid, const QDateTime &recstartts)
     1078{
     1079    return IsJobStatusRunning(GetJobStatus(jobType, chanid, recstartts));
    10751080}
    10761081
    10771082bool JobQueue::IsJobRunning(int jobType, const ProgramInfo &pginfo)
    bool JobQueue::IsJobQueuedOrRunning( 
    10941099bool JobQueue::IsJobQueued(
    10951100    int jobType, uint chanid, const QDateTime &recstartts)
    10961101{
    1097     int tmpStatus = GetJobStatus(jobType, chanid, recstartts);
    1098 
    1099     if (tmpStatus & JOB_QUEUED)
    1100         return true;
    1101 
    1102     return false;
     1102    return IsJobStatusQueued(GetJobStatus(jobType, chanid, recstartts));
    11031103}
    11041104
    11051105QString JobQueue::JobText(int jobType)
  • mythtv/libs/libmythtv/jobqueue.h

    diff --git a/mythtv/libs/libmythtv/jobqueue.h b/mythtv/libs/libmythtv/jobqueue.h
    index e799912..ee7dcaa 100644
    a b class MTV_PUBLIC JobQueue : public QObject, public QRunnable 
    161161    static bool IsJobRunning(int jobType, const ProgramInfo &pginfo);
    162162    static bool IsJobQueued(int jobType,
    163163                            uint chanid, const QDateTime &recstartts);
     164    static bool IsJobStatusQueued(int status);
     165    static bool IsJobStatusRunning(int status);
    164166    static bool PauseJob(int jobID);
    165167    static bool ResumeJob(int jobID);
    166168    static bool RestartJob(int jobID);
  • mythtv/programs/mythfrontend/playbackbox.cpp

    diff --git a/mythtv/programs/mythfrontend/playbackbox.cpp b/mythtv/programs/mythfrontend/playbackbox.cpp
    index d01293f..18ba2ac 100644
    a b static QString extract_main_state(const ProgramInfo &pginfo, const TV *player) 
    280280    return state;
    281281}
    282282
    283 static QString extract_job_state(const ProgramInfo &pginfo)
     283QString PlaybackBox::extract_job_state(const ProgramInfo &pginfo)
    284284{
    285285    QString job = "default";
    286286
    287287    if (pginfo.GetRecordingStatus() == rsRecording)
    288288        job = "recording";
    289     else if (JobQueue::IsJobQueuedOrRunning(
     289    else if (m_jobQueue.IsJobQueuedOrRunning(
    290290                 JOB_TRANSCODE, pginfo.GetChanID(),
    291291                 pginfo.GetRecordingStartTime()))
    292292        job = "transcoding";
    293     else if (JobQueue::IsJobQueuedOrRunning(
     293    else if (m_jobQueue.IsJobQueuedOrRunning(
    294294                 JOB_COMMFLAG,  pginfo.GetChanID(),
    295295                 pginfo.GetRecordingStartTime()))
    296296        job = "commflagging";
    static QString extract_job_state(const ProgramInfo &pginfo) 
    298298    return job;
    299299}
    300300
    301 static QString extract_commflag_state(const ProgramInfo &pginfo)
     301QString PlaybackBox::extract_commflag_state(const ProgramInfo &pginfo)
    302302{
    303303    QString job = "default";
    304304
    305305    // commflagged can be yes, no or processing
    306     if (JobQueue::IsJobRunning(JOB_COMMFLAG, pginfo))
     306    if (m_jobQueue.IsJobRunning(JOB_COMMFLAG, pginfo.GetChanID(),
     307                                pginfo.GetRecordingStartTime()))
    307308        return "running";
    308     if (JobQueue::IsJobQueued(JOB_COMMFLAG, pginfo.GetChanID(),
    309                               pginfo.GetRecordingStartTime()))
     309    if (m_jobQueue.IsJobQueued(JOB_COMMFLAG, pginfo.GetChanID(),
     310                               pginfo.GetRecordingStartTime()))
    310311        return "queued";
    311312
    312313    return (pginfo.GetProgramFlags() & FL_COMMFLAG ? "yes" : "no");
    void HelpPopup::addItem(const QString &state, const QString &text) 
    55355536    item->DisplayState(state, "icons");
    55365537}
    55375538
     5539void PlaybackBox::PbbJobQueue::Update()
     5540{
     5541    QDateTime now = QDateTime::currentDateTime();
     5542    if (!m_lastUpdated.isValid() ||
     5543        m_lastUpdated.msecsTo(now) >= kInvalidateTimeMs)
     5544    {
     5545        QMap<int, JobQueueEntry> jobs;
     5546        JobQueue::GetJobsInQueue(jobs, JOB_LIST_ALL);
     5547        m_jobs.clear();
     5548        for (int i = 0; i < jobs.size(); ++i)
     5549        {
     5550            JobQueueEntry &entry = jobs[i];
     5551            m_jobs.insert(qMakePair(entry.chanid, entry.recstartts), entry);
     5552        }
     5553        m_lastUpdated = now;
     5554    }
     5555}
     5556
     5557bool PlaybackBox::PbbJobQueue::IsJobQueued(int jobType, uint chanid,
     5558                                           const QDateTime &recstartts)
     5559{
     5560    Update();
     5561    QList<JobQueueEntry> values = m_jobs.values(qMakePair(chanid, recstartts));
     5562    QList<JobQueueEntry>::const_iterator iter, end = values.end();
     5563    for (iter = values.begin(); iter != end; ++iter)
     5564    {
     5565        if (iter->type == jobType)
     5566            return JobQueue::IsJobStatusQueued(iter->status);
     5567    }
     5568    return false;
     5569}
     5570
     5571bool PlaybackBox::PbbJobQueue::IsJobRunning(int jobType, uint chanid,
     5572                                            const QDateTime &recstartts)
     5573{
     5574    Update();
     5575    QList<JobQueueEntry> values = m_jobs.values(qMakePair(chanid, recstartts));
     5576    QList<JobQueueEntry>::const_iterator iter, end = values.end();
     5577    for (iter = values.begin(); iter != end; ++iter)
     5578    {
     5579        if (iter->type == jobType)
     5580            return JobQueue::IsJobStatusRunning(iter->status);
     5581    }
     5582    return false;
     5583}
     5584
     5585bool PlaybackBox::PbbJobQueue::IsJobQueuedOrRunning(int jobType, uint chanid,
     5586                                                    const QDateTime &recstartts)
     5587{
     5588    return IsJobQueued(jobType, chanid, recstartts) ||
     5589        IsJobRunning(jobType, chanid, recstartts);
     5590}
     5591
    55385592/* vim: set expandtab tabstop=4 shiftwidth=4: */
  • mythtv/programs/mythfrontend/playbackbox.h

    diff --git a/mythtv/programs/mythfrontend/playbackbox.h b/mythtv/programs/mythfrontend/playbackbox.h
    index 836c433..444ab75 100644
    a b using namespace std; 
    1313
    1414#include <QStringList>
    1515#include <QDateTime>
     16#include <QMultiMap>
    1617#include <QObject>
    1718#include <QMutex>
    1819#include <QMap>
    class PlaybackBox : public ScheduleCommon 
    336337
    337338    QString CreateProgramInfoString(const ProgramInfo &program) const;
    338339
     340    QString extract_job_state(const ProgramInfo &pginfo);
     341    QString extract_commflag_state(const ProgramInfo &pginfo);
     342
    339343
    340344    QRegExp m_prefixes;   ///< prefixes to be ignored when sorting
    341345    QRegExp m_titleChaff; ///< stuff to remove for search rules
    class PlaybackBox : public ScheduleCommon 
    444448    bool                m_usingGroupSelector;
    445449    bool                m_groupSelected;
    446450    bool                m_passwordEntered;
     451
     452    // This class caches the contents of the jobqueue table to avoid excessive
     453    // DB queries each time the PBB selection changes (currently 4 queries per
     454    // displayed item).  The cache remains valid for 15 seconds
     455    // (kInvalidateTimeMs).
     456    class PbbJobQueue
     457    {
     458    public:
     459        PbbJobQueue() { Update(); }
     460        bool IsJobQueued(int jobType, uint chanid,
     461                         const QDateTime &recstartts);
     462        bool IsJobRunning(int jobType, uint chanid,
     463                          const QDateTime &recstartts);
     464        bool IsJobQueuedOrRunning(int jobType, uint chanid,
     465                                  const QDateTime &recstartts);
     466    private:
     467        static const qint64 kInvalidateTimeMs = 15000;
     468        void Update();
     469        QDateTime m_lastUpdated;
     470        // Maps <chanid, recstartts> to a set of JobQueueEntry values.
     471        typedef QMultiMap<QPair<uint, QDateTime>, JobQueueEntry> MapType;
     472        MapType m_jobs;
     473    } m_jobQueue;
    447474};
    448475
    449476class GroupSelector : public MythScreenType