From b6260f55a0703edca761c212f2eda936e4cb961d Mon Sep 17 00:00:00 2001
From: Richard <peper03@yahoo.com>
Date: Mon, 3 Jun 2013 00:51:28 +0200
Subject: [PATCH] Fixed seeking issues on some DVDs where, for example, trying
to jump backwards could actually cause playback to jump
forwards.
dvdnav_absolute_time_search in libdvdnav (renamed from the original dvdnav_time_search but functionally the same) uses a time offset with a start sector, which will only work if all NAV packets are equally spaced. On at least one DVD that had issues, the distance between consecutive NAV packets ranged from 96 to 457.
The existing mechanism to check whether a seek was successful and, if not, narrow in on the required time was broken when jumping backwards.
---
mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp | 8 ++++----
mythtv/libs/libmythtv/DVD/dvdringbuffer.h | 6 +++---
mythtv/libs/libmythtv/tv_play.cpp | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp b/mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp
index 3f99f3b..5b64e28 100644
|
a
|
b
|
long long DVDRingBuffer::Seek(long long time)
|
| 275 | 275 | } |
| 276 | 276 | else |
| 277 | 277 | { |
| 278 | | m_seektime = (uint64_t)time; |
| 279 | | dvdRet = dvdnav_absolute_time_search(m_dvdnav, m_seektime, 0); |
| | 278 | m_seektime = time; |
| | 279 | dvdRet = dvdnav_absolute_time_search(m_dvdnav, (uint64_t)m_seektime, 0); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | LOG(VB_PLAYBACK, LOG_DEBUG, |
| … |
… |
int DVDRingBuffer::safe_read(void *data, uint sz)
|
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | // update our status |
| 784 | | m_currentTime = (uint)dvdnav_get_current_time(m_dvdnav); |
| | 784 | m_currentTime = dvdnav_get_current_time(m_dvdnav); |
| 785 | 785 | m_currentpos = GetReadPosition(); |
| 786 | 786 | |
| 787 | 787 | if (m_seeking) |
| … |
… |
int DVDRingBuffer::safe_read(void *data, uint sz)
|
| 789 | 789 | |
| 790 | 790 | int relativetime = |
| 791 | 791 | (int)((m_seektime - m_currentTime)/ 90000); |
| 792 | | if (relativetime <= 1) |
| | 792 | if (abs(relativetime) <= 1) |
| 793 | 793 | { |
| 794 | 794 | m_seeking = false; |
| 795 | 795 | m_seektime = 0; |
diff --git a/mythtv/libs/libmythtv/DVD/dvdringbuffer.h b/mythtv/libs/libmythtv/DVD/dvdringbuffer.h
index 9c4b6cf..56a42b3 100644
|
a
|
b
|
class MTV_PUBLIC DVDRingBuffer : public RingBuffer
|
| 129 | 129 | |
| 130 | 130 | virtual void IgnoreWaitStates(bool ignore) { m_skipstillorwait = ignore; } |
| 131 | 131 | void AudioStreamsChanged(bool change) { m_audioStreamsChanged = change; } |
| 132 | | uint GetCurrentTime(void) { return (m_currentTime / 90000); } |
| | 132 | int64_t GetCurrentTime(void) { return (m_currentTime / 90000); } |
| 133 | 133 | uint TitleTimeLeft(void); |
| 134 | 134 | void SetTrack(uint type, int trackNo); |
| 135 | 135 | int GetTrack(uint type); |
| … |
… |
class MTV_PUBLIC DVDRingBuffer : public RingBuffer
|
| 198 | 198 | const char *m_dvdname; |
| 199 | 199 | const char *m_serialnumber; |
| 200 | 200 | bool m_seeking; |
| 201 | | uint64_t m_seektime; |
| 202 | | uint m_currentTime; |
| | 201 | int64_t m_seektime; |
| | 202 | int64_t m_currentTime; |
| 203 | 203 | QMap<uint, uint> m_seekSpeedMap; |
| 204 | 204 | QMap<uint, QList<uint64_t> > m_chapterMap; |
| 205 | 205 | |
diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp
index eebb902..004021f 100644
|
a
|
b
|
void TV::DVDJumpForward(PlayerContext *ctx)
|
| 12945 | 12945 | { |
| 12946 | 12946 | uint titleLength = dvdrb->GetTotalTimeOfTitle(); |
| 12947 | 12947 | uint chapterLength = dvdrb->GetChapterLength(); |
| 12948 | | uint currentTime = dvdrb->GetCurrentTime(); |
| | 12948 | uint currentTime = (uint)dvdrb->GetCurrentTime(); |
| 12949 | 12949 | if ((titleLength == chapterLength) && |
| 12950 | 12950 | (currentTime < (chapterLength - (ctx->jumptime * 60))) && |
| 12951 | 12951 | chapterLength > 300) |