Ticket #2844: lirc.diff

File lirc.diff, 2.6 KB (added by keith@…, 14 years ago)
  • libs/libmythui/mythmainwindow.cpp

     
    5353
    5454#define GESTURE_TIMEOUT 1000
    5555
    56 #ifdef USE_LIRC
    57 static void *SpawnLirc(void *param)
    58 {
    59     QString config_file = MythContext::GetConfDir() + "/lircrc";
    60     if (!QFile::exists(config_file))
    61         config_file = QDir::homeDirPath() + "/.lircrc";
    62 
    63     LircClient *cl = new LircClient((MythMainWindow *)param);
    64     if (!cl->Init(config_file, "mythtv"))
    65         cl->Process();
    66 
    67     return NULL;
    68 }
    69 #endif
    70 
    7156#ifdef USE_JOYSTICK_MENU
    7257static void *SpawnJoystickMenu(void *param)
    7358{
     
    294279    installEventFilter(this);
    295280
    296281#ifdef USE_LIRC
    297     pthread_t lirc_tid;
    298     pthread_attr_t attr;
    299     pthread_attr_init(&attr);
    300     pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
     282    QString lircrc = MythContext::GetConfDir() + "/lircrc";
     283    if (!QFile::exists(lircrc))
     284        lircrc = QDir::homeDirPath() + "/.lircrc";
    301285
    302     pthread_create(&lirc_tid, &attr, SpawnLirc, this);
     286    LircClient *lircClient = new LircClient(this);
     287
     288    if (!lircClient->Init(lircrc, "mythtv"))
     289    {
     290        lircClient->start();
     291    } else {
     292        delete lircClient;
     293    }
    303294#endif
    304295
    305296#ifdef USE_JOYSTICK_MENU
  • libs/libmyth/lirc.cpp

     
    6161    lirc_freeconfig(lircConfig);
    6262}
    6363
    64 void LircClient::Process(void)
     64void LircClient::run()
    6565{
    6666    char *code = 0;
    6767    char *ir = 0;
     
    105105    }
    106106}
    107107
     108
    108109void LircClient::SpawnApp(void)
    109110{
    110111    // Spawn app to thwap led (or what ever the user has picked if
     
    122123    }
    123124}
    124125
     126
  • libs/libmyth/lirc.h

     
    55#include <qobject.h>
    66#include <qsocket.h>
    77#include <qstring.h>
     8#include <qthread.h>
    89
    910#include "mythdialogs.h"
    1011
    11 class MPUBLIC LircClient : public QObject
     12class MPUBLIC LircClient : public QObject, public QThread
    1213{
    1314    Q_OBJECT
    1415  public:
    1516    LircClient(QObject *main_window);
    1617    ~LircClient();
    1718    int Init(const QString &config_file, const QString &program);
    18     void Process(void);
    1919
     20  protected:
     21    void run();
     22
    2023  private:
    2124    void SpawnApp(void);
    2225
    2326    struct lirc_config *lircConfig;
    2427    QObject *mainWindow;
    25     pthread_t pth;
    2628    QString external_app;
    2729};
    2830