+}
+
+static int x264_initialize_ipc(MUtils::IPCChannel *const ipcChannel)
+{
+ int iResult = 0;
+
+ if((iResult = ipcChannel->initialize()) != MUtils::IPCChannel::RET_SUCCESS_MASTER)
+ {
+ if(iResult == MUtils::IPCChannel::RET_SUCCESS_SLAVE)
+ {
+ qDebug("Simple x264 Launcher is already running, connecting to running instance...");
+ QScopedPointer<IPCThread_Send> messageProducerThread(new IPCThread_Send(ipcChannel));
+ messageProducerThread->start();
+ if(!messageProducerThread->wait(30000))
+ {
+ qWarning("MessageProducer thread has encountered timeout -> going to kill!");
+ messageProducerThread->terminate();
+ messageProducerThread->wait();
+ MUtils::OS::system_message_err(L"Simple x264 Launcher", L"Simple x264 Launcher is already running, but the running instance doesn't respond!");
+ return -1;
+ }
+ return 0;
+ }
+ else
+ {
+ qFatal("The IPC initialization has failed!");
+ return -1;
+ }
+ }
+
+ return 1;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Main function
+///////////////////////////////////////////////////////////////////////////////
+
+static int simple_x264_main(int &argc, char **argv)
+{
+ int iResult = -1;
+
+ //Print logo
+ x264_print_logo();
+
+ //Get CLI arguments
+ const MUtils::OS::ArgumentMap &arguments = MUtils::OS::arguments();
+
+ //Enumerate CLI arguments
+ if(!arguments.isEmpty())
+ {
+ qDebug("Command-Line Arguments:");
+ foreach(const QString &key, arguments.uniqueKeys())
+ {
+ foreach(const QString &val, arguments.values(key))
+ {
+ if(!val.isEmpty())
+ {
+ qDebug("--%s = \"%s\"", MUTILS_UTF8(key), MUTILS_UTF8(val));
+ continue;
+ }
+ qDebug("--%s", MUTILS_UTF8(key));
+ }
+ }
+ qDebug(" ");
+ }