///////////////////////////////////////////////////////////////////////////////
// Simple x264 Launcher
-// Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2020 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
#pragma once
-#include <QThread>
+//IPC Commands
+static const quint32 IPC_OPCODE_NOOP = 0;
+static const quint32 IPC_OPCODE_PING = 1;
+static const quint32 IPC_OPCODE_ADD_FILE = 2;
+static const quint32 IPC_OPCODE_ADD_JOB = 3;
+static const quint32 IPC_OPCODE_MAX = 4;
-class QSharedMemory;
-class QStringList;
-class QSystemSemaphore;
-class IPCSendThread;
-class IPCReceiveThread;
-
-class IPC : public QObject
-{
- Q_OBJECT
- friend class IPCReceiveThread;
- friend class IPCSendThread;
-
-public:
- IPC(void);
- ~IPC(void);
-
- static const int IPC_OPCODE_PING = 0;
- static const int IPC_OPCODE_ADD_FILE = 1;
- static const int IPC_OPCODE_ADD_JOB = 2;
- static const int IPC_OPCODE_MAX = 3;
-
- bool initialize(bool &firstInstance);
- bool sendAsync(const int &command, const QStringList &args, const int timeout = 5000);
-
- inline bool isInitialized(void) { return (m_initialized >= 0); }
-
-public slots:
- bool startListening(void);
- bool stopListening(void);
-
-signals:
- void receivedCommand(const int &command, const QStringList &args);
-
-protected:
- bool popCommand(int &command, QStringList &args);
- bool pushCommand(const int &command, const QStringList *args);
-
- int m_initialized;
-
- QSharedMemory *m_sharedMemory;
- QSystemSemaphore *m_semaphoreRd;
- QSystemSemaphore *m_semaphoreWr;
- IPCReceiveThread *m_recvThread;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-// Utility Classes
-///////////////////////////////////////////////////////////////////////////////
-
-class IPCSendThread : public QThread
-{
- Q_OBJECT
- friend class IPC;
-
-protected:
- IPCSendThread(IPC *ipc, const int &command, const QStringList &args);
- IPCSendThread::~IPCSendThread(void);
-
- inline bool result(void) { return m_result; }
-
- virtual void run(void);
-
-private:
- volatile bool m_result;
- IPC *const m_ipc;
- const int m_command;
- const QStringList *m_args;
-};
-
-class IPCReceiveThread : public QThread
-{
- Q_OBJECT
- friend class IPC;
-
-protected:
- IPCReceiveThread(IPC *ipc);
- inline void stop(void) { m_stopped = true; }
-
- virtual void run(void);
-
-signals:
- void receivedCommand(const int &command, const QStringList &args);
-
-private:
- void receiveLoop(void);
- volatile bool m_stopped;
- IPC *const m_ipc;
-};
+//IPC Flags
+static const quint32 IPC_FLAG_FORCE_START = 0x00000001;
+static const quint32 IPC_FLAG_FORCE_ENQUEUE = 0x00000002;