Skip to content

Commit b49f6e0

Browse files
author
Mark Kendall
committed
Bluray: Provide some UI feedback on startup progress.
This uses the mythfile_open callback to update the BDRingBuffer object every time a file is successfully opened by libbluray during the initial open/initialisation stage. The callback then calls processEvents - which will update the TvPlayWindow widget as main UI drawing is still enabled at this stage. This relies on the theme using a progress bar widget in TvPlayWindow - which is pretty much restricted to Graphite at the moment.
1 parent 09dad5d commit b49f6e0

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

mythtv/libs/libmythtv/bdringbuffer.cpp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include <QImage>
22
#include <QDir>
3-
4-
#include <cstring>
3+
#include <QCoreApplication>
54

65
#include "bdnav/mpls_parse.h"
76
#include "bdnav/meta_parse.h"
@@ -17,6 +16,7 @@
1716
#include "mythdirs.h"
1817
#include "bluray.h"
1918
#include "tv.h" // for actions
19+
#include "mythiowrapper.h"
2020

2121
#define LOC QString("BDRingBuf: ")
2222
#define LOC_WARN QString("BDRingBuf Warning: ")
@@ -29,15 +29,23 @@ static void HandleOverlayCallback(void *data, const bd_overlay_s *const overlay)
2929
bdrb->SubmitOverlay(overlay);
3030
}
3131

32+
static void file_opened_callback(void* bdr)
33+
{
34+
BDRingBuffer *obj = (BDRingBuffer*)bdr;
35+
if (obj)
36+
obj->ProgressUpdate();
37+
}
38+
3239
BDRingBuffer::BDRingBuffer(const QString &lfilename)
3340
: bdnav(NULL), m_isHDMVNavigation(false), m_tryHDMVNavigation(false),
3441
m_topMenuSupported(false), m_firstPlaySupported(false),
3542
m_numTitles(0), m_titleChanged(false), m_playerWait(false),
3643
m_ignorePlayerWait(true),
3744
m_stillTime(0), m_stillMode(BLURAY_STILL_NONE),
38-
m_infoLock(QMutex::Recursive)
45+
m_infoLock(QMutex::Recursive), m_mainThread(NULL)
3946
{
4047
m_tryHDMVNavigation = NULL != getenv("MYTHTV_HDMV");
48+
m_mainThread = QThread::currentThread();
4149
OpenFile(lfilename);
4250
}
4351

@@ -249,11 +257,27 @@ bool BDRingBuffer::HandleAction(const QStringList &actions, int64_t pts)
249257
return handled;
250258
}
251259

260+
void BDRingBuffer::ProgressUpdate(void)
261+
{
262+
// This thread check is probably unnecessary as processEvents should
263+
// only handle events in the calling thread - and not all threads
264+
if (QThread::currentThread() == m_mainThread)
265+
if (qApp->hasPendingEvents())
266+
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
267+
}
268+
252269
bool BDRingBuffer::OpenFile(const QString &lfilename, uint retry_ms)
253270
{
254271
VERBOSE(VB_IMPORTANT, LOC + QString("Opened BDRingBuffer device at %1")
255272
.arg(lfilename.toLatin1().data()));
256273

274+
// Ask mythiowrapper to update this object on file open progress. Opening
275+
// a bluray disc can involve opening several hundred files which can take
276+
// several minutes when the disc structure is remote. The callback allows
277+
// us to 'kick' the main UI - as the 'please wait' widget is still visible
278+
// at this stage
279+
mythfile_open_register_callback(this, file_opened_callback);
280+
257281
QMutexLocker locker(&m_infoLock);
258282
rwlock.lockForWrite();
259283

@@ -271,6 +295,7 @@ bool BDRingBuffer::OpenFile(const QString &lfilename, uint retry_ms)
271295
if (!bdnav)
272296
{
273297
rwlock.unlock();
298+
mythfile_open_register_callback(this, NULL);
274299
return false;
275300
}
276301

@@ -431,6 +456,7 @@ bool BDRingBuffer::OpenFile(const QString &lfilename, uint retry_ms)
431456

432457
rwlock.unlock();
433458

459+
mythfile_open_register_callback(this, NULL);
434460
return true;
435461
}
436462

mythtv/libs/libmythtv/bdringbuffer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class MPUBLIC BDRingBuffer : public RingBuffer
5151
BDRingBuffer(const QString &lfilename);
5252
virtual ~BDRingBuffer();
5353

54+
void ProgressUpdate(void);
55+
5456
// Player interaction
5557
bool BDWaitingForPlayer(void) { return m_playerWait; }
5658
void SkipBDWaitingForPlayer(void) { m_playerWait = false; }
@@ -172,5 +174,7 @@ class MPUBLIC BDRingBuffer : public RingBuffer
172174
QHash<uint32_t,BLURAY_TITLE_INFO*> m_cachedTitleInfo;
173175
QHash<uint32_t,BLURAY_TITLE_INFO*> m_cachedPlaylistInfo;
174176
QMutex m_infoLock;
177+
178+
QThread *m_mainThread;
175179
};
176180
#endif

0 commit comments

Comments
 (0)