OSDN Git Service

Updated copyright year.
[x264-launcher/x264-launcher.git] / src / thread_ipc_recv.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2022 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
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, but always including the *additional*
9 // restrictions defined in the "License.txt" file.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 //
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
22
23 #include "thread_ipc_recv.h"
24
25 //Internal
26 #include "Global.h"
27 #include "cli.h"
28 #include "ipc.h"
29
30 //MUtils
31 #include <MUtils/Global.h>
32 #include <MUtils/IPCChannel.h>
33 #include <MUtils/OSSupport.h>
34
35 //Qt
36 #include <QStringList>
37 #include <QApplication>
38 #include <QFileInfo>
39 #include <QDir>
40
41 //CRT
42 #include <limits.h>
43
44 ////////////////////////////////////////////////////////////
45 // Constructor & Destructor
46 ////////////////////////////////////////////////////////////
47
48 IPCThread_Recv::IPCThread_Recv(MUtils::IPCChannel *const ipcChannel)
49 :
50         m_ipcChannel(ipcChannel)
51 {
52         m_stopFlag = false;
53 }
54
55 IPCThread_Recv::~IPCThread_Recv(void)
56 {
57 }
58
59 ////////////////////////////////////////////////////////////
60 // Thread Main
61 ////////////////////////////////////////////////////////////
62
63 void IPCThread_Recv::run(void)
64 {
65         setTerminationEnabled(true);
66         AbstractThread::run();
67 }
68
69 int IPCThread_Recv::threadMain(void)
70 {
71         QStringList params;
72         quint32 command, flags;
73
74         while(!m_stopFlag)
75         {
76                 if(m_ipcChannel->read(command, flags, params))
77                 {
78                         if(command != IPC_OPCODE_NOOP)
79                         {
80                                 emit receivedCommand(command, params, flags);
81                         }
82                 }
83                 else
84                 {
85                         qWarning("Failed to read next IPC message!");
86                         break;
87                 }
88         }
89
90         return 1;
91 }
92
93 ////////////////////////////////////////////////////////////
94 // Public Methods
95 ////////////////////////////////////////////////////////////
96
97 void IPCThread_Recv::stop(void)
98 {
99         if(!m_stopFlag)
100         {
101                 m_stopFlag = true;
102                 m_ipcChannel->send(0, 0, QStringList());
103         }
104 }
105
106 ////////////////////////////////////////////////////////////
107 // EVENTS
108 ////////////////////////////////////////////////////////////
109
110 /*NONE*/