Ticket #13334: 20181030_1126_drop_fix.patch

File 20181030_1126_drop_fix.patch, 3.1 KB (added by Peter Bennett, 5 years ago)

avsync2 fix for where you are stuck on one fame for extended time when decoding is slow

  • mythtv/libs/libmythtv/mythplayer.cpp

    diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
    index 1d7113f8039..6ec879727c7 100644
    a b MythPlayer::MythPlayer(PlayerFlags flags) 
    219219      savedAudioTimecodeOffset(0),
    220220      rtcbase(0),
    221221      maxtcval(0), maxtcframes(0),
     222      numdroppedframes(0),
    222223      // LiveTVChain stuff
    223224      m_tv(nullptr),                isDummy(false),
    224225      // Counter for buffering messages
    void MythPlayer::AVSync2(VideoFrame *buffer) 
    22082209            rtcbase = unow - videotimecode * playspeed1000;
    22092210            maxtcval = 0;
    22102211            maxtcframes = 0;
     2212            numdroppedframes = 0;
    22112213        }
    22122214
    22132215        int64_t tcincr = videotimecode - maxtcval;
    void MythPlayer::AVSync2(VideoFrame *buffer) 
    22302232        lateness = unow - framedue;
    22312233        dropframe = false;
    22322234        if (lateness > 30000)
    2233             dropframe = !FlagIsSet(kMusicChoice);
     2235            dropframe = !FlagIsSet(kMusicChoice) && numdroppedframes < 10;
    22342236
    2235         if (lateness <= 30000 && audiotimecode > 0 && normal_speed)
     2237        if (audiotimecode > 0 && normal_speed)
    22362238        {
    22372239            // Get video in sync with audio
    22382240            audio_adjustment = audiotimecode - videotimecode;
    void MythPlayer::AVSync2(VideoFrame *buffer) 
    22442246                LOG(VB_PLAYBACK, LOG_INFO, LOC +
    22452247                    QString("AV Sync, audio ahead by %1 ms").arg(audio_adjustment));
    22462248            }
     2249            if (audio_adjustment > 1000)
     2250                pause_audio = true;
    22472251        }
    22482252        // sanity check - reset rtcbase if time codes have gone crazy.
    22492253        if (lateness > AVSYNC_MAX_LATE || lateness < - AVSYNC_MAX_LATE)
    void MythPlayer::AVSync2(VideoFrame *buffer) 
    22862290        avsync_audiopaused = false;
    22872291        audio.Pause(false);
    22882292    }
     2293    if (pause_audio && !avsync_audiopaused)
     2294    {
     2295        avsync_audiopaused = true;
     2296        audio.Pause(true);
     2297    }
     2298
    22892299    LOG(VB_PLAYBACK | VB_TIMESTAMP, LOG_INFO, LOC +
    22902300        QString("A/V timecodes audio=%1 video=%2 frameinterval=%3 "
    22912301                "audioadj=%4 tcoffset=%5 unow=%6 udue=%7")
    void MythPlayer::AVSync2(VideoFrame *buffer) 
    22972307            .arg(unow)
    22982308            .arg(framedue)
    22992309                );
     2310
     2311    if (dropframe)
     2312        numdroppedframes++;
     2313    else
     2314        numdroppedframes = 0;
     2315
    23002316    if (dropframe)
    23012317        LOG(VB_PLAYBACK, LOG_INFO, LOC +
    23022318            QString("dropping frame to catch up, lateness=%1 usec")
  • mythtv/libs/libmythtv/mythplayer.h

    diff --git a/mythtv/libs/libmythtv/mythplayer.h b/mythtv/libs/libmythtv/mythplayer.h
    index 8ca47303e76..631709a158b 100644
    a b class MTV_PUBLIC MythPlayer 
    851851    int64_t   maxtcval;       // maximum to date video tc
    852852    int       maxtcframes;    // number of frames seen since max to date tc
    853853    int64_t   avsync2adjustms; // number of milliseconds to adjust for av sync errors
     854    int       numdroppedframes; // number of consecutive dropped frames.
    854855
    855856    // LiveTV
    856857    TV *m_tv;