Ticket #5443: hdpvr-channel-change.patch

File hdpvr-channel-change.patch, 3.6 KB (added by jppoet@…, 4 years ago)

HACK: reset HD-PVR driver, when "select timeout" errors are detected. (Does not fix LiveTV)

  • libs/libmythtv/mpegrecorder.h

     
    7575    bool StartEncoding(int fd); 
    7676    bool StopEncoding(int fd); 
    7777 
     78    void InitHDpvr(void); 
    7879    void ResetForNewFile(void); 
    7980 
    8081    inline bool CheckCC(uint pid, uint cc); 
  • libs/libmythtv/v4lchannel.cpp

     
    505505    if ((*it)->externalChanger.isEmpty()) 
    506506    { 
    507507        if ((*it)->name.contains("composite", false) || 
     508            (*it)->name.contains("component", false) || 
    508509            (*it)->name.contains("s-video", false)) 
    509510        { 
    510511            VERBOSE(VB_GENERAL, LOC_WARN + "You have not set " 
  • libs/libmythtv/mpegrecorder.cpp

     
    861861        return OpenV4L2DeviceAsInput(); 
    862862} 
    863863 
     864void MpegRecorder::InitHDpvr(void) 
     865{ 
     866    SetPositionMapType(MARK_GOP_BYFRAME); 
     867     
     868    int progNum = 1; 
     869    MPEGStreamData *sd = new MPEGStreamData(progNum, true); 
     870    sd->SetRecordingType(_recording_type); 
     871    SetStreamData(sd); 
     872     
     873    _stream_data->AddAVListener(this); 
     874    _stream_data->AddWritingListener(this); 
     875     
     876    // Make sure the first things in the file are a PAT & PMT 
     877    _wait_for_keyframe_option = false; 
     878    HandleSingleProgramPAT(_stream_data->PATSingleProgram()); 
     879    HandleSingleProgramPMT(_stream_data->PMTSingleProgram()); 
     880    _wait_for_keyframe_option = true; 
     881} 
     882 
    864883void MpegRecorder::StartRecording(void) 
    865884{ 
    866885    if (!Open()) 
     
    875894 
    876895    if (driver == "hdpvr") 
    877896    { 
    878         SetPositionMapType(MARK_GOP_BYFRAME); 
    879  
    880         int progNum = 1; 
    881         MPEGStreamData *sd = new MPEGStreamData(progNum, true); 
    882         sd->SetRecordingType(_recording_type); 
    883         SetStreamData(sd); 
    884  
    885         _stream_data->AddAVListener(this); 
    886         _stream_data->AddWritingListener(this); 
    887  
    888         // Make sure the first things in the file are a PAT & PMT 
    889         _wait_for_keyframe_option = false; 
    890         HandleSingleProgramPAT(_stream_data->PATSingleProgram()); 
    891         HandleSingleProgramPMT(_stream_data->PMTSingleProgram()); 
    892         _wait_for_keyframe_option = true; 
     897        InitHDpvr(); 
    893898    } 
    894899    else 
    895900    { 
     
    960965                    continue; 
    961966 
    962967                case 0: 
    963                     VERBOSE(VB_IMPORTANT, LOC_ERR + "select timeout - " 
    964                             "driver has stopped responding"); 
     968                  VERBOSE(VB_IMPORTANT, LOC_ERR + "select timeout - " 
     969                          "driver has stopped responding"); 
     970                   
     971                  TeardownAll(); 
     972                  if (!Open())  
     973                      VERBOSE(VB_IMPORTANT, LOC_ERR + "Open failed" + ENO); 
     974             
     975                  if (driver == "hdpvr") 
     976                  { 
     977                      if (!ringBuffer) 
     978                          return; 
    965979 
    966                     if (close(readfd) != 0) 
    967                     { 
    968                         VERBOSE(VB_IMPORTANT, LOC_ERR + "Close error" + ENO); 
    969                     } 
     980                      ringBuffer->WriterSeek(0, SEEK_SET); 
    970981 
    971                     // Force card to be reopened on next iteration.. 
    972                     readfd = -1; 
     982                      _start_code = 0xffffffff; 
     983                      _last_gop_seen = 0; 
     984                      _frames_written_count = 0; 
     985                       
     986                      InitHDpvr(); 
     987                      remainder = 0; 
     988                  } 
    973989 
    974                     continue; 
     990                  continue; 
    975991                 
    976992                default: break; 
    977993            }