Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix DVD playback when a still timeout is set.
The timeout should start running at the end of the cell not at the beginning.  Usually the cell only contains one frame so there's little difference but where there is video, all the parts of the code that query whether we are in a still get 'true' back right from the beginning of cell.  This can cause stuttering under some circumstances (e.g. VDPAU) because frames are not buffered.
  • Loading branch information
peper03 committed Jul 9, 2013
1 parent e06a765 commit 010a87d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
30 changes: 12 additions & 18 deletions mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp
Expand Up @@ -735,7 +735,8 @@ int DVDRingBuffer::safe_read(void *data, uint sz)
m_lastStill = m_still;
uint32_t pos;
uint32_t length;
m_still = dvdnav_get_next_still_flag(m_dvdnav);
uint32_t stillTimer = dvdnav_get_next_still_flag(m_dvdnav);
m_still = 0;
m_titleParts = 0;
dvdnav_current_title_info(m_dvdnav, &m_title, &m_part);
dvdnav_get_number_of_parts(m_dvdnav, m_title, &m_titleParts);
Expand All @@ -758,8 +759,8 @@ int DVDRingBuffer::safe_read(void *data, uint sz)
"#%1 Menu %2 Length %3")
.arg(cell_event->cellN).arg(m_inMenu ? "Yes" : "No")
.arg((float)cell_event->cell_length / 90000.0f,0,'f',1));
QString still = m_still ? ((m_still < 0xff) ?
QString("Stillframe: %1 seconds").arg(m_still) :
QString still = stillTimer ? ((stillTimer < 0xff) ?
QString("Stillframe: %1 seconds").arg(stillTimer) :
QString("Infinite stillframe")) :
QString("Length: %1 seconds")
.arg((float)m_pgcLength / 90000.0f, 0, 'f', 1);
Expand All @@ -777,18 +778,17 @@ int DVDRingBuffer::safe_read(void *data, uint sz)

// wait unless it is a transition from one normal video cell to
// another or the same menu id
if (((m_still != m_lastStill) || (m_title != m_lastTitle)) &&
if ((m_title != m_lastTitle) &&
!((m_title == 0 && m_lastTitle == 0) &&
(m_part == m_lastPart)))
{
WaitForPlayer();
}

// Make sure the still frame timer is updated (if this isn't
// a still frame, this will ensure the timer knows about it).
// Make sure the still frame timer is reset.
if (m_parent)
{
m_parent->SetStillFrameTimeout(m_still);
m_parent->SetStillFrameTimeout(0);
}

// clear menus/still frame selections
Expand Down Expand Up @@ -1126,14 +1126,7 @@ int DVDRingBuffer::safe_read(void *data, uint sz)
dvdnav_still_event_t* still =
(dvdnav_still_event_t*)(blockBuf);

// sense check
if (!m_still)
LOG(VB_GENERAL, LOG_WARNING, LOC + "DVDNAV_STILL_FRAME in "
"cell that is not marked as a still frame");

if (still->length != m_still)
LOG(VB_GENERAL, LOG_WARNING, LOC + "DVDNAV_STILL_FRAME "
"length does not match cell still length");
m_still = still->length;

// pause a little as the dvdnav VM will continue to return
// this event until it has been skipped
Expand All @@ -1147,15 +1140,14 @@ int DVDRingBuffer::safe_read(void *data, uint sz)
SkipStillFrame();
else if (m_parent)
{
if ((still->length > 0) && (still->length < 0xff))
m_parent->SetStillFrameTimeout(still->length);
m_parent->SetStillFrameTimeout(m_still);
}

// debug
if (!stillSeen)
{
LOG(VB_PLAYBACK, LOG_DEBUG, LOC + QString("DVDNAV_STILL_FRAME (%1)")
.arg(still->length));
.arg(m_still));
stillSeen = true;
}

Expand Down Expand Up @@ -1301,6 +1293,8 @@ void DVDRingBuffer::SkipStillFrame(void)
{
QMutexLocker locker(&m_seekLock);
LOG(VB_PLAYBACK, LOG_INFO, LOC + "Skipping still frame.");

m_still = 0;
dvdnav_still_skip(m_dvdnav);

// Make sure the still frame timer is disabled.
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/DVD/dvdringbuffer.h
Expand Up @@ -105,6 +105,7 @@ class MTV_PUBLIC DVDRingBuffer : public RingBuffer
bool PGCLengthChanged(void);
bool CellChanged(void);
virtual bool IsInStillFrame(void) const { return m_still > 0; }
bool IsStillFramePending(void) const { return dvdnav_get_next_still_flag(m_dvdnav) > 0; }
bool AudioStreamsChanged(void) const { return m_audioStreamsChanged; }
bool IsWaiting(void) const { return m_dvdWaiting; }
int NumPartsInTitle(void) const { return m_titleParts; }
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/DVD/mythdvdplayer.cpp
Expand Up @@ -186,7 +186,7 @@ bool MythDVDPlayer::VideoLoop(void)
}

// the still frame is treated as a pause frame
if (player_ctx->buffer->DVD()->IsInStillFrame())
if (player_ctx->buffer->DVD()->IsStillFramePending())
{
// ensure we refresh the pause frame
if (!dvd_stillframe_showing)
Expand Down

0 comments on commit 010a87d

Please sign in to comment.