1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
29 class QSystemSemaphore;
32 class IPCReceiveThread;
36 static const int IPC_OPCODE_PING = 0;
37 static const int IPC_OPCODE_ADD_FILE = 1;
38 static const int IPC_OPCODE_ADD_JOB = 2;
39 static const int IPC_OPCODE_MAX = 3;
42 static const unsigned int IPC_FLAG_FORCE_START = 0x00000001;
43 static const unsigned int IPC_FLAG_FORCE_ENQUEUE = 0x00000002;
45 ///////////////////////////////////////////////////////////////////////////////
47 ///////////////////////////////////////////////////////////////////////////////
49 class IPC : public QObject
57 bool initialize(bool &firstInstance);
58 bool sendAsync(const int &command, const QStringList &args, const unsigned int &flags = 0);
59 bool isInitialized(void);
60 bool isListening(void);
63 bool startListening(void);
64 bool stopListening(void);
67 void receivedCommand(const int &command, const QStringList &args, const quint32 &flags);
71 IPCReceiveThread *m_recvThread;
75 ///////////////////////////////////////////////////////////////////////////////
77 ///////////////////////////////////////////////////////////////////////////////
79 class IPCSendThread : public QThread
85 IPCSendThread(IPCCore *ipc, const int &command, const QStringList &args, const unsigned int &flags);
86 IPCSendThread::~IPCSendThread(void);
88 inline bool result(void) { return m_result; }
89 virtual void run(void);
92 volatile bool m_result;
95 const unsigned int m_flags;
96 const QStringList *m_args;
99 class IPCReceiveThread : public QThread
105 IPCReceiveThread(IPCCore *ipc);
106 ~IPCReceiveThread(void);
108 inline void stop(void) { m_stopped = true; }
109 virtual void run(void);
112 void receivedCommand(const int &command, const QStringList &args, const quint32 &flags);
115 void receiveLoop(void);
116 volatile bool m_stopped;
117 IPCCore *const m_ipc;