Ticket #5515: libs_libmythtv-forward-null-ticket-5515.patch

File libs_libmythtv-forward-null-ticket-5515.patch, 8.2 KB (added by Erik Hovland <erik@…>, 13 years ago)

Latest version of the pointer check patch for libmythtv

  • mythtv/libs/libmythtv/NuppelVideoPlayer.cpp

    Fix any instance where null is checked (or tracked) in
    
    From: Erik Hovland <erik@hovland.org>
    
    a function once and not checked every time the pointer
    is used.
    ---
    
     mythtv/libs/libmythtv/NuppelVideoPlayer.cpp |   42 ++++++++++++++++-----------
     mythtv/libs/libmythtv/guidegrid.cpp         |    4 +--
     mythtv/libs/libmythtv/tv_play.cpp           |   20 +++++++++----
     mythtv/libs/libmythtv/tv_rec.cpp            |   16 ++++++----
     4 files changed, 51 insertions(+), 31 deletions(-)
    
    diff --git a/mythtv/libs/libmythtv/NuppelVideoPlayer.cpp b/mythtv/libs/libmythtv/NuppelVideoPlayer.cpp
    index 23380c0..a3dd0d6 100644
    a b void NuppelVideoPlayer::InitAVSync(void) 
    22992299        warpfactor = warpfactor_avg;
    23002300    }
    23012301
    2302     refreshrate = videoOutput->GetRefreshRate();
     2302    refreshrate = videoOutput ? videoOutput->GetRefreshRate() : -1;
    23032303    if (refreshrate <= 0)
    23042304        refreshrate = frame_interval;
     2305
    23052306    vsynctol = refreshrate / 4;
    23062307
    23072308    if (!using_null_videoout)
    void NuppelVideoPlayer::OutputVideoLoop(void) 
    28842885
    28852886        if (ringBuffer->isDVD())
    28862887        {
    2887             int nbframes = videoOutput->ValidVideoFrames();
     2888            int nbframes = 0;
     2889            if (videoOutput)
     2890                nbframes = videoOutput->ValidVideoFrames();
    28882891
    28892892            if (nbframes < 2)
    28902893            {
    void NuppelVideoPlayer::DoPlay(void) 
    41484151    if (skip_changed)
    41494152    {
    41504153        //cout << "handling skip change" << endl;
    4151         videoOutput->SetPrebuffering(ffrew_skip == 1);
     4154        if (videoOutput) {
     4155            videoOutput->SetPrebuffering(ffrew_skip == 1);
    41524156
    41534157#ifdef USING_IVTV
    4154         if (IsIVTVDecoder())
    4155         {
    4156             VideoOutputIvtv *vidout = (VideoOutputIvtv *)videoOutput;
    4157             vidout->NextPlay(play_speed / ffrew_skip, normal_speed,
    4158                              (ffrew_skip == 1) ? 2 : 0);
    4159         }
     4158            if (IsIVTVDecoder())
     4159            {
     4160                VideoOutputIvtv *vidout = dynamic_cast<VideoOutputIvtv *>(videoOutput);
     4161                if (vidout)
     4162                    vidout->NextPlay(play_speed / ffrew_skip, normal_speed,
     4163                                     (ffrew_skip == 1) ? 2 : 0);
     4164            }
    41604165#endif
     4166        }
    41614167
    41624168        GetDecoder()->setExactSeeks(exactseeks && ffrew_skip == 1);
    41634169        GetDecoder()->DoRewind(framesPlayed);
    void NuppelVideoPlayer::DoPlay(void) 
    42034209    }
    42044210
    42054211#ifdef USING_IVTV
    4206     if (IsIVTVDecoder())
     4212    if (IsIVTVDecoder() && videoOutput)
    42074213    {
    4208         VideoOutputIvtv *vidout = (VideoOutputIvtv *)videoOutput;
    4209         vidout->Play(play_speed / ffrew_skip, normal_speed,
    4210                      (ffrew_skip == 1) ? 2 : 0);
     4214        VideoOutputIvtv *vidout = dynamic_cast<VideoOutputIvtv *>(videoOutput);
     4215        if (vidout)
     4216            vidout->Play(play_speed / ffrew_skip, normal_speed,
     4217                         (ffrew_skip == 1) ? 2 : 0);
    42114218    }
    42124219#endif
    42134220
    long long NuppelVideoPlayer::CalcMaxFFTime(long long ff, bool setjump) const 
    43164323            if (behind < maxtime || behind - ff <= maxtime * 2)
    43174324            {
    43184325                ret = -1;
    4319                 if (setjump)
     4326                if (setjump && livetvchain)
    43204327                    livetvchain->JumpToNext(true, 1);
    43214328            }
    43224329        }
    bool NuppelVideoPlayer::IsReallyNearEnd(void) const 
    43974404 */
    43984405bool NuppelVideoPlayer::IsNearEnd(long long margin) const
    43994406{
    4400     long long framesRead, framesLeft;
     4407    long long framesRead, framesLeft = 0;
    44014408
    44024409    if (!m_playbackinfo || m_playbackinfo->isVideo || !GetDecoder())
    44034410        return false;
    bool NuppelVideoPlayer::IsNearEnd(long long margin) const 
    44334440    if (livetv && livetvchain && livetvchain->HasNext())
    44344441        return false;
    44354442
    4436     framesLeft = nvr_enc->GetCachedFramesWritten() - framesRead;
     4443    if (nvr_enc)
     4444        framesLeft = nvr_enc->GetCachedFramesWritten() - framesRead;
    44374445
    44384446    // if it looks like we are near end, get an updated GetFramesWritten()
    4439     if (framesLeft < margin)
     4447    if (framesLeft < margin && nvr_enc)
    44404448        framesLeft = nvr_enc->GetFramesWritten() - framesRead;
    44414449
    44424450    return (framesLeft < margin);
  • mythtv/libs/libmythtv/guidegrid.cpp

    diff --git a/mythtv/libs/libmythtv/guidegrid.cpp b/mythtv/libs/libmythtv/guidegrid.cpp
    index 64d3659..bf80e52 100644
    a b void GuideGrid::fillProgramRowInfos(unsigned int row) 
    12121212        }
    12131213        else
    12141214        {
    1215             if (proginfo == *program)
     1215            if (proginfo && proginfo == *program)
    12161216            {
    12171217                proginfo->spread++;
    12181218            }
    1219             else
     1219            else if (*program)
    12201220            {
    12211221                proginfo = *program;
    12221222                proginfo->startCol = x;
  • mythtv/libs/libmythtv/tv_play.cpp

    diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp
    index f4a525e..2c42c33 100644
    a b void TV::SwapPIP(void) 
    40574057    main.buffer   = prbuffer;
    40584058    main.recorder = recorder;
    40594059    main.chain    = tvchain;
    4060     main.frame    = nvp->GetFramesPlayed();
     4060    main.frame    = nvp ? nvp->GetFramesPlayed() : -1;
    40614061    pip.buffer    = piprbuffer;
    40624062    pip.recorder  = piprecorder;
    40634063    pip.chain     = piptvchain;
    void TV::SwapPIP(void) 
    40694069    piprbuffer->Pause();
    40704070    piprbuffer->WaitForPause();
    40714071
    4072     nvp->StopPlaying();
     4072    if (nvp)
     4073        nvp->StopPlaying();
     4074
    40734075    pipnvp->StopPlaying();
     4076
    40744077    {
    40754078        QMutexLocker locker(&osdlock); // prevent UpdateOSDSignal using osd...
    40764079        pthread_join(decode, NULL);
    void TV::DoPause(bool showOSD) 
    42194222
    42204223    if (paused)
    42214224    {
    4222         activerbuffer->WaitForPause();
     4225        if (activerbuffer)
     4226            activerbuffer->WaitForPause();
     4227
    42234228        DoNVPSeek(time);
    42244229        if (showOSD)
    42254230            UpdateOSDSeekMessage(tr("Paused"), -1);
    void TV::ChangeChannel(uint chanid, const QString &chan) 
    51305135    if (!prevChan.empty() && prevChan.back() == channum)
    51315136        return;
    51325137
    5133     if (!activerecorder->CheckChannel(channum))
     5138    if (!activerecorder || !activerecorder->CheckChannel(channum))
    51345139        return;
    51355140
    51365141    if (nvp)
    bool TV::VideoThemeCheck(QString str, bool stayPaused) 
    58745879    bool ret = true;
    58755880    bool allowembed = (nvp && nvp->getVideoOutput() &&
    58765881                    nvp->getVideoOutput()->AllowPreviewEPG());
     5882    long long margin = 0;
     5883
     5884    if (nvp)
     5885        margin = static_cast<long long>((nvp->GetFrameRate() *
     5886                                        nvp->GetAudioStretchFactor()));
    58775887
    5878     long long margin = (long long)(nvp->GetFrameRate() *
    5879                         nvp->GetAudioStretchFactor());
    58805888    margin = margin * 5;
    58815889    QDomElement xmldata;
    58825890    XMLParse *theme = new XMLParse();
  • mythtv/libs/libmythtv/tv_rec.cpp

    diff --git a/mythtv/libs/libmythtv/tv_rec.cpp b/mythtv/libs/libmythtv/tv_rec.cpp
    index 04d94a2..b76d823 100644
    a b static QString load_profile(QString cardtype, void *tvchain, 
    39443944void TVRec::TuningNewRecorder(MPEGStreamData *streamData)
    39453945{
    39463946    VERBOSE(VB_RECORD, LOC + "Starting Recorder");
     3947#ifdef USING_V4L
     3948    V4LChannel* v4lChannel = 0;
     3949#endif
    39473950
    39483951    bool had_dummyrec = false;
    39493952    if (HasFlags(kFlagDummyRecorderRunning))
    void TVRec::TuningNewRecorder(MPEGStreamData *streamData) 
    40384041
    40394042    // Setup for framebuffer capture devices..
    40404043    if (channel)
    4041     {
    40424044        SetVideoFiltersForChannel(channel->GetCurrentSourceID(),
    40434045                                  channel->GetCurrentName());
    4044     }
    40454046
    40464047#ifdef USING_V4L
    4047     if (GetV4LChannel())
     4048    v4lChannel = GetV4LChannel();
     4049    if (v4lChannel)
    40484050    {
    4049         channel->InitPictureAttributes();
     4051        v4lChannel->InitPictureAttributes();
    40504052        CloseChannel();
    40514053    }
    40524054#endif
    void TVRec::TuningNewRecorder(MPEGStreamData *streamData) 
    40594061        usleep(5 * 1000);
    40604062    stateChangeLock.lock();
    40614063
    4062     if (GetV4LChannel())
    4063         channel->SetFd(recorder->GetVideoFd());
     4064#ifdef USING_V4L
     4065    if (v4lChannel)
     4066        v4lChannel->SetFd(recorder->GetVideoFd());
     4067#endif
    40644068
    40654069    SetFlags(kFlagRecorderRunning | kFlagRingBufferReady);
    40664070