Ticket #1970: 1970-fix-pmt-change-bug.patch

File 1970-fix-pmt-change-bug.patch, 3.4 KB (added by danielk, 13 years ago)

Potential fix

  • libs/libmythtv/dvbrecorder.cpp

     
    417417        PIDInfoMap::iterator lp_it = _pid_infos.begin();
    418418        for (;lp_it != _pid_infos.end(); ++lp_it)
    419419        {
    420             if (lp_it != it && (*lp_it)->priority < 0)
     420            if (lp_it != it && (*lp_it)->priority < kFilterPriorityHigh)
    421421            {
    422422                (*lp_it)->Close();
    423423                break;
     
    439439        }
    440440        else
    441441        {
    442             VERBOSE(VB_RECORD, LOC + "No low priority PID filter available, "
    443                     "open will fail.");
     442            VERBOSE(VB_RECORD, LOC_ERR + "Out of PID filters!");
    444443        }
    445444    }
    446445
     
    469468    return avail;
    470469}
    471470
     471bool DVBRecorder::SetPIDFilterPriority(uint pid, int priority)
     472{
     473    PIDInfoMap::iterator it = _pid_infos.find(pid);
     474    bool exists = it != _pid_infos.end();
     475
     476    if (exists)
     477        (*it)->priority = priority;
     478
     479    return exists;
     480}
     481
    472482bool DVBRecorder::AdjustFilters(void)
    473483{
    474484    StopDummyVideo(); // Stop the dummy video before acquiring the lock.
     
    519529        _stream_data->AddListeningPID(pmt_pid);
    520530        if (pmt_pid == input_pmt_pid)
    521531        {
    522             add_pid.push_back(input_pmt_pid);
     532            add_pid.push_back(pmt_pid);
    523533            add_stream_type.push_back(StreamID::PrivSec);
    524534        }
    525535        else
     
    529539    }
    530540
    531541    // Delete filters for pids we no longer wish to monitor
     542    // and make sure pids are set to the correct priority
    532543    PIDInfoMap::iterator it   = _pid_infos.begin();
    533544    PIDInfoMap::iterator next = it;
    534545    for (; it != _pid_infos.end(); it = next)
    535546    {
    536547        next = it; next++;
    537548
    538         if (find(add_pid.begin(), add_pid.end(), it.key()) == add_pid.end())
     549        if (find(add_pid.begin(), add_pid.end(), it.key()) != add_pid.end())
    539550        {
    540             _stream_data->RemoveListeningPID(it.key());
    541             _stream_data->RemoveWritingPID(it.key());
    542             (*it)->Close();
    543             delete *it;
    544             _pid_infos.erase(it);
     551            // Make sure this is considered high priority pid
     552            SetPIDFilterPriority(it.key(), kFilterPriorityHigh);
     553            continue;
    545554        }
     555
     556        if (find(_pmt_monitoring_pids.begin(), _pmt_monitoring_pids.end(),
     557                 it.key()) != _pmt_monitoring_pids.end())
     558        {
     559            // Make sure this is considered low priority pid
     560            SetPIDFilterPriority(it.key(), kFilterPriorityLow);
     561            continue;
     562        }
     563
     564        // Delete pids we are no longer interested in
     565        _stream_data->RemoveListeningPID(it.key());
     566        _stream_data->RemoveWritingPID(it.key());
     567        (*it)->Close();
     568        delete *it;
     569        _pid_infos.erase(it);
    546570    }
    547571
    548572    // Add or adjust filters for pids we wish to monitor
  • libs/libmythtv/dvbrecorder.h

     
    9999    bool OpenFilter(uint pid, int pes_type,
    100100                    uint mpeg_stream_type, int priority);
    101101    int  OpenFilterFd(uint pid, int pes_type, uint stream_type);
     102    bool SetPIDFilterPriority(uint pid, int priority);
    102103
    103104    void SetOutputPAT(ProgramAssociationTable*);
    104105    void SetOutputPMT(ProgramMapTable*);