summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Kendall <mkendall@mythtv.org>2011-06-08 09:07:51 (GMT)
committer Mark Kendall <mkendall@mythtv.org>2011-06-08 09:07:51 (GMT)
commit4dec7cf2c709b3a17c998b6cb06b7b97fda6ed75 (patch)
treea03650048a6e260b5647a3b740ec7f2212bf420d
parent3657f313ac1c57ed0df171130bd914717f0084c3 (diff)
DVDRingBuffer: Release the ringbuffer writelock when waiting.
This is a backport of fd5e33a69b630aa9c0b9 from master, with 0.24 specific fixes for the different code structure. Closes #9780
-rw-r--r--mythtv/libs/libmythtv/DVDRingBuffer.cpp12
-rw-r--r--mythtv/libs/libmythtv/DVDRingBuffer.h4
-rw-r--r--mythtv/libs/libmythtv/RingBuffer.cpp2
-rw-r--r--mythtv/libs/libmythtv/RingBuffer.h4
4 files changed, 18 insertions, 4 deletions
diff --git a/mythtv/libs/libmythtv/DVDRingBuffer.cpp b/mythtv/libs/libmythtv/DVDRingBuffer.cpp
index 82522f3..2cfec54 100644
--- a/mythtv/libs/libmythtv/DVDRingBuffer.cpp
+++ b/mythtv/libs/libmythtv/DVDRingBuffer.cpp
@@ -33,7 +33,7 @@ static const char *dvdnav_menu_table[] =
"Part",
};
-DVDRingBufferPriv::DVDRingBufferPriv()
+DVDRingBufferPriv::DVDRingBufferPriv(RingBuffer* ringbuffer)
: m_dvdnav(NULL), m_dvdBlockReadBuf(NULL),
m_dvdFilename(QString::null),
m_dvdBlockRPos(0), m_dvdBlockWPos(0),
@@ -62,7 +62,7 @@ DVDRingBufferPriv::DVDRingBufferPriv()
m_dvdname(NULL), m_serialnumber(NULL),
m_seeking(false), m_seektime(0),
m_currentTime(0),
- m_parent(NULL),
+ m_parent(NULL), m_ringBuffer(ringbuffer),
// Menu/buttons
m_inMenu(false), m_buttonVersion(1), m_buttonStreamID(0),
@@ -289,7 +289,11 @@ void DVDRingBufferPriv::WaitForPlayer(void)
m_playerWait = true;
int count = 0;
while (m_playerWait && count++ < 200)
+ {
+ m_ringBuffer->DVDUnlockRW();
usleep(10000);
+ m_ringBuffer->DVDLockRWForWrite();
+ }
if (m_playerWait)
{
VERBOSE(VB_IMPORTANT, LOC_ERR +
@@ -666,7 +670,9 @@ int DVDRingBufferPriv::safe_read(void *data, unsigned sz)
// pause a little as the dvdnav VM will continue to return
// this event until it has been skipped
+ m_ringBuffer->DVDUnlockRW();
usleep(10000);
+ m_ringBuffer->DVDLockRWForWrite();
// when scanning the file or exiting playback, skip immediately
// otherwise update the timeout in the player
@@ -699,7 +705,9 @@ int DVDRingBufferPriv::safe_read(void *data, unsigned sz)
else
{
m_dvdWaiting = true;
+ m_ringBuffer->DVDUnlockRW();
usleep(10000);
+ m_ringBuffer->DVDLockRWForWrite();
}
// release buffer
diff --git a/mythtv/libs/libmythtv/DVDRingBuffer.h b/mythtv/libs/libmythtv/DVDRingBuffer.h
index b0718dc..1bad915 100644
--- a/mythtv/libs/libmythtv/DVDRingBuffer.h
+++ b/mythtv/libs/libmythtv/DVDRingBuffer.h
@@ -16,6 +16,7 @@ extern "C" {
}
#include "dvdnav/dvdnav.h"
+#include "RingBuffer.h"
/** \class DVDRingBufferPriv
* \brief RingBuffer class for DVD's
@@ -28,7 +29,7 @@ class MythDVDPlayer;
class MPUBLIC DVDRingBufferPriv
{
public:
- DVDRingBufferPriv();
+ DVDRingBufferPriv(RingBuffer* ringbuffer);
virtual ~DVDRingBufferPriv();
// gets
@@ -167,6 +168,7 @@ class MPUBLIC DVDRingBufferPriv
QMap<uint, uint> m_seekSpeedMap;
MythDVDPlayer *m_parent;
+ RingBuffer *m_ringBuffer;
// Private menu/button stuff
bool DVDButtonUpdate(bool b_mode);
diff --git a/mythtv/libs/libmythtv/RingBuffer.cpp b/mythtv/libs/libmythtv/RingBuffer.cpp
index 8b59616..40bbdd8 100644
--- a/mythtv/libs/libmythtv/RingBuffer.cpp
+++ b/mythtv/libs/libmythtv/RingBuffer.cpp
@@ -344,7 +344,7 @@ void RingBuffer::OpenFile(const QString &lfilename, uint retry_ms)
(filename.endsWith(".iso"))))))
{
is_dvd = true;
- dvdPriv = new DVDRingBufferPriv();
+ dvdPriv = new DVDRingBufferPriv(this);
startreadahead = false;
if (filename.left(6) == "dvd://") // 'Play DVD' sends "dvd:/" + dev
diff --git a/mythtv/libs/libmythtv/RingBuffer.h b/mythtv/libs/libmythtv/RingBuffer.h
index ab4b2de..09c5f3a 100644
--- a/mythtv/libs/libmythtv/RingBuffer.h
+++ b/mythtv/libs/libmythtv/RingBuffer.h
@@ -91,6 +91,10 @@ class MPUBLIC RingBuffer : protected QThread
bool IsDVD(void) const;
bool InDVDMenuOrStillFrame(void);
+ // Temporary DVD locking mechanisms (fixed in 0.25)
+ void DVDUnlockRW(void) { rwlock.unlock(); }
+ void DVDLockRWForWrite(void) { rwlock.lockForWrite(); }
+
// BDRingBuffer proxies
bool IsBD(void) const;