Skip to content

Commit

Permalink
MythPlayer: Pause the audio when the video is lagging.
Browse files Browse the repository at this point in the history
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 afe5669
  • Loading branch information
Mark Kendall committed May 3, 2011
1 parent 56c54fa commit a0bb5e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion mythtv/libs/libmythtv/mythplayer.cpp
Expand Up @@ -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),
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/mythplayer.h
Expand Up @@ -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
Expand Down

0 comments on commit a0bb5e9

Please sign in to comment.