Ticket #3326: 3326-inputgroupbug-v1.patch

File 3326-inputgroupbug-v1.patch, 9.8 KB (added by danielk, 16 years ago)

Possible bug for a bug where recordings sharing an input group are canceled when they shouldn't (untested!)

  • libs/libmythtv/libmythtv.pro

     
    347347    # Channel stuff
    348348    HEADERS += channelbase.h               dtvchannel.h
    349349    HEADERS += signalmonitor.h             dtvsignalmonitor.h
    350     HEADERS += inputinfo.h
     350    HEADERS += inputinfo.h                 inputgroupmap.h
    351351    SOURCES += channelbase.cpp             dtvchannel.h
    352352    SOURCES += signalmonitor.cpp           dtvsignalmonitor.cpp
    353     SOURCES += inputinfo.cpp
     353    SOURCES += inputinfo.cpp               inputgroupmap.cpp
    354354
    355355    # Channel scanner stuff
    356356    HEADERS += scanwizard.h                scanwizardhelpers.h
  • libs/libmythtv/tv_rec.cpp

     
    574574            TunedInputInfo busy_input;
    575575            bool is_busy = RemoteIsBusy(cardids[i], busy_input);
    576576
     577            // if the other recorder is busy, but the input is
     578            // not in a shared input group, then as far as we're
     579            // concerned here it isn't busy.
     580            if (is_busy)
     581            {
     582                is_busy = (bool) igrp.GetSharedInputGroup(
     583                    busy_input.inputid, rcinfo->inputid);
     584            }
     585
    577586            if (is_busy && !mplexid)
    578587            {
    579588                mplexid  = (*it).info->GetMplexID();
  • libs/libmythtv/inputgroupmap.cpp

     
     1// -*- Mode: c++ -*-
     2/*
     3 *   Copyright (c) Daniel Kristjansson 2007
     4 *
     5 *   This program is free software; you can redistribute it and/or modify
     6 *   it under the terms of the GNU General Public License as published by
     7 *   the Free Software Foundation; either version 2 of the License, or
     8 *   (at your option) any later version.
     9 *
     10 *   This program is distributed in the hope that it will be useful,
     11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 *   GNU General Public License for more details.
     14 *
     15 *   You should have received a copy of the GNU General Public License
     16 *   along with this program; if not, write to the Free Software
     17 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     18 */
     19
     20#include "inputgroupmap.h"
     21#include "mythdbcon.h"
     22
     23bool InputGroupMap::Build(void)
     24{
     25    bool ok = true;
     26    inputgroupmap.clear();
     27    MSqlQuery query(MSqlQuery::InitCon());
     28
     29    query.prepare("SELECT cardinputid, inputgroupid from inputgroup");
     30    if (!query.exec())
     31    {
     32        MythContext::DBError("InputGroupMap::Build 1", query);
     33        ok = false;
     34    }
     35    else
     36    {
     37        while (query.next())
     38        {
     39            uint inputid = query.value(0).toUInt();
     40            uint groupid = query.value(1).toUInt();
     41            inputgroupmap[inputid].push_back(groupid);
     42        }
     43    }
     44
     45    query.prepare("SELECT cardinputid, cardid from cardinput");
     46    if (!query.exec())
     47    {
     48        MythContext::DBError("InputGroupMap::Build 2", query);
     49        ok = false;
     50    }
     51    else
     52    {
     53        while (query.next())
     54        {
     55            uint inputid = query.value(0).toUInt();
     56            uint groupid = query.value(1).toUInt() + 1000;
     57            if (inputgroupmap[inputid].empty())
     58                inputgroupmap[inputid].push_back(groupid);
     59        }
     60    }
     61
     62    return ok;
     63}
     64
     65uint InputGroupMap::GetSharedInputGroup(uint inputid1, uint inputid2) const
     66{
     67    const InputGroupList &input1 = inputgroupmap[inputid1];
     68    const InputGroupList &input2 = inputgroupmap[inputid2];
     69    if (input1.empty() || input2.empty())
     70        return 0;
     71
     72    InputGroupList::const_iterator it;
     73    for (it = input1.begin(); it != input1.end(); ++it)
     74    {
     75        if (find(input2.begin(), input2.end(), *it) != input2.end())
     76            return *it;
     77    }
     78
     79    return 0;
     80}
  • libs/libmythtv/tv_rec.h

     
    1111#include <qwaitcondition.h>
    1212
    1313#include "inputinfo.h"
     14#include "inputgroupmap.h"
    1415#include "mythdeque.h"
    1516#include "programinfo.h"
    1617#include "tv.h"
     
    347348    int     overRecordSecNrml;
    348349    int     overRecordSecCat;
    349350    QString overRecordCategory;
     351    InputGroupMap igrp;
    350352
    351353    // Configuration variables from setup routines
    352354    int               cardid;
  • libs/libmythtv/inputgroupmap.h

     
     1// -*- Mode: c++ -*-
     2#ifndef _INPUTGROUPMAP_H_
     3#define _INPUTGROUPMAP_H_
     4
     5// C++ headers
     6#include <vector>
     7using namespace std;
     8
     9// Qt headers
     10#include <qmap.h>
     11
     12typedef vector<uint> InputGroupList;
     13
     14class InputGroupMap
     15{
     16  public:
     17    InputGroupMap() { Build(); }
     18
     19    bool Build(void);
     20    uint GetSharedInputGroup(uint input1, uint input2) const;
     21
     22  private:
     23    QMap<uint, InputGroupList> inputgroupmap;
     24};
     25
     26#endif // _INPUTGROUPMAP_H_
  • programs/mythbackend/scheduler.h

     
    1616#include "scheduledrecording.h"
    1717#include "programinfo.h"
    1818#include "remoteutil.h"
     19#include "inputgroupmap.h"
    1920
    2021class EncoderLink;
    2122class MainServer;
     
    3435typedef RecList::const_iterator RecConstIter;
    3536typedef RecList::iterator RecIter;
    3637
    37 typedef vector<int> InputGroupList;
    38 
    3938class Scheduler : public QObject
    4039{
    4140  public:
     
    130129    int FillRecordingDir(ProgramInfo *pginfo, RecList& reclist);
    131130    void FillDirectoryInfoCache(bool force = false);
    132131
    133     void BuildInputGroupMap(void);
    134     int  GetSharedInputGroup(int, int) const;
    135 
    136132    QValueList<int> reschedQueue;
    137133    QMutex reschedLock;
    138134    QMutex recordmatchLock;
     
    143139    QMap<int, RecList> cardlistmap;
    144140    QMap<int, RecList> recordidlistmap;
    145141    QMap<QString, RecList> titlelistmap;
    146     QMap<int, InputGroupList> inputgroupmap;
     142    InputGroupMap igrp;
    147143
    148144    QMutex *reclist_lock;
    149145    bool reclist_changed;
  • programs/mythbackend/scheduler.cpp

     
    300300    schedMoveHigher = (bool)gContext->GetNumSetting("SchedMoveHigher");
    301301    schedTime = QDateTime::currentDateTime();
    302302
    303     BuildInputGroupMap();
    304 
    305303    VERBOSE(VB_SCHEDULE, "BuildWorkList...");
    306304    BuildWorkList();
    307305    VERBOSE(VB_SCHEDULE, "AddNewRecords...");
     
    815813            cout << QString("\n  comparing with '%1' ").arg(q->title);
    816814
    817815        if (p->cardid != 0 && (p->cardid != q->cardid) &&
    818             !GetSharedInputGroup(p->inputid, q->inputid))
     816            !igrp.GetSharedInputGroup(p->inputid, q->inputid))
    819817        {
    820818            if (is_conflict_dbg)
    821819                cout << "  cardid== ";
     
    845843            cout << "\n" <<
    846844                QString("  cardid's: %1, %2 ").arg(p->cardid).arg(q->cardid) +
    847845                QString("Shared input group: %1 ")
    848                 .arg(GetSharedInputGroup(p->inputid, q->inputid)) +
     846                .arg(igrp.GetSharedInputGroup(p->inputid, q->inputid)) +
    849847                QString("mplexid's: %1, %2")
    850848                .arg(p->GetMplexID()).arg(q->GetMplexID());
    851849
    852850        // if two inputs are in the same input group we have a conflict
    853851        // unless the programs are on the same multiplex.
    854852        if (p->cardid && (p->cardid != q->cardid) &&
    855             GetSharedInputGroup(p->inputid, q->inputid) &&
     853            igrp.GetSharedInputGroup(p->inputid, q->inputid) &&
    856854            p->GetMplexID() && (p->GetMplexID() == q->GetMplexID()))
    857855        {
    858856            continue;
     
    33653363    fsInfoCacheFillTime = QDateTime::currentDateTime();
    33663364}
    33673365
    3368 void Scheduler::BuildInputGroupMap(void)
    3369 {
    3370     inputgroupmap.clear();
    3371     MSqlQuery query(dbConn);
    3372 
    3373     query.prepare("SELECT cardinputid, inputgroupid from inputgroup");
    3374     if (!query.exec())
    3375     {
    3376         MythContext::DBError("BuildInputGroupMap 1", query);
    3377     }
    3378     else
    3379     {
    3380         while (query.next())
    3381         {
    3382             int inputid = query.value(0).toUInt();
    3383             int groupid = query.value(1).toUInt();
    3384             inputgroupmap[inputid].push_back(groupid);
    3385         }
    3386     }
    3387 
    3388     query.prepare("SELECT cardinputid, cardid from cardinput");
    3389     if (!query.exec())
    3390     {
    3391         MythContext::DBError("BuildInputGroupMap 2", query);
    3392     }
    3393     else
    3394     {
    3395         while (query.next())
    3396         {
    3397             int inputid = query.value(0).toUInt();
    3398             int groupid = query.value(1).toUInt() + 1000;
    3399             if (inputgroupmap[inputid].empty())
    3400                 inputgroupmap[inputid].push_back(groupid);
    3401         }
    3402     }
    3403 }
    3404 
    3405 int Scheduler::GetSharedInputGroup(int inputid1, int inputid2) const
    3406 {
    3407     const InputGroupList &input1 = inputgroupmap[inputid1];
    3408     const InputGroupList &input2 = inputgroupmap[inputid2];
    3409     if (input1.empty() || input2.empty())
    3410         return 0;
    3411 
    3412     InputGroupList::const_iterator it;
    3413     for (it = input1.begin(); it != input1.end(); ++it)
    3414     {
    3415         if (find(input2.begin(), input2.end(), *it) != input2.end())
    3416             return *it;
    3417     }
    3418 
    3419     return 0;
    3420 }
    3421 
    34223366void Scheduler::SchedPreserveLiveTV(void)
    34233367{
    34243368    if (!livetvTime.isValid())