diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
index 50b87523c76..576dc7c541d 100644
a
|
b
|
MythPlayer::MythPlayer(PlayerFlags flags) |
151 | 151 | fftime(0), |
152 | 152 | // Playback misc. |
153 | 153 | videobuf_retries(0), framesPlayed(0), |
154 | | prebufferFramesPlayed(0), |
155 | 154 | framesPlayedExtra(0), |
156 | 155 | totalFrames(0), totalLength(0), |
157 | 156 | totalDuration(0), |
… |
… |
void MythPlayer::AVSync2(VideoFrame *buffer) |
2241 | 2240 | if (lateness > 30000) |
2242 | 2241 | dropframe = !FlagIsSet(kMusicChoice) && numdroppedframes < 10; |
2243 | 2242 | |
2244 | | if (lateness <= 30000 && audiotimecode > 0 && normal_speed) |
| 2243 | if (lateness <= 30000 && audiotimecode > 0 && normal_speed && !FlagIsSet(kMusicChoice)) |
2245 | 2244 | { |
2246 | 2245 | // Get video in sync with audio |
2247 | 2246 | audio_adjustment = audiotimecode - videotimecode; |
… |
… |
void MythPlayer::AVSync2(VideoFrame *buffer) |
2257 | 2256 | pause_audio = true; |
2258 | 2257 | } |
2259 | 2258 | // 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)) |
2261 | 2261 | { |
2262 | 2262 | framedue = 0; |
2263 | 2263 | rtcbase = 0; |
… |
… |
bool MythPlayer::PrebufferEnoughFrames(int min_buffers) |
2447 | 2447 | if (!videoOutput) |
2448 | 2448 | return false; |
2449 | 2449 | |
| 2450 | bool paused_now = false; |
2450 | 2451 | if (!(min_buffers ? (videoOutput->ValidVideoFrames() >= min_buffers) : |
2451 | 2452 | (GetEof() != kEofStateNone) || |
2452 | 2453 | (videoOutput->hasHWAcceleration() ? |
… |
… |
bool MythPlayer::PrebufferEnoughFrames(int min_buffers) |
2454 | 2455 | videoOutput->EnoughDecodedFrames()))) |
2455 | 2456 | { |
2456 | 2457 | SetBuffering(true); |
| 2458 | |
2457 | 2459 | // This piece of code is to address the problem, when starting |
2458 | 2460 | // Live TV, of jerking and stuttering. Without this code |
2459 | 2461 | // that could go on forever, but is cured by a pause and play. |
2460 | 2462 | // This code inserts a brief pause and play when the potential |
2461 | 2463 | // for the jerking is detected. |
2462 | | if (prebufferFramesPlayed != framesPlayed) |
| 2464 | |
| 2465 | bool watchingTV = IsWatchingInprogress(); |
| 2466 | if (!paused_now && (livetv || watchingTV) && !FlagIsSet(kMusicChoice)) |
2463 | 2467 | { |
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) |
2468 | 2472 | { |
2469 | 2473 | LOG(VB_PLAYBACK, LOG_NOTICE, LOC + |
2470 | 2474 | 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)); |
2472 | 2476 | audio.Pause(true); |
2473 | 2477 | avsync_audiopaused = true; |
2474 | | prebufferFramesPlayed = framesPlayed; |
| 2478 | paused_now = true; |
2475 | 2479 | } |
2476 | 2480 | } |
2477 | 2481 | usleep(frame_interval >> 3); |
… |
… |
bool MythPlayer::PrebufferEnoughFrames(int min_buffers) |
2497 | 2501 | playerFlags = (PlayerFlags)(playerFlags | kMusicChoice); |
2498 | 2502 | LOG(VB_GENERAL, LOG_NOTICE, LOC + |
2499 | 2503 | "Music Choice program detected - disabling AV Sync."); |
| 2504 | avsync_audiopaused = false; |
| 2505 | audio.Pause(false); |
2500 | 2506 | } |
2501 | 2507 | if (waited_for > 7000 && audio.IsBufferAlmostFull() |
2502 | 2508 | && !FlagIsSet(kMusicChoice)) |
diff --git a/mythtv/libs/libmythtv/mythplayer.h b/mythtv/libs/libmythtv/mythplayer.h
index 631709a158b..c80d9ecb677 100644
a
|
b
|
class MTV_PUBLIC MythPlayer |
699 | 699 | /// How often we have tried to wait for a video output buffer and failed |
700 | 700 | int videobuf_retries; |
701 | 701 | uint64_t framesPlayed; |
702 | | uint64_t prebufferFramesPlayed; |
703 | 702 | // "Fake" frame counter for when the container frame rate doesn't |
704 | 703 | // match the stream frame rate. |
705 | 704 | uint64_t framesPlayedExtra; |