Skip to content
Browse files

DVDRingBuffer: Release the ringbuffer writelock when waiting.

This is a backport of fd5e33a from master, with 0.24
specific fixes for the different code structure.

Closes #9780
  • Loading branch information...
1 parent 3657f31 commit 4dec7cf2c709b3a17c998b6cb06b7b97fda6ed75 Mark Kendall committed
View
12 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
View
4 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);
View
2 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
View
4 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;

0 comments on commit 4dec7cf

Please sign in to comment.
Something went wrong with that request. Please try again.