Ticket #13383: 20190204_1416_catchup.patch

File 20190204_1416_catchup.patch, 1.7 KB (added by Peter Bennett, 20 months ago)

Updated patch that fixes AVSync2 bugs and takes out the audio reset. This should give a better experience, especially in speedup cases.

  • mythtv/libs/libmythtv/mythplayer.cpp

    diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
    index 5b80c452a3..acf1d16193 100644
    a b void wait_for_time(int64_t framedue) 
    21702170        QThread::usleep(delay);
    21712171}
    21722172
    2173 #define AVSYNC_MAX_LATE 1000000
     2173#define AVSYNC_MAX_LATE 10000000
    21742174void MythPlayer::AVSync2(VideoFrame *buffer)
    21752175{
    21762176    if (videoOutput->IsErrored())
    void MythPlayer::AVSync2(VideoFrame *buffer) 
    22492249            // Get video in sync with audio
    22502250            audio_adjustment = audiotimecode - videotimecode;
    22512251            int sign = audio_adjustment < 0 ? -1 : 1;
     2252            int64_t fix_amount = avsync2adjustms;
     2253            // Faster catch-up when off by more than 200 ms
     2254            if (audio_adjustment * sign > 200)
     2255            {
     2256                fix_amount = audio_adjustment * sign - 200;
     2257                if (fix_amount < avsync2adjustms)
     2258                    fix_amount = avsync2adjustms;
     2259            }
     2260            // If there is excess audio - throw it away.
     2261            // if (audio_adjustment < -300)
     2262            //     audio.Reset();
    22522263            if (audio_adjustment * sign > 40)
    22532264            {
    22542265                // adjust by AVSyncIncrementMS milliseconds at a time (range 1-40)
    2255                 rtcbase -= (int64_t)1000000 * avsync2adjustms * sign / playspeed1000;
     2266                int64_t speedup1000 = (float)1000 * play_speed;
     2267                rtcbase -= (int64_t)1000000 * fix_amount * sign / speedup1000;
    22562268                LOG(VB_PLAYBACK, LOG_INFO, LOC +
    22572269                    QString("AV Sync, audio ahead by %1 ms").arg(audio_adjustment));
    22582270            }