Ticket #13349: 20181119_1607_transition_fix.patch

File 20181119_1607_transition_fix.patch, 4.4 KB (added by Peter Bennett, 19 months ago)

Fix transition problem

  • mythtv/libs/libmythtv/mythplayer.cpp

    diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
    index 50b87523c76..576dc7c541d 100644
    a b MythPlayer::MythPlayer(PlayerFlags flags) 
    151151      fftime(0),
    152152      // Playback misc.
    153153      videobuf_retries(0),          framesPlayed(0),
    154       prebufferFramesPlayed(0),
    155154      framesPlayedExtra(0),
    156155      totalFrames(0),               totalLength(0),
    157156      totalDuration(0),
    void MythPlayer::AVSync2(VideoFrame *buffer) 
    22412240        if (lateness > 30000)
    22422241            dropframe = !FlagIsSet(kMusicChoice) && numdroppedframes < 10;
    22432242
    2244         if (lateness <= 30000 && audiotimecode > 0 && normal_speed)
     2243        if (lateness <= 30000 && audiotimecode > 0 && normal_speed && !FlagIsSet(kMusicChoice))
    22452244        {
    22462245            // Get video in sync with audio
    22472246            audio_adjustment = audiotimecode - videotimecode;
    void MythPlayer::AVSync2(VideoFrame *buffer) 
    22572256                pause_audio = true;
    22582257        }
    22592258        // sanity check - reset rtcbase if time codes have gone crazy.
    2260         if (lateness > AVSYNC_MAX_LATE || lateness < - AVSYNC_MAX_LATE)
     2259        if ((lateness > AVSYNC_MAX_LATE || lateness < - AVSYNC_MAX_LATE)
     2260            && !FlagIsSet(kMusicChoice))
    22612261        {
    22622262            framedue = 0;
    22632263            rtcbase = 0;
    bool MythPlayer::PrebufferEnoughFrames(int min_buffers) 
    24472447    if (!videoOutput)
    24482448        return false;
    24492449
     2450    bool paused_now = false;
    24502451    if (!(min_buffers ? (videoOutput->ValidVideoFrames() >= min_buffers) :
    24512452                        (GetEof() != kEofStateNone) ||
    24522453                        (videoOutput->hasHWAcceleration() ?
    bool MythPlayer::PrebufferEnoughFrames(int min_buffers) 
    24542455                            videoOutput->EnoughDecodedFrames())))
    24552456    {
    24562457        SetBuffering(true);
     2458
    24572459        // This piece of code is to address the problem, when starting
    24582460        // Live TV, of jerking and stuttering. Without this code
    24592461        // that could go on forever, but is cured by a pause and play.
    24602462        // This code inserts a brief pause and play when the potential
    24612463        // for the jerking is detected.
    2462         if (prebufferFramesPlayed != framesPlayed)
     2464
     2465        bool watchingTV = IsWatchingInprogress();
     2466        if (!paused_now && (livetv || watchingTV) && !FlagIsSet(kMusicChoice))
    24632467        {
    2464             float current   = ComputeSecs(framesPlayed, true);
    2465             float length    = ComputeSecs(totalFrames, true);
    2466             if (length > current && length - current < 1.5
    2467                 && !FlagIsSet(kMusicChoice))
     2468            uint64_t frameCount = GetCurrentFrameCount();
     2469            uint64_t framesLeft = frameCount - framesPlayed;
     2470            uint64_t margin = (uint64_t) (video_frame_rate * 3);
     2471            if (framesLeft < margin)
    24682472            {
    24692473                LOG(VB_PLAYBACK, LOG_NOTICE, LOC +
    24702474                    QString("Pause to allow live tv catch up. Position in sec. Current: %2, Total: %3")
    2471                     .arg(current).arg(length));
     2475                    .arg(framesPlayed).arg(frameCount));
    24722476                audio.Pause(true);
    24732477                avsync_audiopaused = true;
    2474                 prebufferFramesPlayed = framesPlayed;
     2478                paused_now = true;
    24752479            }
    24762480        }
    24772481        usleep(frame_interval >> 3);
    bool MythPlayer::PrebufferEnoughFrames(int min_buffers) 
    24972501                playerFlags = (PlayerFlags)(playerFlags | kMusicChoice);
    24982502                LOG(VB_GENERAL, LOG_NOTICE, LOC +
    24992503                    "Music Choice program detected - disabling AV Sync.");
     2504                avsync_audiopaused = false;
     2505                audio.Pause(false);
    25002506            }
    25012507            if (waited_for > 7000 && audio.IsBufferAlmostFull()
    25022508                && !FlagIsSet(kMusicChoice))
  • mythtv/libs/libmythtv/mythplayer.h

    diff --git a/mythtv/libs/libmythtv/mythplayer.h b/mythtv/libs/libmythtv/mythplayer.h
    index 631709a158b..c80d9ecb677 100644
    a b class MTV_PUBLIC MythPlayer 
    699699    /// How often we have tried to wait for a video output buffer and failed
    700700    int       videobuf_retries;
    701701    uint64_t  framesPlayed;
    702     uint64_t  prebufferFramesPlayed;
    703702    // "Fake" frame counter for when the container frame rate doesn't
    704703    // match the stream frame rate.
    705704    uint64_t  framesPlayedExtra;