Skip to content

Commit

Permalink
Fix MythIOWrapper compile following 82f7dda.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Kendall committed Feb 4, 2011
1 parent 640c82f commit 752ae31
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 41 deletions.
15 changes: 8 additions & 7 deletions mythtv/libs/libmythtv/bdringbuffer.cpp
Expand Up @@ -273,34 +273,35 @@ 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();

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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
59 changes: 29 additions & 30 deletions mythtv/libs/libmythtv/mythiowrapper.cpp
Expand Up @@ -53,10 +53,38 @@ QMultiHash<QString, Callback> 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
Expand All @@ -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 +
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions mythtv/libs/libmythtv/mythiowrapper.h
Expand Up @@ -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);
Expand Down

0 comments on commit 752ae31

Please sign in to comment.