Ticket #6881: hdhr-cleanup.patch

File hdhr-cleanup.patch, 12.5 KB (added by mikeb@…, 10 years ago)

remove obsolete functions

  • libs/libmythtv/hdhrsignalmonitor.cpp

    diff -Nur -x .svn mythtv/libs/libmythtv/hdhrsignalmonitor.cpp mythtv.new/libs/libmythtv/hdhrsignalmonitor.cpp
    old new  
    4040HDHRSignalMonitor::HDHRSignalMonitor(
    4141    int db_cardnum, HDHRChannel* _channel, uint64_t _flags) :
    4242    DTVSignalMonitor(db_cardnum, _channel, _flags),
    43     streamHandlerStarted(false), streamHandler(NULL)
     43    _stream_handler_started(false), _stream_handler(NULL)
    4444{
    4545    VERBOSE(VB_CHANNEL, LOC + "ctor");
    4646
     
    4848
    4949    AddFlags(kSigMon_WaitForSig);
    5050
    51     streamHandler = HDHRStreamHandler::Get(_channel->GetDevice());
     51    _stream_handler = HDHRStreamHandler::Get(_channel->GetDevice());
    5252}
    5353
    5454/** \fn HDHRSignalMonitor::~HDHRSignalMonitor()
     
    5858{
    5959    VERBOSE(VB_CHANNEL, LOC + "dtor");
    6060    Stop();
    61     HDHRStreamHandler::Return(streamHandler);
     61    HDHRStreamHandler::Return(_stream_handler);
    6262}
    6363
    6464/** \fn HDHRSignalMonitor::Stop(void)
     
    6969    VERBOSE(VB_CHANNEL, LOC + "Stop() -- begin");
    7070    SignalMonitor::Stop();
    7171    if (GetStreamData())
    72         streamHandler->RemoveListener(GetStreamData());
    73     streamHandlerStarted = false;
     72        _stream_handler->RemoveListener(GetStreamData());
     73    _stream_handler_started = false;
    7474
    7575    VERBOSE(VB_CHANNEL, LOC + "Stop() -- end");
    7676}
     
    9191    if (!running || exit)
    9292        return;
    9393
    94     if (streamHandlerStarted)
     94    if (_stream_handler_started)
    9595    {
    9696        EmitStatus();
    9797        if (IsAllGood())
     
    104104    }
    105105
    106106    struct hdhomerun_tuner_status_t status;
    107     streamHandler->GetTunerStatus(&status);
     107    _stream_handler->GetTunerStatus(&status);
    108108
    109109    uint sig = status.signal_strength;
    110110    uint snq = status.signal_to_noise_quality;
     
    137137                   kDTVSigMon_WaitForMGT | kDTVSigMon_WaitForVCT |
    138138                   kDTVSigMon_WaitForNIT | kDTVSigMon_WaitForSDT))
    139139    {
    140         streamHandler->AddListener(GetStreamData());
    141         streamHandlerStarted = true;
     140        _stream_handler->AddListener(GetStreamData());
     141        _stream_handler_started = true;
    142142    }
    143143
    144144    update_done = true;
  • libs/libmythtv/hdhrsignalmonitor.h

    diff -Nur -x .svn mythtv/libs/libmythtv/hdhrsignalmonitor.h mythtv.new/libs/libmythtv/hdhrsignalmonitor.h
    old new  
    2828    HDHRChannel *GetHDHRChannel(void);
    2929
    3030  protected:
    31     bool               streamHandlerStarted;
    32     HDHRStreamHandler *streamHandler;
     31    bool               _stream_handler_started;
     32    HDHRStreamHandler *_stream_handler;
    3333};
    3434
    3535#endif // HDHRSIGNALMONITOR_H
  • libs/libmythtv/hdhrstreamhandler.cpp

    diff -Nur -x .svn mythtv/libs/libmythtv/hdhrstreamhandler.cpp mythtv.new/libs/libmythtv/hdhrstreamhandler.cpp
    old new  
    3939
    4040    QMap<QString,HDHRStreamHandler*>::iterator it = _handlers.find(devkey);
    4141
    42     hdhr_id_data device_data;
    43 
    44     if (it == _handlers.end())
    45     {
    46         // Not found in the current _handlers
    47         // Try to find the physical device and determine a unique device key
    48         // Then check to see if the unique key exists
    49         FindDevice(devname, device_data);
    50 
    51         devkey = QString("%1-%2").arg(device_data.device_id, 8, 16)
    52                                  .arg(device_data.tuner);
    53 
    54         // If the physical device is not found use the key "NOTFOUND-0"
    55         if (device_data.device_id == 0)
    56             devkey = "NOTFOUND-0";
    57 
    58         devkey = devkey.toUpper();
    59         it = _handlers.find(devkey);
    60     }
    61 
    62 
    6342    if (it == _handlers.end())
    6443    {
    65         HDHRStreamHandler *newhandler = new HDHRStreamHandler(devkey,
    66                                                               device_data);
     44        HDHRStreamHandler *newhandler = new HDHRStreamHandler(devkey);
    6745        newhandler->Open();
    6846        _handlers[devkey] = newhandler;
    6947        _handlers_refcnt[devkey] = 1;
    7048
    71         // If we are adding a "NOTFOUND" device,
    72         // up its refcount so we never delete it.
    73         if (device_data.device_id == 0)
    74             _handlers_refcnt[devkey]++;
    75 
    7649        VERBOSE(VB_RECORD,
    7750                QString("HDHRSH: Creating new stream handler %1 for %2")
    7851                .arg(devkey).arg(devname));
     
    127100    ref = NULL;
    128101}
    129102
    130 HDHRStreamHandler::HDHRStreamHandler(const QString &devicename,
    131                                      hdhr_id_data  &device_data) :
     103HDHRStreamHandler::HDHRStreamHandler(const QString &devicename) :
    132104    _hdhomerun_device(NULL),
    133     _device_id(device_data.device_id),
    134     _device_ip(device_data.device_ip),
    135     _tuner(device_data.tuner),
     105    _tuner(-1),
    136106    _devicename(devicename),
    137107
    138108    _start_stop_lock(QMutex::Recursive),
     
    590560
    591561bool HDHRStreamHandler::Open(void)
    592562{
    593     // By the time we get here we have a unique device_id & device_ip pair
    594     // for the hdhomerun. _device_id == 0 and _devicename == "NOTFOUND-0"
    595     // denote a device which is configured but we coudn't find.
    596     if (_device_id == 0)
    597         return false;
    598563    return Connect();
    599564}
    600565
     
    610575
    611576bool HDHRStreamHandler::Connect(void)
    612577{
    613     _hdhomerun_device = hdhomerun_device_create(_device_id, _device_ip, _tuner, NULL);
     578    _hdhomerun_device = hdhomerun_device_create_from_str(
     579        _devicename.toLocal8Bit().constData(), NULL);
    614580
    615581    if (!_hdhomerun_device)
    616582    {
     
    618584        return false;
    619585    }
    620586
     587    _tuner = hdhomerun_device_get_tuner(_hdhomerun_device);
     588
    621589    if (hdhomerun_device_get_local_machine_addr(_hdhomerun_device) == 0)
    622590    {
    623591        VERBOSE(VB_IMPORTANT, LOC_ERR + "Unable to connect to device");
     
    628596    return true;
    629597}
    630598
    631 void HDHRStreamHandler::FindDevice(const QString &_devicename,
    632                                    hdhr_id_data  &device_data)
    633 {
    634     hdhomerun_device_t* thisdevice = hdhomerun_device_create_from_str(
    635         _devicename.toLocal8Bit().constData(), NULL);
    636 
    637     if (thisdevice)
    638     {
    639         device_data.device_id = hdhomerun_device_get_device_id(thisdevice);
    640         device_data.device_ip = hdhomerun_device_get_device_ip(thisdevice);
    641         device_data.tuner     = hdhomerun_device_get_tuner(thisdevice);
    642         hdhomerun_device_destroy(thisdevice);
    643 
    644         if (device_data.device_ip != 0)
    645         {
    646             VERBOSE(VB_IMPORTANT,
    647                     QString("HDHRSH: device %1 found at "
    648                             "address %2.%3.%4.%5 tuner %6")
    649                     .arg(_devicename)
    650                     .arg((device_data.device_ip>>24) & 0xFF)
    651                     .arg((device_data.device_ip>>16) & 0xFF)
    652                     .arg((device_data.device_ip>> 8) & 0xFF)
    653                     .arg((device_data.device_ip>> 0) & 0xFF)
    654                     .arg(device_data.tuner));
    655         }
    656         else
    657         {
    658             VERBOSE(VB_IMPORTANT, LOC + "device not found");
    659             device_data.device_id = 0;
    660             device_data.device_ip = hdhomerun_device_get_device_ip_requested(
    661                                         thisdevice);
    662             device_data.tuner     = 0;
    663         }
    664     }
    665     else
    666     {
    667         VERBOSE(VB_IMPORTANT, LOC + "device not found");
    668         device_data.device_id = 0;
    669         device_data.device_ip = 0;
    670         device_data.tuner     = 0;
    671     }
    672 }
    673 
    674 
    675599bool HDHRStreamHandler::EnterPowerSavingMode(void)
    676600{
    677601    if (!hdhomerun_device_get_video_sock(_hdhomerun_device))
     
    685609    }
    686610}
    687611
    688 QString HDHRStreamHandler::DeviceGet(
     612QString HDHRStreamHandler::TunerGet(
    689613    const QString &name, bool report_error_return, bool print_error) const
    690614{
    691615    QMutexLocker locker(&_hdhr_lock);
     
    696620        return QString::null;
    697621    }
    698622
     623    QString valname = QString("/tuner%1/%2").arg(_tuner).arg(name);
    699624    char *value = NULL;
    700625    char *error = NULL;
    701626    if (hdhomerun_device_get_var(
    702             _hdhomerun_device, name.toLocal8Bit().constData(),
     627            _hdhomerun_device, valname.toLocal8Bit().constData(),
    703628            &value, &error) < 0)
    704629    {
    705630        VERBOSE(VB_IMPORTANT, LOC_ERR + "Get request failed" + ENO);
     
    720645    return QString(value);
    721646}
    722647
    723 QString HDHRStreamHandler::DeviceSet(
     648QString HDHRStreamHandler::TunerSet(
    724649    const QString &name, const QString &val,
    725650    bool report_error_return, bool print_error)
    726651{
     
    732657        return QString::null;
    733658    }
    734659
     660
     661    QString valname = QString("/tuner%1/%2").arg(_tuner).arg(name);
    735662    char *value = NULL;
    736663    char *error = NULL;
     664
    737665    if (hdhomerun_device_set_var(
    738             _hdhomerun_device, name.toLocal8Bit().constData(),
     666            _hdhomerun_device, valname.toLocal8Bit().constData(),
    739667            val.toLocal8Bit().constData(), &value, &error) < 0)
    740668    {
    741669        VERBOSE(VB_IMPORTANT, LOC_ERR + "Set request failed" + ENO);
     
    758686    return QString(value);
    759687}
    760688
    761 QString HDHRStreamHandler::TunerGet(
    762     const QString &name, bool report_error_return, bool print_error) const
    763 {
    764     return DeviceGet(QString("/tuner%1/%2").arg(_tuner).arg(name),
    765                      report_error_return, print_error);
    766 }
    767 
    768 QString HDHRStreamHandler::TunerSet(
    769     const QString &name, const QString &value,
    770     bool report_error_return, bool print_error)
    771 {
    772     QString valname = QString("/tuner%1/%2").arg(_tuner).arg(name);
    773     return DeviceSet(valname, value, report_error_return, print_error);
    774 }
    775 
    776 bool HDHRStreamHandler::DeviceSetTarget(unsigned short localPort)
    777 {
    778     if (localPort == 0)
    779     {
    780         return false;
    781     }
    782 
    783     unsigned long localIP = hdhomerun_device_get_local_machine_addr(
    784         _hdhomerun_device);
    785     if (localIP == 0)
    786     {
    787         return false;
    788     }
    789 
    790     QString rtpValue = QString("rtp://%1.%2.%3.%4:%5")
    791         .arg((localIP >> 24) & 0xFF).arg((localIP >> 16) & 0xFF)
    792         .arg((localIP >>  8) & 0xFF).arg((localIP >>  0) & 0xFF)
    793         .arg(localPort);
    794 
    795     QString err = TunerSet("target", rtpValue, true, false);
    796 
    797     if (err.isEmpty())
    798     {
    799         QString udpValue = QString("udp://%1.%2.%3.%4:%5")
    800             .arg((localIP >> 24) & 0xFF).arg((localIP >> 16) & 0xFF)
    801             .arg((localIP >>  8) & 0xFF).arg((localIP >>  0) & 0xFF)
    802             .arg(localPort);
    803         return !TunerSet("target", udpValue).isEmpty();
    804     }
    805 
    806     return true;
    807 }
    808 
    809 bool HDHRStreamHandler::DeviceClearTarget(void)
    810 {
    811     return !TunerSet("target", "0.0.0.0:0").isEmpty();
    812 }
    813 
    814689void HDHRStreamHandler::GetTunerStatus(struct hdhomerun_tuner_status_t *status)
    815690{
    816691    hdhomerun_device_get_tuner_status(_hdhomerun_device, NULL, status);
  • libs/libmythtv/hdhrstreamhandler.h

    diff -Nur -x .svn mythtv/libs/libmythtv/hdhrstreamhandler.h mythtv.new/libs/libmythtv/hdhrstreamhandler.h
    old new  
    3030
    3131//#define RETUNE_TIMEOUT 5000
    3232
    33 struct hdhr_id_data {
    34     uint device_id;
    35     uint device_ip;
    36     uint tuner;
    37 };
    38 
    3933class HDHRStreamHandler : public ReaderPausedCB
    4034{
    4135    friend void *run_hdhr_stream_handler_thunk(void *param);
     
    6155    virtual void ReaderPaused(int fd) { (void) fd; }
    6256
    6357  private:
    64     HDHRStreamHandler(const QString &, hdhr_id_data &);
     58    HDHRStreamHandler(const QString &);
    6559    ~HDHRStreamHandler();
    6660
    67     static void FindDevice(const QString &, hdhr_id_data &);
    6861    bool Connect(void);
    6962
    70     QString DeviceGet(const QString &name,
    71                       bool report_error_return = true,
    72                       bool print_error = true) const;
    73     QString DeviceSet(const QString &name, const QString &value,
    74                       bool report_error_return = true,
    75                       bool print_error = true);
    76 
    7763    QString TunerGet(const QString &name,
    7864                     bool report_error_return = true,
    7965                     bool print_error = true) const;
     
    8167                     bool report_error_return = true,
    8268                     bool print_error = true);
    8369
    84     bool DeviceSetTarget(short unsigned int);
    85     bool DeviceClearTarget(void);
    86 
    8770    bool Open(void);
    8871    void Close(void);
    8972
     
    10689
    10790  private:
    10891    hdhomerun_device_t  *_hdhomerun_device;
    109     uint                       _device_id;
    110     uint                       _device_ip;
    11192    uint                       _tuner;
    11293    QString                    _devicename;
    11394