diff --git a/mythtv/libs/libmythtv/bdringbuffer.cpp b/mythtv/libs/libmythtv/bdringbuffer.cpp index 849ce1c4497..b081f3d3e7d 100644 --- a/mythtv/libs/libmythtv/bdringbuffer.cpp +++ b/mythtv/libs/libmythtv/bdringbuffer.cpp @@ -273,15 +273,18 @@ void BDRingBuffer::ProgressUpdate(void) bool BDRingBuffer::OpenFile(const QString &lfilename, uint retry_ms) { + filename = lfilename; + VERBOSE(VB_IMPORTANT, LOC + QString("Opened BDRingBuffer device at %1") - .arg(lfilename.toLatin1().data())); + .arg(filename.toLatin1().data())); // Ask mythiowrapper to update this object on file open progress. Opening // a bluray disc can involve opening several hundred files which can take // several minutes when the disc structure is remote. The callback allows // us to 'kick' the main UI - as the 'please wait' widget is still visible // at this stage - mythfile_open_register_callback(lfilename, this, file_opened_callback); + mythfile_open_register_callback(filename.toLatin1().data(), this, + file_opened_callback); QMutexLocker locker(&m_infoLock); rwlock.lockForWrite(); @@ -289,18 +292,16 @@ bool BDRingBuffer::OpenFile(const QString &lfilename, uint retry_ms) if (bdnav) close(); - filename = lfilename; - QString keyfile = QString("%1/KEYDB.cfg").arg(GetConfDir()); QByteArray keyarray = keyfile.toAscii(); const char *keyfilepath = keyarray.data(); - bdnav = bd_open(lfilename.toLatin1().data(), keyfilepath); + bdnav = bd_open(filename.toLatin1().data(), keyfilepath); if (!bdnav) { rwlock.unlock(); - mythfile_open_register_callback(lfilename, this, NULL); + mythfile_open_register_callback(filename.toLatin1().data(), this, NULL); return false; } @@ -461,7 +462,7 @@ bool BDRingBuffer::OpenFile(const QString &lfilename, uint retry_ms) rwlock.unlock(); - mythfile_open_register_callback(lfilename, this, NULL); + mythfile_open_register_callback(filename.toLatin1().data(), this, NULL); return true; } diff --git a/mythtv/libs/libmythtv/mythiowrapper.cpp b/mythtv/libs/libmythtv/mythiowrapper.cpp index 671e69b3c9c..3a294cf16a8 100644 --- a/mythtv/libs/libmythtv/mythiowrapper.cpp +++ b/mythtv/libs/libmythtv/mythiowrapper.cpp @@ -53,10 +53,38 @@ QMultiHash m_fileOpenCallbacks; #define LOC QString("mythiowrapper: ") #define LOC_ERR QString("mythiowrapper: ERROR: ") -void mythfile_open_register_callback(const QString &path, void* object, +///////////////////////////////////////////////////////////////////////////// + +extern "C" { + +static int getNextFileID(void) +{ + int id = 100000; + + for (; id < maxID; ++id) + { + if ((!m_localfiles.contains(id)) && + (!m_remotefiles.contains(id)) && + (!m_ringbuffers.contains(id))) + break; + } + + if (id == maxID) + { + VERBOSE(VB_IMPORTANT, LOC_ERR + "getNextFileID(), too " + "many files are open."); + } + + VERBOSE(VB_FILE+VB_EXTRA, LOC + QString("getNextFileID() = %1").arg(id)); + + return id; +} + +void mythfile_open_register_callback(const char *pathname, void* object, callback_t func) { m_callbackLock.lock(); + QString path(pathname); if (m_fileOpenCallbacks.contains(path)) { // if we already have a callback registered for this path with this @@ -78,8 +106,6 @@ void mythfile_open_register_callback(const QString &path, void* object, } } - QString new_path = path; - new_path.detach(); Callback new_callback(object, func); m_fileOpenCallbacks.insert(path, new_callback); VERBOSE(VB_PLAYBACK, LOC + @@ -90,33 +116,6 @@ void mythfile_open_register_callback(const QString &path, void* object, m_callbackLock.unlock(); } -///////////////////////////////////////////////////////////////////////////// - -extern "C" { - -static int getNextFileID(void) -{ - int id = 100000; - - for (; id < maxID; ++id) - { - if ((!m_localfiles.contains(id)) && - (!m_remotefiles.contains(id)) && - (!m_ringbuffers.contains(id))) - break; - } - - if (id == maxID) - { - VERBOSE(VB_IMPORTANT, LOC_ERR + "getNextFileID(), too " - "many files are open."); - } - - VERBOSE(VB_FILE+VB_EXTRA, LOC + QString("getNextFileID() = %1").arg(id)); - - return id; -} - int mythfile_check(int id) { VERBOSE(VB_FILE+VB_EXTRA, diff --git a/mythtv/libs/libmythtv/mythiowrapper.h b/mythtv/libs/libmythtv/mythiowrapper.h index bb0becf55bf..4c355a46d40 100644 --- a/mythtv/libs/libmythtv/mythiowrapper.h +++ b/mythtv/libs/libmythtv/mythiowrapper.h @@ -6,14 +6,14 @@ #include "mythexp.h" -typedef void (*callback_t)(void*); -void mythfile_open_register_callback(const QString &path, void* object, - callback_t func); - #ifdef __cplusplus extern "C" { #endif +typedef void (*callback_t)(void*); +void mythfile_open_register_callback(const char *pathname, void* object, + callback_t func); + int mythfile_check(int fileID); int mythfile_open(const char *pathname, int flags); int mythfile_close(int fileID);