diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
index 1d7113f8039..6ec879727c7 100644
a
|
b
|
MythPlayer::MythPlayer(PlayerFlags flags) |
219 | 219 | savedAudioTimecodeOffset(0), |
220 | 220 | rtcbase(0), |
221 | 221 | maxtcval(0), maxtcframes(0), |
| 222 | numdroppedframes(0), |
222 | 223 | // LiveTVChain stuff |
223 | 224 | m_tv(nullptr), isDummy(false), |
224 | 225 | // Counter for buffering messages |
… |
… |
void MythPlayer::AVSync2(VideoFrame *buffer) |
2208 | 2209 | rtcbase = unow - videotimecode * playspeed1000; |
2209 | 2210 | maxtcval = 0; |
2210 | 2211 | maxtcframes = 0; |
| 2212 | numdroppedframes = 0; |
2211 | 2213 | } |
2212 | 2214 | |
2213 | 2215 | int64_t tcincr = videotimecode - maxtcval; |
… |
… |
void MythPlayer::AVSync2(VideoFrame *buffer) |
2230 | 2232 | lateness = unow - framedue; |
2231 | 2233 | dropframe = false; |
2232 | 2234 | if (lateness > 30000) |
2233 | | dropframe = !FlagIsSet(kMusicChoice); |
| 2235 | dropframe = !FlagIsSet(kMusicChoice) && numdroppedframes < 10; |
2234 | 2236 | |
2235 | | if (lateness <= 30000 && audiotimecode > 0 && normal_speed) |
| 2237 | if (audiotimecode > 0 && normal_speed) |
2236 | 2238 | { |
2237 | 2239 | // Get video in sync with audio |
2238 | 2240 | audio_adjustment = audiotimecode - videotimecode; |
… |
… |
void MythPlayer::AVSync2(VideoFrame *buffer) |
2244 | 2246 | LOG(VB_PLAYBACK, LOG_INFO, LOC + |
2245 | 2247 | QString("AV Sync, audio ahead by %1 ms").arg(audio_adjustment)); |
2246 | 2248 | } |
| 2249 | if (audio_adjustment > 1000) |
| 2250 | pause_audio = true; |
2247 | 2251 | } |
2248 | 2252 | // sanity check - reset rtcbase if time codes have gone crazy. |
2249 | 2253 | if (lateness > AVSYNC_MAX_LATE || lateness < - AVSYNC_MAX_LATE) |
… |
… |
void MythPlayer::AVSync2(VideoFrame *buffer) |
2286 | 2290 | avsync_audiopaused = false; |
2287 | 2291 | audio.Pause(false); |
2288 | 2292 | } |
| 2293 | if (pause_audio && !avsync_audiopaused) |
| 2294 | { |
| 2295 | avsync_audiopaused = true; |
| 2296 | audio.Pause(true); |
| 2297 | } |
| 2298 | |
2289 | 2299 | LOG(VB_PLAYBACK | VB_TIMESTAMP, LOG_INFO, LOC + |
2290 | 2300 | QString("A/V timecodes audio=%1 video=%2 frameinterval=%3 " |
2291 | 2301 | "audioadj=%4 tcoffset=%5 unow=%6 udue=%7") |
… |
… |
void MythPlayer::AVSync2(VideoFrame *buffer) |
2297 | 2307 | .arg(unow) |
2298 | 2308 | .arg(framedue) |
2299 | 2309 | ); |
| 2310 | |
| 2311 | if (dropframe) |
| 2312 | numdroppedframes++; |
| 2313 | else |
| 2314 | numdroppedframes = 0; |
| 2315 | |
2300 | 2316 | if (dropframe) |
2301 | 2317 | LOG(VB_PLAYBACK, LOG_INFO, LOC + |
2302 | 2318 | QString("dropping frame to catch up, lateness=%1 usec") |
diff --git a/mythtv/libs/libmythtv/mythplayer.h b/mythtv/libs/libmythtv/mythplayer.h
index 8ca47303e76..631709a158b 100644
a
|
b
|
class MTV_PUBLIC MythPlayer |
851 | 851 | int64_t maxtcval; // maximum to date video tc |
852 | 852 | int maxtcframes; // number of frames seen since max to date tc |
853 | 853 | int64_t avsync2adjustms; // number of milliseconds to adjust for av sync errors |
| 854 | int numdroppedframes; // number of consecutive dropped frames. |
854 | 855 | |
855 | 856 | // LiveTV |
856 | 857 | TV *m_tv; |