Ticket #12318: 20171108_#12318_stutter.patch

File 20171108_#12318_stutter.patch, 2.5 KB (added by Peter Bennett, 2 years ago)

Proposed fix

  • mythtv/libs/libmythtv/mythplayer.cpp

    diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
    index 5a6777a..871d778 100644
    a b MythPlayer::MythPlayer(PlayerFlags flags) 
    154154      fftime(0),
    155155      // Playback misc.
    156156      videobuf_retries(0),          framesPlayed(0),
     157      prebufferFramesPlayed(0),
    157158      framesPlayedExtra(0),
    158159      totalFrames(0),               totalLength(0),
    159160      totalDuration(0),
    bool MythPlayer::PrebufferEnoughFrames(int min_buffers) 
    22082209                            videoOutput->EnoughDecodedFrames())))
    22092210    {
    22102211        SetBuffering(true);
     2212        // This pece of code is to address the problem when starting
     2213        // Live TV of jerking and stuttering. Without this code
     2214        // that could go on forever, but is ured by a pause and play.
     2215        // This code inserts a bried pause and play when the potential
     2216        // for the jerking is detected.
     2217        if (prebufferFramesPlayed != framesPlayed)
     2218        {
     2219            float current   = ComputeSecs(framesPlayed, true);
     2220            float length    = ComputeSecs(totalFrames, true);
     2221            if (prebufferFramesPlayed != framesPlayed
     2222                && length > current && length - current < 1.5)
     2223            {
     2224                LOG(VB_PLAYBACK, LOG_NOTICE, LOC +
     2225                    QString("Pause to allow live tv catch up. Position in sec. Current: %2, Total: %3")
     2226                    .arg(current).arg(length));
     2227                if (!audio.IsPaused())
     2228                {
     2229                    audio.Pause(true);
     2230                    avsync_audiopaused = true;
     2231                }
     2232                prebufferFramesPlayed = framesPlayed;
     2233            }
     2234        }
    22112235        usleep(frame_interval >> 3);
    22122236        int waited_for = buffering_start.msecsTo(QTime::currentTime());
    22132237        int last_msg = buffering_last_msg.msecsTo(QTime::currentTime());
  • mythtv/libs/libmythtv/mythplayer.h

    diff --git a/mythtv/libs/libmythtv/mythplayer.h b/mythtv/libs/libmythtv/mythplayer.h
    index 6581ca6..8b55108 100644
    a b class MTV_PUBLIC MythPlayer 
    695695    /// How often we have tried to wait for a video output buffer and failed
    696696    int       videobuf_retries;
    697697    uint64_t  framesPlayed;
     698    uint64_t  prebufferFramesPlayed;
    698699    // "Fake" frame counter for when the container frame rate doesn't
    699700    // match the stream frame rate.
    700701    uint64_t  framesPlayedExtra;