Ticket #3786: mythtv_tsreset.2.patch

File mythtv_tsreset.2.patch, 7.0 KB (added by Mark Spieth, 17 years ago)
  • libs/libmyth/remotefile.h

     
    2222
    2323    int Read(void *data, int size);
    2424    void Reset(void);
     25    int GetStarvedCount() const { return starvedCount; };
    2526
    2627    bool SaveAs(QByteArray &data);
    2728
     
    4748    bool            timeoutisfast;
    4849    long long       readposition;
    4950    int             recordernum;
     51    int             starvedCount;
    5052
    5153    mutable QMutex  lock;
    5254    MythSocket     *controlSock;
  • libs/libmyth/remotefile.cpp

     
    224224    strlist << QString::number(size);
    225225    controlSock->writeStringList(strlist);
    226226
     227    starvedCount = 0;
    227228    sent = size;
    228229   
    229230    while (recv < sent && !error && zerocnt++ < 50)
     
    235236            {
    236237                recv += ret;
    237238            }
     239            else if (ret == 0)
     240            {
     241                starvedCount++;
     242            }
    238243            else if (sock->error() != MythSocket::NoError)
    239244            {
    240245                VERBOSE(VB_IMPORTANT, "RemoteFile::Read(): socket error");
  • libs/libmythtv/RingBuffer.h

     
    5757               bool toAdjust      = false,
    5858               bool resetInternal = false);
    5959
     60    int  GetStarvedCount() const { return starvedCount; }
     61
    6062    // Seeks
    6163    long long Seek(long long pos, int whence);
    6264
     
    172174    LiveTVChain *livetvchain;
    173175    bool ignoreliveeof;
    174176
     177    int starvedCount;
     178
    175179    long long readAdjust;
    176180
    177181    /// Condition to signal that the read ahead thread is running
  • libs/libmythtv/RingBuffer.cpp

     
    100100      numfailures(0),           commserror(false),
    101101      dvdPriv(NULL),            oldfile(false),
    102102      livetvchain(NULL),        ignoreliveeof(false),
     103      starvedCount(0),
    103104      readAdjust(0)
    104105{
    105106    pthread_rwlock_init(&rwlock, NULL);
     
    396397    unsigned errcnt = 0;
    397398    unsigned zerocnt = 0;
    398399
     400    if (!readaheadrunning)
     401        starvedCount = 0;
     402
    399403    if (fd < 0)
    400404    {
    401405        VERBOSE(VB_IMPORTANT, LOC_ERR +
     
    446450        if (tot < sz)
    447451            usleep(60000);
    448452    }
     453    if (!readaheadrunning)
     454        starvedCount = zerocnt;
     455
    449456    return tot;
    450457}
    451458
     
    461468{
    462469    int ret = 0;
    463470
     471    if (!readaheadrunning)
     472        starvedCount = 0;
     473
    464474    ret = rf->Read(data, sz);
    465475    if (ret < 0)
    466476    {
     
    471481        ret = 0;
    472482        numfailures++;
    473483     }
     484    if (!readaheadrunning)
     485        starvedCount = rf->GetStarvedCount();
    474486
    475487    return ret;
    476488}
     
    935947    bool readone = false;
    936948    int readErr = 0;
    937949   
     950    starvedCount = 0;
     951
    938952    if (readaheadpaused && stopreads)
    939953    {
    940954        readone = true;
     
    10211035                availWaitMutex.unlock();
    10221036                return 0;
    10231037            }
     1038            starvedCount++;
    10241039        }
    10251040
    10261041        wanttoread = 0;
  • libs/libmythtv/decoderbase.h

     
    123123    bool GetWaitForChange(void);
    124124    void SetReadAdjust(long long adjust);
    125125
     126    int  GetStarvedCount() const { return starvedCount; }
     127
    126128    // DVD public stuff
    127129    void ChangeDVDTrack(bool ffw);
    128130    long long DVDFindPosition(long long desiredFrame);
     
    213215    bool getrawframes;
    214216    bool getrawvideo;
    215217
     218    int  starvedCount;
     219
    216220    bool errored;
    217221
    218222    bool waitingForChange;
  • libs/libmythtv/decoderbase.cpp

     
    3939
    4040      hasKeyFrameAdjustTable(false), lowbuffers(false),
    4141      getrawframes(false), getrawvideo(false),
     42      starvedCount(0),
    4243      errored(false), waitingForChange(false), readAdjust(0),
    4344      justAfterChange(false),
    4445      // language preference
  • libs/libmythtv/avformatdecoder.cpp

     
    28352835                    delete pkt;
    28362836                return false;
    28372837            }
     2838            starvedCount = avfRingBuffer->GetRingBuffer()->GetStarvedCount();
     2839#if 1
     2840            // for debugging
     2841            if (starvedCount > 0)
     2842            {
     2843                VERBOSE(VB_PLAYBACK, LOC_ERR + QString("AVF Starved %1").arg(starvedCount));
     2844            }
     2845#endif
    28382846
    28392847            if (waitingForChange && pkt->pos >= readAdjust)
    28402848                FileChanged();
  • libs/libmythtv/nuppeldecoder.cpp

     
    988988    int seeklen = 0;
    989989
    990990    decoded_video_frame = NULL;
     991    starvedCount = 0;
    991992
    992993    while (!gotvideo)
    993994    {
     
    10051006            return false;
    10061007        }
    10071008
     1009        starvedCount += ringBuffer->GetStarvedCount();
    10081010
    10091011        if (!ringBuffer->LiveMode() &&
    10101012            ((frameheader.frametype == 'Q') || (frameheader.frametype == 'K')))
     
    10311033                GetNVP()->SetEof();
    10321034                return false;
    10331035            }
     1036            starvedCount += ringBuffer->GetStarvedCount();
    10341037            seeklen = 1;
    10351038        }
    10361039
     
    10461049                GetNVP()->SetEof();
    10471050                return false;
    10481051            }
     1052            starvedCount += ringBuffer->GetStarvedCount();
    10491053
    10501054            delete [] dummy;
    10511055            continue;
     
    11151119                GetNVP()->SetEof();
    11161120                return false;
    11171121            }
     1122            starvedCount += ringBuffer->GetStarvedCount();
    11181123        }
    11191124        else
    11201125            continue;
  • libs/libmythtv/NuppelVideoPlayer.cpp

     
    12651265    CheckPrebuffering();
    12661266
    12671267    if ((play_speed > 1.01f) && (audio_stretchfactor > 1.01f) &&
    1268          livetv && IsNearEnd())
     1268         (livetv || (watchingrecording && nvr_enc && nvr_enc->IsValidRecorder()))
     1269         && (IsNearEnd() || GetDecoder()->GetStarvedCount()>0))
    12691270    {
    12701271        VERBOSE(VB_PLAYBACK, LOC + "Near end, Slowing down playback.");
    12711272        Play(1.0f, true, true);