Ticket #1133: 1133-v1.patch

File 1133-v1.patch, 34.4 KB (added by danielk, 15 years ago)

Start of support for different tuner types on each input

  • libs/libmythtv/recordingprofile.h

     
    7575    RecordingProfile(QString profName = NULL);
    7676    virtual void loadByID(int id);
    7777    virtual bool loadByCard(QString name, int cardid);
     78    virtual bool loadByType(QString name, QString cardtype);
    7879    virtual bool loadByGroup(QString name, QString group);
    7980    virtual int exec();
    8081
  • libs/libmythtv/NuppelVideoPlayer.cpp

     
    24432443
    24442444        if ((!paused || eof) && livetvchain)
    24452445        {
     2446            cerr<<".";
    24462447            if (livetvchain->NeedsToSwitch())
    24472448                SwitchToProgram();
    24482449            else if (livetvchain->NeedsToJump())
  • libs/libmythtv/tv_play.cpp

     
    2828#include "jobqueue.h"
    2929#include "audiooutput.h"
    3030#include "DisplayRes.h"
    31 #include "signalmonitor.h"
     31#include "signalmonitorvalue.h"
    3232#include "scheduledrecording.h"
    3333#include "config.h"
    3434#include "livetvchain.h"
     
    10331033    stateLock.unlock();
    10341034}
    10351035
    1036 uint TV::GetLockTimeout(uint cardid)
    1037 {
    1038     uint timeout = 0xffffffff;
    1039     MSqlQuery query(MSqlQuery::InitCon());
    1040     query.prepare("SELECT channel_timeout, cardtype "
    1041                   "FROM capturecard "
    1042                   "WHERE cardid = :CARDID");
    1043     query.bindValue(":CARDID", cardid);
    1044     if (!query.exec() || !query.isActive())
    1045         MythContext::DBError("Getting timeout", query);
    1046     else if (query.next() &&
    1047              SignalMonitor::IsSupported(query.value(1).toString()))
    1048         timeout = max(query.value(0).toInt(), 500);
    1049 
    1050     VERBOSE(VB_PLAYBACK, LOC + QString("GetLockTimeout(%1): "
    1051                                        "Set lock timeout to %2 ms")
    1052             .arg(cardid).arg(timeout));
    1053 
    1054     return timeout;
    1055 }
    1056 
    10571036/** \fn TV::StartRecorder(RemoteEncoder*, int)
    10581037 *  \brief Starts recorder, must be called before StartPlayer().
    10591038 *  \param maxWait How long to wait for RecorderBase to start recording.
     
    10771056    VERBOSE(VB_PLAYBACK, LOC + "StartRecorder(): took "<<t.elapsed()
    10781057            <<" ms to start recorder.");
    10791058
    1080     // Get timeout for this recorder
    1081     lockTimeout[rec->GetRecorderNumber()] =
    1082         GetLockTimeout(rec->GetRecorderNumber());
    1083 
    10841059    // Cache starting frame rate for this recorder
    10851060    if (rec == recorder)
    10861061        frameRate = recorder->GetFrameRate();
     
    34653440
    34663441    // Pause the backend recorder, send command, and then unpause..
    34673442    PauseLiveTV();
    3468     activerecorder->ToggleInputs();
     3443    lockTimerOn = false;
     3444    QString inputname = activerecorder->SetInput("SwitchToNextInput");
    34693445    UnpauseLiveTV();
    34703446
    34713447    // If activenvp is main nvp, show new input in on screen display
    34723448    if (nvp && activenvp == nvp)
    3473         UpdateOSDInput();
     3449        UpdateOSDInput(inputname);
    34743450}
    34753451
    34763452void TV::ToggleChannelFavorite(void)
     
    40254001    update_osd_pos = true;
    40264002}
    40274003
    4028 void TV::UpdateOSDInput(void)
     4004void TV::UpdateOSDInput(QString inputname)
    40294005{
     4006    QString displayName = QString::null;
     4007
    40304008    if (!activerecorder || !tvchain)
    40314009        return;
    40324010
    4033     QString name = tvchain->GetInputName(-1);
    4034     QString displayName = "";
    4035     QString msg;
     4011    int cardid = activerecorder->GetRecorderNumber();
    40364012
     4013    if (inputname.isEmpty())
     4014        inputname = tvchain->GetInputName(-1);
     4015
     4016    // Try to get display name
    40374017    MSqlQuery query(MSqlQuery::InitCon());
    4038     query.prepare("SELECT displayname FROM cardinput "
    4039                   "WHERE cardid = :CARDID AND inputname = :INPUTNAME");
    4040     query.bindValue(":CARDID", activerecorder->GetRecorderNumber());
    4041     query.bindValue(":INPUTNAME", name);
    4042     query.exec();
    4043     if (query.isActive() && query.size() > 0)
    4044     {
    4045         query.next();
     4018    query.prepare("SELECT displayname "
     4019                  "FROM cardinput "
     4020                  "WHERE inputname = :INPUTNAME AND "
     4021                  "      cardid    = :CARDID");
     4022    query.bindValue(":CARDID",    cardid);
     4023    query.bindValue(":INPUTNAME", inputname);
     4024    if (query.exec() && query.isActive() && query.size() && query.next())
    40464025        displayName = query.value(0).toString();
    4047     }
    40484026
    4049     if ( displayName == "")
    4050         msg = QString("%1: %2")
    4051                 .arg(activerecorder->GetRecorderNumber()).arg(name);
    4052     else
    4053         msg = displayName;
     4027    // If a display name doesn't exist use cardid and inputname
     4028    if (displayName.isEmpty())
     4029        displayName = QString("%1: %2").arg(cardid).arg(inputname);
    40544030
    40554031    if (GetOSD())
    4056         GetOSD()->SetSettingsText(msg, 3);
     4032        GetOSD()->SetSettingsText(displayName, 3);
    40574033}
    40584034
    40594035/** \fn TV::UpdateOSDSignal(const QStringList&)
     
    41794155    bool timed_out = false;
    41804156    if (activerecorder)
    41814157    {
    4182         uint timeout = lockTimeout[activerecorder->GetRecorderNumber()];
     4158        QString input = activerecorder->GetInput();
     4159        uint timeout  = activerecorder->GetSignalLockTimeout(input);
    41834160        timed_out = lockTimerOn && ((uint)lockTimer.elapsed() > timeout);
    41844161    }
    41854162    OSD *osd = GetOSD();
     
    60195996    osdlock.unlock();
    60205997
    60215998    lockTimerOn = false;
    6022     uint timeout = lockTimeout[activerecorder->GetRecorderNumber()];
     5999
     6000    QString input = activerecorder->GetInput();
     6001    uint timeout = activerecorder->GetSignalLockTimeout(input);
    60236002    if (timeout < 0xffffffff)
    60246003    {
    60256004        lockTimer.start();
  • libs/libmythtv/remoteencoder.h

     
    3939    void CancelNextRecording(bool cancel);
    4040
    4141    void SetLiveRecording(bool recording);
    42     void ToggleInputs(void);
     42    QStringList GetInputs(void);
     43    QString GetInput(void);
     44    QString SetInput(QString);
    4345    int ChangeContrast(bool direction);
    4446    int ChangeBrightness(bool direction);
    4547    int ChangeColour(bool direction);
     
    4850    void ChangeDeinterlacer(int deint_mode);
    4951    void ToggleChannelFavorite(void);
    5052    void SetChannel(QString channel);
    51     int SetSignalMonitoringRate(int msec, bool notifyFrontend = true);
     53    int  SetSignalMonitoringRate(int msec, bool notifyFrontend = true);
     54    uint GetSignalLockTimeout(QString input);
    5255    bool CheckChannel(QString channel);
    5356    bool ShouldSwitchToAnotherCard(QString channelid);
    5457    bool CheckChannelPrefix(const QString&,uint&,bool&,QString&);
  • libs/libmythtv/dvbchannel.cpp

     
    176176                .arg(it.key()).arg(*it)
    177177                .arg(inputChannel[it.key()]));
    178178    }
    179     currentcapchannel = nextcapchannel = GetNextInput();
     179    currentcapchannel = nextcapchannel = GetNextInputNum();
    180180    VERBOSE(VB_CHANNEL, LOC + QString("Current Input #%1: '%2'")
    181181            .arg(GetCurrentInputNum()).arg(GetCurrentInput()));
    182182}
     
    326326bool DVBChannel::SwitchToInput(int newcapchannel, bool setstarting)
    327327{
    328328    (void)setstarting;
    329     if(inputChannel[newcapchannel] != "")
    330      {
     329    if (!inputChannel[newcapchannel].isEmpty())
     330    {
    331331        nextcapchannel = newcapchannel;
    332332        return SetChannelByString(inputChannel[newcapchannel]);
    333333    }
  • libs/libmythtv/tv_play.h

     
    186186    bool RequestNextRecorder(bool showDialogs);
    187187    void DeleteRecorder();
    188188
    189     static uint GetLockTimeout(uint cardid);
    190189    bool StartRecorder(RemoteEncoder *rec, int maxWait=-1);
    191190    bool StartPlayer(bool isWatchingRecording, int maxWait=-1);
    192191    void StartOSD(void);
     
    269268    void ToggleOSD(bool includeStatusOSD);
    270269    void UpdateOSDProgInfo(const char *whichInfo);
    271270    void UpdateOSDSeekMessage(const QString &mesg, int disptime);
    272     void UpdateOSDInput(void);
     271    void UpdateOSDInput(QString inputname = QString::null);
    273272    void UpdateOSDTextEntry(const QString &message);
    274273    void UpdateOSDSignal(const QStringList& strlist);
    275274    void UpdateOSDTimeoutMessage(void);
     
    434433    // Channel changing timeout notification variables
    435434    QTime   lockTimer;
    436435    bool    lockTimerOn;
    437     QMap<uint,uint> lockTimeout;
    438436
    439437    // Previous channel functionality state variables
    440438    str_vec_t prevChan;       ///< Previous channels
  • libs/libmythtv/remoteencoder.cpp

     
    88#include "programinfo.h"
    99#include "util.h"
    1010#include "mythcontext.h"
     11#include "signalmonitor.h"
    1112
    1213RemoteEncoder::RemoteEncoder(int num, const QString &host, short port)
    1314    : recordernum(num),       controlSock(NULL),      remotehost(host),
     
    313314    SendReceiveStringList(strlist);
    314315}
    315316
    316 void RemoteEncoder::ToggleInputs(void)
     317QStringList RemoteEncoder::GetInputs(void)
    317318{
    318319    QStringList strlist = QString("QUERY_RECORDER %1").arg(recordernum);
    319     strlist << "TOGGLE_INPUTS";
     320    strlist << "GET_INPUTS";
    320321
    321322    SendReceiveStringList(strlist);
    322323
     324    return strlist;
     325}
     326
     327QString RemoteEncoder::GetInput(void)
     328{
     329    QStringList strlist = QString("QUERY_RECORDER %1").arg(recordernum);
     330    strlist << "GET_INPUT";
     331
     332    SendReceiveStringList(strlist);
     333
     334    return strlist[0];
     335}
     336
     337QString RemoteEncoder::SetInput(QString input)
     338{
     339    QStringList strlist = QString("QUERY_RECORDER %1").arg(recordernum);
     340    strlist << "SET_INPUT";
     341    strlist << input;
     342
     343    SendReceiveStringList(strlist);
     344
    323345    lastchannel = "";
     346
     347    return strlist[0];
    324348}
    325349
    326350void RemoteEncoder::ToggleChannelFavorite(void)
     
    382406    return retval;
    383407}
    384408
     409uint RemoteEncoder::GetSignalLockTimeout(QString input)
     410{
     411    uint cardid  = recordernum;
     412    uint timeout = 0xffffffff;
     413    MSqlQuery query(MSqlQuery::InitCon());
     414    query.prepare("SELECT channel_timeout, cardtype "
     415                  "FROM capturecard "
     416                  "WHERE cardid = :CARDID");
     417    query.bindValue(":CARDID", cardid);
     418    if (!query.exec() || !query.isActive())
     419        MythContext::DBError("Getting timeout", query);
     420    else if (query.next() &&
     421             SignalMonitor::IsSupported(query.value(1).toString()))
     422        timeout = max(query.value(0).toInt(), 500);
     423
     424    VERBOSE(VB_PLAYBACK, "RemoteEncoder: " +
     425            QString("GetSignalLockTimeout(%1): Set lock timeout to %2 ms")
     426            .arg(cardid).arg(timeout));
     427
     428    return timeout;
     429}
     430
    385431/** \fn RemoteEncoder::ChangeContrast(bool)
    386432 *  \brief Changes contrast of a recording.
    387433 *
  • libs/libmythtv/dbcheck.cpp

     
    19901990            return false;
    19911991    }
    19921992
     1993    if (dbver == "1122")
     1994    {
     1995        const QString updates[] = {
     1996"ALTER TABLE cardinput ADD COLUMN inputtype VARCHAR(20) NOT NULL DEFAULT '';",
     1997"ALTER TABLE cardinput ADD COLUMN inputdev VARCHAR(128) NOT NULL DEFAULT '';",
     1998""
     1999};
     2000        if (!performActualUpdate(updates, "1123", dbver))
     2001            return false;
     2002    }
     2003
    19932004// Drop xvmc_buffer_settings table in 0.20
    19942005// Drop dvb_dmx_buf_size and dvb_pkt_buf_size columns of channel in 0.20
    19952006
  • libs/libmythtv/livetvchain.cpp

     
    460460 */
    461461void LiveTVChain::SwitchToNext(bool up)
    462462{
    463     //VERBOSE(VB_PLAYBACK, LOC + "SwitchToNext("<<(up?"up":"down")<<")");
     463    VERBOSE(VB_PLAYBACK, LOC + "SwitchToNext("<<(up?"up":"down")<<")");
    464464    if (up && HasNext())
    465465        SwitchTo(m_curpos + 1);
    466466    else if (!up && HasPrev())
     
    475475
    476476void LiveTVChain::JumpToNext(bool up, int pos)
    477477{
     478    VERBOSE(VB_PLAYBACK, LOC + "JumpToNext("<<(up?"up":"down")
     479            <<", "<<pos<<")");
    478480    m_jumppos = pos;
    479481    SwitchToNext(up);
    480482}
  • libs/libmythtv/tv_rec.cpp

     
    132132{
    133133}
    134134
    135 /** \fn TVRec::Init()
    136  *  \brief Performs instance initialization, returns true on success.
    137  *
    138  *  \return Returns true on success, false on failure.
    139  */
    140 bool TVRec::Init(void)
     135bool TVRec::CreateChannel(void)
    141136{
    142     QMutexLocker lock(&stateChangeLock);
    143 
    144     bool ok = GetDevices(cardid, genOpt, dvbOpt, fwOpt, dboxOpt);
    145 
    146     if (!ok)
    147         return false;
    148 
    149137    QString startchannel = GetStartChannel(cardid, genOpt.defaultinput);
    150 
    151138    bool init_run = false;
    152139    if (genOpt.cardtype == "DVB")
    153140    {
    154141#ifdef USING_DVB_EIT
    155         scanner = new EITScanner();
     142        if (!scanner)
     143            scanner = new EITScanner();
    156144#endif // USING_DVB_EIT
    157145
    158146#ifdef USING_DVB
     
    203191            rbFileExt = "nuv";
    204192    }
    205193
    206     if (!init_run)
    207     {
    208         QString msg = QString(
    209             "%1 card configured on video device %2, \n"
    210             "but MythTV was not compiled with %2 support. \n"
    211             "\n"
    212             "Recompile MythTV with %3 support or remove the card \n"
    213             "from the configuration and restart MythTV.")
    214             .arg(genOpt.cardtype).arg(genOpt.videodev)
    215             .arg(genOpt.cardtype).arg(genOpt.cardtype);
    216         VERBOSE(VB_IMPORTANT, LOC_ERR + msg);
    217         SetFlags(kFlagErrored);
     194    if (init_run)
     195        return true;
     196
     197    QString msg = QString(
     198        "%1 card configured on video device %2, \n"
     199        "but MythTV was not compiled with %2 support. \n"
     200        "\n"
     201        "Recompile MythTV with %3 support or remove the card \n"
     202        "from the configuration and restart MythTV.")
     203        .arg(genOpt.cardtype).arg(genOpt.videodev)
     204        .arg(genOpt.cardtype).arg(genOpt.cardtype);
     205
     206    VERBOSE(VB_IMPORTANT, LOC_ERR + msg);
     207
     208    SetFlags(kFlagErrored);
     209
     210    return false;
     211}
     212
     213/** \fn TVRec::Init(void)
     214 *  \brief Performs instance initialization, returns true on success.
     215 *
     216 *  \return Returns true on success, false on failure.
     217 */
     218bool TVRec::Init(void)
     219{
     220    QMutexLocker lock(&stateChangeLock);
     221
     222    if (!GetDevices(cardid, genOpt, dvbOpt, fwOpt, dboxOpt) || !CreateChannel())
    218223        return false;
    219     }
    220224
     225    origGenOpt = genOpt;
     226
    221227    transcodeFirst    =
    222228        gContext->GetNumSetting("AutoTranscodeBeforeAutoCommflag", 0);
    223229    earlyCommFlag     = gContext->GetNumSetting("AutoCommflagWhileRecording", 0);
     
    16501656
    16511657    if (SignalMonitor::IsSupported(genOpt.cardtype) && channel->Open())
    16521658    {
    1653         // TODO reset the tuner hardware
    1654         //channel->SwitchToInput(channel->GetCurrentInputNum(), true);
    1655 
    16561659        signalMonitor = SignalMonitor::Init(genOpt.cardtype, cardid, channel);
    16571660    }
    16581661   
     
    29792982    return ret;
    29802983}
    29812984
     2985/** \fn TVRec::GetConnectedInputs(void) const
     2986 *  \brief Returns TVRec's recorders connected inputs.
     2987 */
     2988QStringList TVRec::GetConnectedInputs(void) const
     2989{
     2990    QStringList list;
     2991    if (channel)
     2992        list = channel->GetConnectedInputs();
     2993    return list;
     2994}
     2995
     2996/** \fn TVRec::GetInput(void) const
     2997 *  \brief Returns current input.
     2998 */
     2999QString TVRec::GetInput(void) const
     3000{
     3001    if (channel)
     3002        return channel->GetCurrentInput();
     3003    return QString::null;
     3004}
     3005
     3006/** \fn TVRec::SetInput(QString)
     3007 *  \brief Changes to the specified input.
     3008 *
     3009 *   You must call PauseRecorder(void) before calling this.
     3010 *
     3011 *  \param input Input to switch to, or "SwitchToNectInput".
     3012 *  \return input we have switched to
     3013 */
     3014QString TVRec::SetInput(QString input, uint requestType)
     3015{
     3016    QMutexLocker lock(&stateChangeLock);
     3017    QString origIn = input;
     3018    VERBOSE(VB_RECORD, LOC + "SetInput("<<input<<") -- begin");
     3019
     3020    if (!channel)
     3021    {
     3022        VERBOSE(VB_RECORD, LOC + "SetInput() -- end  no channel class");
     3023        return QString::null;
     3024    }
     3025
     3026    input = (input == "SwitchToNextInput") ? channel->GetNextInput() : input;
     3027
     3028    if (input == channel->GetCurrentInput())
     3029    {
     3030        VERBOSE(VB_RECORD, LOC + "SetInput("<<origIn<<":"<<input
     3031                <<") -- end  nothing to do");
     3032        return input;
     3033    }
     3034
     3035    QString name = channel->GetNextInputStartChan();
     3036   
     3037    // Detect tuning request type if needed
     3038    if (requestType & kFlagDetect)
     3039    {
     3040        WaitForEventThreadSleep();
     3041        requestType = lastTuningRequest.flags & (kFlagRec | kFlagNoRec);
     3042    }
     3043
     3044    // Clear the RingBuffer reset flag, in case we wait for a reset below
     3045    ClearFlags(kFlagRingBufferReady);
     3046
     3047    // Actually add the tuning request to the queue, and
     3048    // then wait for it to start tuning
     3049    tuningRequests.enqueue(TuningRequest(requestType, name, input));
     3050    WaitForEventThreadSleep();
     3051
     3052    // If we are using a recorder, wait for a RingBuffer reset
     3053    if (requestType & kFlagRec)
     3054    {
     3055        while (!HasFlags(kFlagRingBufferReady))
     3056            WaitForEventThreadSleep();
     3057    }
     3058    VERBOSE(VB_RECORD, LOC + "SetInput("<<origIn<<":"<<input<<") -- end");
     3059
     3060    return GetInput();
     3061}
     3062
    29823063/** \fn TVRec::SetChannel(QString,uint)
    29833064 *  \brief Changes to a named channel on the current tuner.
    29843065 *
     
    31903271{
    31913272    if (tuningRequests.size())
    31923273    {
     3274        VERBOSE(VB_RECORD, LOC + "Request: " + tuningRequests[0].toString());
    31933275        const TuningRequest *request = &tuningRequests.front();
    3194         VERBOSE(VB_RECORD, LOC + "Request: "<<request->toString());
    31953276        TuningShutdowns(*request);
    31963277
    31973278        // Now we start new stuff
     
    32563337 */
    32573338void TVRec::TuningShutdowns(const TuningRequest &request)
    32583339{
     3340    QString curType(""), curDev(""), newType(""), newDev("");
     3341    if (channel && !request.input.isEmpty())
     3342    {
     3343        QString current_input = channel->GetCurrentInput();
     3344        curType = channel->GetInputType(current_input, curDev);
     3345        curType = curType.isEmpty() ? origGenOpt.cardtype : curType;
     3346        curDev  = curDev.isEmpty()  ? origGenOpt.videodev : curDev;
     3347       
     3348        newType = channel->GetInputType(request.input, newDev);
     3349        newType = newType.isEmpty() ? origGenOpt.cardtype : newType;
     3350        newDev  = newDev.isEmpty()  ? origGenOpt.videodev : newDev;
     3351    }
     3352
     3353    VERBOSE(VB_IMPORTANT, LOC + "Tuner Type: <"<<curType<<":"<<newType<<">");
     3354    VERBOSE(VB_IMPORTANT, LOC + "Tuner Dev:  <"<<curDev <<":"<<newDev <<">");
     3355
     3356    bool force_teardown = false;
     3357    if (curType != newType)
     3358    {
     3359        // TODO handle total shutdown...
     3360        force_teardown = true;
     3361    }
     3362
    32593363#ifdef USING_DVB_EIT
    32603364    if (!(request.flags & kFlagEITScan) && HasFlags(kFlagEITScannerRunning))
    32613365    {
     
    32843388
    32853389    // At this point any waits are canceled.
    32863390
    3287     if ((request.flags & kFlagNoRec))
     3391    if ((request.flags & kFlagNoRec) || force_teardown)
    32883392    {
    32893393        if (HasFlags(kFlagDummyRecorderRunning))
    32903394        {
     
    33093413        CloseChannel();
    33103414        // At this point the channel is shut down
    33113415    }
     3416   
     3417    if (force_teardown)
     3418    {
     3419        VERBOSE(VB_IMPORTANT, "Recreating channel...");
     3420        channel->Close();
     3421        delete channel;
     3422        channel = NULL;
     3423        genOpt.cardtype     = newType;
     3424        genOpt.videodev     = newDev;
     3425        genOpt.defaultinput = request.input;
     3426        CreateChannel();
    33123427
     3428        if (!(request.flags & kFlagNoRec))
     3429            channel->Open();
     3430    }
     3431
    33133432    if (ringBuffer && (request.flags & kFlagKillRingBuffer))
    33143433    {
    33153434        VERBOSE(VB_RECORD, LOC + "Tearing down RingBuffer");
     
    33713490
    33723491        if (!input.isEmpty())
    33733492            ok = channel->SwitchToInput(input, channum);
    3374         else if (channum.find("ToggleInputs") >= 0)
    3375             ok = channel->ToggleInputs();
    33763493        else
    33773494            ok = channel->SetChannelByString(channum);
    33783495    }
     
    35433660    return true;
    35443661}
    35453662
    3546 static void load_recording_profile(
    3547     RecordingProfile &profile, ProgramInfo *rec, int cardid)
    3548 {
    3549     QString profileName = "Live TV";
    3550     bool done = false;
    3551 
    3552     if (rec)
    3553     {
    3554         profileName = rec->GetScheduledRecording()->getProfileName();
    3555         if (!profileName.isEmpty())
    3556             done = profile.loadByCard(profileName, cardid);
    3557         profileName = (done) ? profileName : QString("Default");
    3558     }
    3559 
    3560     if (!done)
    3561         profile.loadByCard(profileName, cardid);
    3562 
    3563     QString msg = QString("Using profile '%1' to record").arg(profileName);
    3564     VERBOSE(VB_RECORD, LOC + msg);
    3565 }
    3566 
    35673663static int init_jobs(const ProgramInfo *rec, RecordingProfile &profile,
    35683664                      bool on_host, bool transcode_bfr_comm, bool on_line_comm)
    35693665{
     
    36223718        had_dummyrec = true;
    36233719    }
    36243720
     3721    ProgramInfo *rec = lastTuningRequest.program;   
     3722    QString profileName = (tvchain) ? QString("Live TV") :
     3723        rec->GetScheduledRecording()->getProfileName();
     3724
    36253725    RecordingProfile profile;
    3626     ProgramInfo *rec = lastTuningRequest.program;
    3627     load_recording_profile(profile, rec, cardid);
     3726    if (!profile.loadByType(profileName, genOpt.cardtype))
     3727    {
     3728        profileName = "Default";
     3729        profile.loadByType(profileName, genOpt.cardtype);
     3730    }
     3731
     3732    VERBOSE(VB_RECORD, LOC + QString("Using profile '%1' to record")
     3733            .arg(profileName));
     3734
    36283735    if (tvchain)
    36293736    {
    36303737        bool ok;
     
    36343741            SetFlags(kFlagRingBufferReady);
    36353742        }
    36363743        else
    3637             ok = SwitchLiveTVRingBuffer(true, !had_dummyrec);
     3744            ok = SwitchLiveTVRingBuffer(true, !had_dummyrec && recorder);
    36383745        if (!ok)
    36393746        {
    36403747            VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed to create RingBuffer 2");
     
    37253832    if (GetV4LChannel())
    37263833        channel->SetFd(recorder->GetVideoFd());
    37273834
    3728     SetFlags(kFlagRecorderRunning);
     3835    SetFlags(kFlagRecorderRunning | kFlagRingBufferReady);
    37293836
    37303837    if (!tvchain)
    37313838        autoRunJobs = init_jobs(rec, profile, runJobOnHostOnly,
     
    39114018        }
    39124019    }
    39134020    if (kFlagRingBufferReady & f)
    3914         msg += "RingBufferReset,";
     4021        msg += "RingBufferReady,";
    39154022
    39164023    if (msg.isEmpty())
    39174024        msg = QString("0x%1").arg(f,0,16);
  • libs/libmythtv/recordingprofile.cpp

     
    905905    return false;
    906906}
    907907
     908bool RecordingProfile::loadByType(QString name, QString cardtype)
     909{
     910    QString hostname = gContext->GetHostName();
     911    int recid = 0;
     912
     913    MSqlQuery result(MSqlQuery::InitCon());
     914    result.prepare(
     915        "SELECT recordingprofiles.id, profilegroups.hostname, "
     916        "       profilegroups.is_default "
     917        "FROM recordingprofiles, profilegroups, capturecard "
     918        "WHERE profilegroups.id       = recordingprofiles.profilegroup AND "
     919        "      profilegroups.cardtype = :CARDTYPE                      AND "
     920        "      recordingprofiles.name = :NAME");
     921    result.bindValue(":CARDTYPE", cardtype);
     922    result.bindValue(":NAME", name);
     923
     924    if (result.exec() && result.isActive() && result.size() > 0)
     925    {
     926        while (result.next())
     927        {
     928            if (result.value(1).toString() == hostname)
     929            {
     930                recid = result.value(0).toInt();
     931                break;
     932            }
     933            else if (result.value(2).toInt() == 1)
     934                recid = result.value(0).toInt();
     935        }
     936    }
     937    if (recid)
     938    {
     939        loadByID(recid);
     940        return true;
     941    }
     942    return false;
     943}
     944
    908945bool RecordingProfile::loadByGroup(QString name, QString group)
    909946{
    910947    MSqlQuery result(MSqlQuery::InitCon());
  • libs/libmythtv/channelbase.h

     
    3838    virtual bool Open(void) = 0;
    3939    /// \brief Closes the channel changing hardware to use.
    4040    virtual void Close(void) = 0;
    41     /// \brief Switches to another input on hardware,
    42     ///        and sets the channel is setstarting is true.
    43     virtual bool SwitchToInput(int newcapchannel, bool setstarting) = 0;
    4441    virtual bool SetChannelByString(const QString &chan) = 0;
    4542    /// \brief Reports whether channel is already open
    4643    virtual bool IsOpen(void) const = 0;
     
    6057        { return currentcapchannel; }
    6158    virtual QString GetCurrentInput(void) const
    6259        { return channelnames[GetCurrentInputNum()]; }
     60    virtual int GetNextInputNum(void) const;
     61    virtual QString GetNextInput(void) const
     62        { return channelnames[GetNextInputNum()]; }
     63    virtual QString GetNextInputStartChan(void)
     64        { return inputChannel[GetNextInputNum()]; }
     65    virtual QString GetInputType(const QString&, QString&) const;
    6366    virtual QString GetOrdering(void) const
    6467        { return channelorder; }
     68    virtual QStringList GetConnectedInputs(void) const;
    6569    /// \brief Returns true iff commercial detection is not required
    6670    //         on current channel, for BBC, CBC, etc.
    6771    bool IsCommercialFree(void) const { return commfree; }
     
    7680    virtual bool SetChannelByDirection(ChannelChangeDirection);
    7781
    7882    // Input toggling convenience methods
    79     virtual bool ToggleInputs(void);
    8083    virtual bool SwitchToInput(const QString &input);
    8184    virtual bool SwitchToInput(const QString &input, const QString &chan);
    8285
     
    115118    void StoreInputChannels(const QMap<int, QString> &inputChannel);
    116119
    117120  protected:
    118     int GetNextInput(void) const;
     121    /// \brief Switches to another input on hardware,
     122    ///        and sets the channel is setstarting is true.
     123    virtual bool SwitchToInput(int newcapchannel, bool setstarting) = 0;
     124
    119125    virtual int GetCardID(void) const;
    120126    virtual bool ChangeExternalChannel(const QString &newchan);
    121127    virtual void SetCachedATSCInfo(const QString &chan);
  • libs/libmythtv/osd.cpp

     
    18961896    char name[128];
    18971897    sprintf(name, "%lld-%d", number, type);
    18981898
    1899     int xpos = (int)((editarrowRect.width() * 1.0 / totalframes) * number);
    1900     xpos = (editarrowRect.left() + xpos) * wmult;
    1901     int ypos = editarrowRect.top() * hmult;
     1899    int xtmp = (int)((editarrowRect.width() * 1.0 / totalframes) * number);
     1900    int xpos = (int) round((editarrowRect.left() + xtmp) * wmult);
     1901    int ypos = (int) round(editarrowRect.top() * hmult);
    19021902
    19031903    osdlock.lock();
    19041904
  • libs/libmythtv/tv_rec.h

     
    187187    void ToggleChannelFavorite(void);
    188188
    189189    void SetLiveRecording(int recording);
    190     /// Toggles between inputs on current capture card.
    191     void ToggleInputs(void)     { SetChannel("ToggleInputs"); }
     190
     191    QStringList GetConnectedInputs(void) const;
     192    QString     GetInput(void) const;
     193    QString     SetInput(QString input, uint requestType = kFlagDetect);
     194
    192195    /// Changes to a channel in the 'dir' channel change direction.
    193196    void ChangeChannel(ChannelChangeDirection dir)
    194197        { SetChannel(QString("NextChannel %1").arg((int)dir)); }
     
    249252    HDTVRecorder *GetHDTVRecorder(void);
    250253    DVBRecorder  *GetDVBRecorder(void);
    251254   
     255    bool CreateChannel(void);
    252256    void InitChannel(const QString &inputname, const QString &startchannel);
    253257    void CloseChannel(void);
    254258    DBox2Channel *GetDBox2Channel(void);
     
    323327    bool              ispip;
    324328
    325329    // Configuration variables from database, based on cardid
    326     GeneralDBOptions  genOpt;
     330    GeneralDBOptions  genOpt, origGenOpt;
    327331    DVBDBOptions      dvbOpt;
    328332    FireWireDBOptions fwOpt;
    329333    DBox2DBOptions    dboxOpt;
  • libs/libmythtv/channelbase.cpp

     
    5252    return fTune;
    5353}
    5454
    55 int ChannelBase::GetNextInput(void) const
     55int ChannelBase::GetNextInputNum(void) const
    5656{
    5757    QMap<int, QString>::const_iterator it;
    5858    it = channelnames.find(currentcapchannel);
     
    8080    return (i<100) ? it.key() : -1;
    8181}
    8282
    83 bool ChannelBase::ToggleInputs(void)
     83QStringList ChannelBase::GetConnectedInputs(void) const
    8484{
    85     int nextInput = GetNextInput();
    86     if (nextInput >= 0 && (nextInput != currentcapchannel))
    87         return SwitchToInput(nextInput, true);
    88     return true;
     85    QStringList list;
     86
     87    QMap<int, QString>::const_iterator it = channelnames.begin();
     88    for (; it != channelnames.end(); ++it)
     89        if (!inputTuneTo[it.key()].isEmpty())
     90            list.push_back(it.data());
     91
     92    return list;
    8993}
    9094
    9195QString ChannelBase::GetInputByNum(int capchannel) const
     
    139143    return ok;
    140144}
    141145
     146QString ChannelBase::GetInputType(const QString &inputname,
     147                                    QString &inputdevice) const
     148{
     149    QString inputformat = QString::null;
     150
     151    MSqlQuery query(MSqlQuery::InitCon());
     152    query.prepare(
     153        "SELECT inputtype, inputdev "
     154        "FROM cardinput "
     155        "WHERE cardid    = :CARDID    AND "
     156        "      inputname = :INPUTNAME");
     157    query.bindValue(":CARDID",    GetCardID());
     158    query.bindValue(":INPUTNAME", inputname);
     159
     160    if (!query.exec() || !query.isActive())
     161    {
     162        MythContext::DBError("GetInputFormat", query);
     163    }
     164    else if (query.next())
     165    {
     166        inputformat = query.value(0).toString();
     167        inputdevice = query.value(1).toString();
     168    }
     169
     170    return inputformat;
     171}
     172
    142173bool ChannelBase::ChangeExternalChannel(const QString &channum)
    143174{
    144175    if (externalChanger[currentcapchannel].isEmpty())
  • libs/libmythtv/channel.cpp

     
    276276
    277277    int inputNum = currentcapchannel;
    278278    if (currentcapchannel < 0)
    279         inputNum = GetNextInput();
     279        inputNum = GetNextInputNum();
    280280
    281281    QString fmt = format;
    282282    if ((fmt == "Default") || format.isEmpty())
  • programs/mythbackend/encoderlink.h

     
    7676    void StopLiveTV(void);
    7777    void PauseRecorder(void);
    7878    void SetLiveRecording(int);
    79     void ToggleInputs(void);
     79    QStringList GetConnectedInputs(void) const;
     80    QString GetInput(void) const;
     81    QString SetInput(QString);
    8082    void ToggleChannelFavorite(void);
    8183    void ChangeChannel(int channeldirection);
    8284    void SetChannel(const QString &name);
  • programs/mythbackend/mainserver.cpp

     
    24732473        enc->SetLiveRecording(recording);
    24742474        retlist << "ok";
    24752475    }
    2476     else if (command == "TOGGLE_INPUTS")
     2476    else if (command == "GET_CONNECTED_INPUTS")
    24772477    {
    2478         enc->ToggleInputs();
    2479         retlist << "ok";
     2478        QStringList ret = enc->GetConnectedInputs();
     2479        if (ret.empty())
     2480            retlist << "EMPTY_LIST";
     2481        else
     2482            retlist += ret;
    24802483    }
     2484    else if (command == "GET_INPUT")
     2485    {
     2486        QString ret = enc->GetInput();
     2487        ret = (ret.isEmpty()) ? "UNKNOWN" : ret;
     2488        retlist << ret;
     2489    }
     2490    else if (command == "SET_INPUT")
     2491    {
     2492        QString input = slist[2];
     2493        QString ret   = enc->SetInput(input);
     2494        ret = (ret.isEmpty()) ? "UNKNOWN" : ret;
     2495        retlist << ret;
     2496    }
    24812497    else if (command == "TOGGLE_CHANNEL_FAVORITE")
    24822498    {
    24832499        enc->ToggleChannelFavorite();
  • programs/mythbackend/encoderlink.cpp

     
    654654        VERBOSE(VB_IMPORTANT, "Should be local only query: SetLiveRecording");
    655655}
    656656
    657 /** \fn EncoderLink::ToggleInputs(void)
    658  *  \brief Tells TVRec's recorder to change to the next input.
     657/** \fn EncoderLink::GetConnectedInputs(void) const
     658 *  \brief Returns TVRec's recorders connected inputs.
    659659 *         <b>This only works on local recorders.</b>
    660660 *
    661  *   You must call PauseRecorder(void) before calling this.
     661 *  \sa TVRec::GetConnectedInputs(void) const
    662662 */
    663 void EncoderLink::ToggleInputs(void)
     663QStringList EncoderLink::GetConnectedInputs(void) const
    664664{
     665    QStringList list;
     666
    665667    if (local)
    666         tv->ToggleInputs();
     668        list = tv->GetConnectedInputs();
    667669    else
    668         VERBOSE(VB_IMPORTANT, "Should be local only query: ToggleInputs");
     670        VERBOSE(VB_IMPORTANT, "Should be local only query: GetConnectedInputs");
     671
     672    return list;
    669673}
    670674
     675/** \fn EncoderLink::GetInput(void) const
     676 *  \brief Returns TVRec's recorders current input.
     677 *         <b>This only works on local recorders.</b>
     678 *
     679 *  \sa TVRec::GetInput(void) const
     680 */
     681QString EncoderLink::GetInput(void) const
     682{
     683    if (local)
     684        return tv->GetInput();
     685
     686    VERBOSE(VB_IMPORTANT, "Should be local only query: GetInput");
     687    return QString::null;
     688}
     689
     690/** \fn EncoderLink::SetInput(QString)
     691 *  \brief Tells TVRec's recorder to change to the specified input.
     692 *         <b>This only works on local recorders.</b>
     693 *
     694 *   You must call PauseRecorder(void) before calling this.
     695 *
     696 *  \param input Input to switch to, or "SwitchToNectInput".
     697 *  \return input we have switched to
     698 *  \sa TVRec::SetInput(QString)
     699 */
     700QString EncoderLink::SetInput(QString input)
     701{
     702    if (local)
     703        return tv->SetInput(input);
     704
     705    VERBOSE(VB_IMPORTANT, "Should be local only query: SetInput");
     706    return QString::null;
     707}
     708
    671709/** \fn EncoderLink::ToggleChannelFavorite(void)
    672710 *  \brief Toggles whether the current channel should be on our favorites list.
    673711 *         <b>This only works on local recorders.</b>