summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Kendall <mkendall@mythtv.org>2011-05-03 01:09:17 (GMT)
committer Mark Kendall <mkendall@mythtv.org>2011-05-03 01:09:17 (GMT)
commita0bb5e9a5fdbbacef3f16a1316cf30465bcf10ae (patch)
treef9a78bf5ef514345f30cc90ac83bf0bde2c5094a
parent56c54fa86652016bb28eac330d67bdc08fc1932e (diff)
MythPlayer: Pause the audio when the video is lagging.
When using software decoding and the decoder is struggling to keep up, audio sync may take a long time to recover after startup or following a skip. Under certain conditions, playback never recovers and because we are constantly skipping frames, the user sees no screen updates - and hence playback looks entirely broken. By pausing the audio when skipping frames, we allow video playback to catch up. Backported from afe5669be72c3c452dfb
-rw-r--r--mythtv/libs/libmythtv/mythplayer.cpp14
-rw-r--r--mythtv/libs/libmythtv/mythplayer.h1
2 files changed, 14 insertions, 1 deletions
diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
index 058f910..e02c4d1 100644
--- a/mythtv/libs/libmythtv/mythplayer.cpp
+++ b/mythtv/libs/libmythtv/mythplayer.cpp
@@ -201,7 +201,7 @@ MythPlayer::MythPlayer(bool muted)
avsync_adjustment(0), avsync_avg(0),
refreshrate(0),
lastsync(false), repeat_delay(0),
- disp_timecode(0),
+ disp_timecode(0), avsync_audiopaused(false),
// Time Code stuff
prevtc(0), prevrp(0),
savedAudioTimecodeOffset(0),
@@ -1665,10 +1665,22 @@ void MythPlayer::AVSync(VideoFrame *buffer, bool limit_delay)
{
// If we are using software decoding, skip this frame altogether.
VERBOSE(VB_PLAYBACK, LOC + dbg + "dropping frame to catch up.");
+ // Pause the audio if necessary
+ if (!using_null_videoout && !audio.IsPaused())
+ {
+ audio.Pause(true);
+ avsync_audiopaused = true;
+ }
}
}
else if (!using_null_videoout)
{
+ if (avsync_audiopaused)
+ {
+ avsync_audiopaused = false;
+ audio.Pause(false);
+ }
+
// if we get here, we're actually going to do video output
osdLock.lock();
videoOutput->PrepareFrame(buffer, ps, osd);
diff --git a/mythtv/libs/libmythtv/mythplayer.h b/mythtv/libs/libmythtv/mythplayer.h
index 00b28dc..3a7655b 100644
--- a/mythtv/libs/libmythtv/mythplayer.h
+++ b/mythtv/libs/libmythtv/mythplayer.h
@@ -696,6 +696,7 @@ class MPUBLIC MythPlayer
bool decode_extra_audio;
int repeat_delay;
int64_t disp_timecode;
+ bool avsync_audiopaused;
// Time Code stuff
int prevtc; ///< 32 bit timecode if last VideoFrame shown