Ticket #13: tune2startchannel.0.patch

File tune2startchannel.0.patch, 7.3 KB (added by stuarta@…, 14 years ago)

Patch to tune the backend to an on-air channel

  • libs/libmythtv/firewirechannel.cpp

     
    8989
    9090}
    9191   
    92 void FirewireChannel::SwitchToInput(const QString &input, const QString &chan)
     92bool FirewireChannel::SwitchToInput(const QString &input, const QString &chan)
    9393{
    9494    currentcapchannel = 0;
    9595    if (channelnames.empty())
    9696       channelnames[currentcapchannel] = input;
    9797
    98     SetChannelByString(chan);
     98    return SetChannelByString(chan);
    9999}
    100100
    101101void FirewireChannel::SetExternalChanger(void) {
  • libs/libmythtv/dvbchannel.h

     
    5353    QString     GetSIStandard()    const { return chan_opts.sistandard; }
    5454
    5555    // Commands
    56     void SwitchToInput(const QString &inputname, const QString &chan);
     56    bool SwitchToInput(const QString &inputname, const QString &chan);
    5757    void SwitchToInput(int newcapchannel, bool setstarting)
    5858        { (void)newcapchannel; (void)setstarting; }
    5959    bool Tune(dvb_channel_t& channel, bool all=false);
  • libs/libmythtv/dvbchannel.cpp

     
    232232    }
    233233    curchannelname = chan;
    234234
    235     GENERAL(QString("Successfully tuned to channel %1.").arg(chan));
    236 
    237235    if (!chan_opts.pmt.OnAir())
    238236    {
    239237        ERROR(QString("Channel #%1 is off air.").arg(chan));
    240238        return false;
    241239    }
    242240
     241    GENERAL(QString("Successfully tuned to channel %1.").arg(chan));
     242
    243243    inputChannel[currentcapchannel] = curchannelname;
    244244
    245245#if (DVB_API_VERSION_MINOR == 1)
     
    257257        emit ChannelChanged(chan_opts);
    258258}
    259259
    260 void DVBChannel::SwitchToInput(const QString &input, const QString &chan)
     260bool DVBChannel::SwitchToInput(const QString &input, const QString &chan)
    261261{
    262262    currentcapchannel = 0;
    263263    if (channelnames.empty())
    264264       channelnames[currentcapchannel] = input;
    265265
    266     SetChannelByString(chan);
     266    return SetChannelByString(chan);
    267267}
    268268
    269269/** \fn DVBChannel::GetChannelOptions(const QString&)
  • libs/libmythtv/firewirechannel.h

     
    4343        { return QString("%1:%2").arg(fw_opts.port).arg(fw_opts.node); }
    4444
    4545    // Commands
    46     void SwitchToInput(const QString &inputname, const QString &chan);
     46    bool SwitchToInput(const QString &inputname, const QString &chan);
    4747    void SwitchToInput(int newcapchannel, bool setstarting)
    4848        { (void)newcapchannel; (void)setstarting; }
    4949
  • libs/libmythtv/tv_rec.cpp

     
    129129{
    130130    QString chanorder = gContext->GetSetting("ChannelOrdering", "channum + 0");
    131131    QString inputname, startchannel;
     132    bool tuneSuccess;
    132133
    133134    GetDevices(m_capturecardnum, videodev, vbidev,
    134135               audiodev, audiosamplerate,
     
    145146        pthread_create(&scanner_thread, NULL, ScannerThread, scanner);
    146147
    147148        if (inputname.isEmpty())
    148             channel->SetChannelByString(startchannel);
     149            tuneSuccess=channel->SetChannelByString(startchannel);
    149150        else
    150             channel->SwitchToInput(inputname, startchannel);
     151            tuneSuccess=channel->SwitchToInput(inputname, startchannel);
     152
     153        if (!tuneSuccess)
     154        {
     155            startchannel=gContext->GetSetting("DefaultTVChannel");
     156            if (inputname.isEmpty())
     157                tuneSuccess=channel->SetChannelByString(startchannel);
     158            else
     159                tuneSuccess=channel->SwitchToInput(inputname, startchannel);
     160        }
     161       
     162        if (!tuneSuccess)
     163            VERBOSE(VB_IMPORTANT,"Utter failuer to tune to a channel");
     164       
    151165        channel->SetChannelOrdering(chanorder);
    152166        // don't close this channel, otherwise we cannot read data
    153167        if (dvb_options.dvb_on_demand)
     
    10401054
    10411055    if (channel)
    10421056    {
    1043         channel->SwitchToInput(inputname, chanstr);
     1057        if (!channel->SwitchToInput(inputname, chanstr))
     1058            VERBOSE(VB_IMPORTANT,"TVRec::SetChannel() Failed SwitchToInput()");
     1059
    10441060        if (needopen)
    10451061            channel->Close();
    10461062    }
     
    28432859    }
    28442860
    28452861}
    2846 
  • libs/libmythtv/channelbase.h

     
    7676    // Input toggling convenience methods
    7777    virtual void ToggleInputs(void);
    7878    virtual void SwitchToInput(const QString &input);
    79     virtual void SwitchToInput(const QString &input, const QString &chan);
     79    virtual bool SwitchToInput(const QString &input, const QString &chan);
    8080
    8181    /// Saves current channel as the default channel for the current input.
    8282    virtual void StoreInputChannels(void);
  • libs/libmythtv/channelbase.cpp

     
    9090                                      "%1 on card\n").arg(inputname));
    9191}
    9292
    93 void ChannelBase::SwitchToInput(const QString &inputname, const QString &chan)
     93bool ChannelBase::SwitchToInput(const QString &inputname, const QString &chan)
    9494{
    9595    int input = GetInputByName(inputname);
    9696
    9797    if (input >= 0)
    9898    {
    9999        SwitchToInput(input, false);
    100         SetChannelByString(chan);
     100        return SetChannelByString(chan);
    101101    }
    102102    else
     103    {
    103104        VERBOSE(VB_IMPORTANT,
    104105                QString("ChannelBase: Could not find input: %1 on card when "
    105106                        "setting channel %2\n").arg(inputname).arg(chan));
     107        return false;
     108    }
    106109}
    107110
    108111bool ChannelBase::ChangeExternalChannel(const QString &channum)
  • libs/libmythtv/channel.cpp

     
    407407    // and return, since the act of changing inputs will change the channel as well.
    408408    if (!inputName.isEmpty())
    409409    {
    410         ChannelBase::SwitchToInput(inputName, chan);
    411         SetCachedATSCInfo(chan);
    412         return true;
     410        if(ChannelBase::SwitchToInput(inputName, chan))
     411        {
     412            SetCachedATSCInfo(chan);
     413            return true;
     414        }
     415        else return false;
    413416    }
    414417
    415418    MSqlQuery query(MSqlQuery::InitCon());
     
    616619        TuneTo(inputTuneTo[currentcapchannel], 0);
    617620
    618621    if (setstarting && !inputChannel[currentcapchannel].isEmpty())
    619         SetChannelByString(inputChannel[currentcapchannel]);
     622        if (!SetChannelByString(inputChannel[currentcapchannel]))
     623            VERBOSE(VB_IMPORTANT,"Channel::SwitchToInput() FAILED");
    620624}
    621625
    622626unsigned short *Channel::GetV4L1Field(int attrib, struct video_picture &vid_pic)
     
    915919{
    916920    return ChangeColourAttribute(V4L2_CID_HUE, "hue", up);
    917921}
    918