Skip to content

Commit

Permalink
DVDRingBuffer: Release the ringbuffer writelock when waiting.
Browse files Browse the repository at this point in the history
This is a backport of fd5e33a from master, with 0.24
specific fixes for the different code structure.

Closes #9780
  • Loading branch information
Mark Kendall committed Jun 8, 2011
1 parent 3657f31 commit 4dec7cf
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
12 changes: 10 additions & 2 deletions mythtv/libs/libmythtv/DVDRingBuffer.cpp
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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 +
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion mythtv/libs/libmythtv/DVDRingBuffer.h
Expand Up @@ -16,6 +16,7 @@ extern "C" {
}

#include "dvdnav/dvdnav.h"
#include "RingBuffer.h"

/** \class DVDRingBufferPriv
* \brief RingBuffer class for DVD's
Expand All @@ -28,7 +29,7 @@ class MythDVDPlayer;
class MPUBLIC DVDRingBufferPriv
{
public:
DVDRingBufferPriv();
DVDRingBufferPriv(RingBuffer* ringbuffer);
virtual ~DVDRingBufferPriv();

// gets
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/RingBuffer.cpp
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions mythtv/libs/libmythtv/RingBuffer.h
Expand Up @@ -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;

Expand Down

0 comments on commit 4dec7cf

Please sign in to comment.