Skip to content

Commit

Permalink
Couple patches by Anduin Withers (myth_system(), cleanup in rankprogr…
Browse files Browse the repository at this point in the history
…ams.cpp).

git-svn-id: http://svn.mythtv.org/svn/trunk@2030 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information
Isaac Richards committed Aug 13, 2003
1 parent 78fe75f commit a4f7807
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 19 deletions.
4 changes: 2 additions & 2 deletions mythtv/libs/libmyth/libmyth.pro
Expand Up @@ -38,8 +38,8 @@ using_alsa {

using_lirc {
DEFINES += USE_LIRC
HEADERS += lirc.h
SOURCES += lirc.cpp
HEADERS += lirc.h lircevent.h
SOURCES += lirc.cpp lircevent.cpp
}

INSTALLS += inc
40 changes: 40 additions & 0 deletions mythtv/libs/libmyth/lircevent.cpp
@@ -0,0 +1,40 @@
#include <qapplication.h>
#include <qstring.h>
#include "mythcontext.h"

#include "lircevent.h"

LircEventLock::LircEventLock(bool lock_events)
: events_locked(false)
{
if (lock_events)
lock();
}

LircEventLock::~LircEventLock()
{
if (events_locked)
unlock();
}

void LircEventLock::lock()
{
MythMainWindow *mw = gContext->GetMainWindow();
if (mw)
{
events_locked = true;
QApplication::postEvent((QObject *)mw,
new LircMuteEvent(events_locked));
}
}

void LircEventLock::unlock()
{
MythMainWindow *mw = gContext->GetMainWindow();
if (mw)
{
events_locked = false;
QApplication::postEvent((QObject *)mw,
new LircMuteEvent(events_locked));
}
}
28 changes: 28 additions & 0 deletions mythtv/libs/libmyth/lircevent.h
Expand Up @@ -2,6 +2,7 @@
#define LIRCEVENT_H_

const int kLircKeycodeEventType = 23423;
const int kLircMuteEventType = 23424;

class LircKeycodeEvent : public QCustomEvent
{
Expand Down Expand Up @@ -31,5 +32,32 @@ class LircKeycodeEvent : public QCustomEvent
bool keydown;
};

class LircMuteEvent : public QCustomEvent
{
public:
LircMuteEvent(bool mute_events) : QCustomEvent(kLircMuteEventType),
mute_lirc_events(mute_events) {}

bool eventsMuted()
{
return mute_lirc_events;
}

private:
bool mute_lirc_events;
};

class LircEventLock
{
public:
LircEventLock(bool lock_events = true);
~LircEventLock();
void lock();
void unlock();

private:
bool events_locked;
};

#endif

2 changes: 1 addition & 1 deletion mythtv/libs/libmyth/mythcontext.h
Expand Up @@ -52,7 +52,7 @@ class MythEvent : public QCustomEvent
QString extradata;
};

#define MYTH_BINARY_VERSION "0.11.08062003-1"
#define MYTH_BINARY_VERSION "0.11.08132003-1"
#define MYTH_SCHEMA_VERSION "1003"

extern bool print_verbose_messages;
Expand Down
9 changes: 8 additions & 1 deletion mythtv/libs/libmyth/mythdialogs.cpp
Expand Up @@ -37,6 +37,7 @@ MythMainWindow::MythMainWindow(QWidget *parent, const char *name, bool modal)
: QDialog(parent, name, modal)
{
Init();
ignore_lirc_keys = false;
#ifdef USE_LIRC
pthread_t lirc_tid;
pthread_attr_t attr;
Expand Down Expand Up @@ -124,7 +125,7 @@ void MythMainWindow::keyPressEvent(QKeyEvent *e)
void MythMainWindow::customEvent(QCustomEvent *ce)
{
#ifdef USE_LIRC
if (ce->type() == kLircKeycodeEventType)
if (ce->type() == kLircKeycodeEventType && !ignore_lirc_keys)
{
LircKeycodeEvent *lke = (LircKeycodeEvent *)ce;
int keycode = lke->getKeycode();
Expand Down Expand Up @@ -173,6 +174,12 @@ void MythMainWindow::customEvent(QCustomEvent *ce)
" your key mappings.\n";
}
}

if (ce->type() == kLircMuteEventType)
{
LircMuteEvent *lme = (LircMuteEvent *)ce;
ignore_lirc_keys = lme->eventsMuted();
}
#endif
}

Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmyth/mythdialogs.h
Expand Up @@ -50,6 +50,8 @@ class MythMainWindow : public QDialog
int screenwidth, screenheight;

vector<QWidget *> widgetList;

bool ignore_lirc_keys;
};

class MythDialog : public QFrame
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmyth/themedmenu.cpp
Expand Up @@ -1691,7 +1691,7 @@ void ThemedMenu::handleAction(QString &action)
if (action.left(5) == "EXEC ")
{
QString rest = action.right(action.length() - 5);
system(rest);
myth_system(rest);
}
else if (action.left(7) == "EXECTV ")
{
Expand All @@ -1707,7 +1707,7 @@ void ThemedMenu::handleAction(QString &action)
(const char*)strlist[2],
(const char*)strlist[3]);

system(rest);
myth_system(rest);

strlist = QString("FREE_TUNER %1").arg(cardid);
gContext->SendReceiveStringList(strlist);
Expand Down
13 changes: 13 additions & 0 deletions mythtv/libs/libmyth/util.cpp
Expand Up @@ -19,6 +19,10 @@ extern "C" {
#include <qpainter.h>
#include <qpixmap.h>

#ifdef USE_LIRC
#include "lircevent.h"
#endif

bool WriteStringList(QSocket *socket, QStringList &list)
{
QString str = list.join("[]:[]");
Expand Down Expand Up @@ -255,3 +259,12 @@ QRgb blendColors(QRgb source, QRgb add, int alpha)
return qRgb(sred, sgreen, sblue);
}

int myth_system(const QString &command, int flags)
{
#ifdef USE_LIRC
LircEventLock lirc_lock(!(flags & MYTH_SYSTEM_DONT_BLOCK_LIRC));
#endif

return system(command);
}

3 changes: 3 additions & 0 deletions mythtv/libs/libmyth/util.h
Expand Up @@ -25,4 +25,7 @@ void GetMythTVGeometry(Display *dpy, int screen_num, int *x, int *y,

QRgb blendColors(QRgb source, QRgb add, int alpha);

#define MYTH_SYSTEM_DONT_BLOCK_LIRC (1)
int myth_system(const QString &command, int flags = 0);

#endif
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/NuppelVideoPlayer.cpp
Expand Up @@ -1291,7 +1291,7 @@ void NuppelVideoPlayer::OutputVideoLoop(void)
pthread_mutex_unlock(&video_buflock);

//printf("video waiting for unpause\n");
usleep(5000);
usleep(frame_interval * 2);
continue;
}
video_actually_paused = false;
Expand Down
8 changes: 7 additions & 1 deletion mythtv/libs/libmythtv/programinfo.cpp
Expand Up @@ -75,11 +75,17 @@ ProgramInfo::ProgramInfo(const ProgramInfo &other)
record = NULL;
}

ProgramInfo::~ProgramInfo() {
ProgramInfo::~ProgramInfo()
{
if (record != NULL)
delete record;
}

QString ProgramInfo::MakeUniqueKey(void)
{
return title + ":" + chanid + ":" + startts.toString(Qt::ISODate);
}

void ProgramInfo::ToStringList(QStringList &list)
{
if (title == "")
Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmythtv/programinfo.h
Expand Up @@ -85,6 +85,8 @@ class ProgramInfo
QString GetRecordBasename(void);
QString GetRecordFilename(const QString &prefix);

QString MakeUniqueKey(void);

int CalculateLength(void);

void ToStringList(QStringList &list);
Expand Down
16 changes: 5 additions & 11 deletions mythtv/programs/mythfrontend/programrecpriority.cpp
Expand Up @@ -442,8 +442,7 @@ void RankPrograms::edit(void)

// also set the origRankData with new rank so we don't
// save to db again when we exit
QString key = progInfo->title + ":" + progInfo->chanid + ":" +
progInfo->startts.toString(Qt::ISODate);
QString key = progInfo->MakeUniqueKey();
origRankData[key] = progInfo->rank;

SortList();
Expand Down Expand Up @@ -503,8 +502,7 @@ void RankPrograms::saveRank(void)
for (it = programData.begin(); it != programData.end(); ++it)
{
ProgramRankInfo *progInfo = &(it.data());
QString key = progInfo->title + ":" + progInfo->chanid + ":" +
progInfo->startts.toString(Qt::ISODate);
QString key = progInfo->MakeUniqueKey();

// if this program's rank changed from when we entered
// save new value out to db
Expand Down Expand Up @@ -533,8 +531,7 @@ void RankPrograms::FillList(void)

// save rank value in map so we don't have to save all program's
// rank values when we exit
QString key = (*pgiter)->title + ":" + (*pgiter)->chanid + ":" +
(*pgiter)->startts.toString(Qt::ISODate);
QString key = (*pgiter)->MakeUniqueKey();
origRankData[key] = (*pgiter)->rank;

delete (*pgiter);
Expand Down Expand Up @@ -606,8 +603,7 @@ void RankPrograms::FillList(void)
for (it = programData.begin(); it != programData.end(); ++it)
{
ProgramRankInfo *progInfo = &(it.data());
QString keyB = progInfo->title + ":" + progInfo->chanid + ":" +
progInfo->startts.toString(Qt::ISODate);
QString keyB = progInfo->MakeUniqueKey();
if(keyA == keyB)
{
progInfo->channelRank = channelRank;
Expand Down Expand Up @@ -757,9 +753,7 @@ void RankPrograms::updateList(QPainter *p)
{
ProgramRankInfo *progInfo = &(it.data());

QString key = progInfo->title + ":" +
progInfo->chanid + ":" +
progInfo->startts.toString(Qt::ISODate);
QString key = progInfo->MakeUniqueKey();

int progRank = progInfo->rank.toInt();
int finalRank = progRank + progInfo->channelRank +
Expand Down

0 comments on commit a4f7807

Please sign in to comment.