Added multi-instance handling to main() function.
This commit is contained in:
parent
66883a749b
commit
fa9b468f92
@ -2,4 +2,4 @@ Simple x264 Launcher was created from the scratch by LoRd_MuldeR <mulder2@gmx.de
|
||||
|
||||
The Qt GUI Toolkit is Copyright (C) 2012 Digia Finland Ltd and/or its subsidiary(-ies). You may use, distribute and copy the Qt GUI Toolkit under the terms of GNU General Public License version 3.
|
||||
|
||||
x264 is Copyright (C) 2003-2012 'x264 project' and is distributed under the terms of GNU General Public License. Avs2YUV was created by Loren Merritt and BugMaster.
|
||||
x264 is Copyright (C) 2003-2014 'x264 project' and is distributed under the terms of GNU General Public License. Avs2YUV was created by Loren Merritt and BugMaster.
|
||||
|
75
src/main.cpp
75
src/main.cpp
@ -21,6 +21,7 @@
|
||||
|
||||
#include "global.h"
|
||||
#include "win_main.h"
|
||||
#include "ipc.h"
|
||||
#include "taskbar7.h"
|
||||
|
||||
//Qt includes
|
||||
@ -33,6 +34,9 @@
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
|
||||
//Forward declaration
|
||||
void handleMultipleInstances(QStringList args, IPC *ipc);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Main function
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -62,7 +66,7 @@ static int x264_main(int argc, char* argv[])
|
||||
|
||||
//Get CLI arguments
|
||||
const QStringList &arguments = x264_arguments();
|
||||
|
||||
|
||||
//Detect CPU capabilities
|
||||
const x264_cpu_t cpuFeatures = x264_detect_cpu_features(arguments);
|
||||
qDebug(" CPU vendor id : %s (Intel: %s)", cpuFeatures.vendor, X264_BOOL(cpuFeatures.intel));
|
||||
@ -71,6 +75,23 @@ static int x264_main(int argc, char* argv[])
|
||||
qDebug("CPU capabilities : MMX=%s, MMXEXT=%s, SSE=%s, SSE2=%s, SSE3=%s, SSSE3=%s, X64=%s", X264_BOOL(cpuFeatures.mmx), X264_BOOL(cpuFeatures.mmx2), X264_BOOL(cpuFeatures.sse), X264_BOOL(cpuFeatures.sse2), X264_BOOL(cpuFeatures.sse3), X264_BOOL(cpuFeatures.ssse3), X264_BOOL(cpuFeatures.x64));
|
||||
qDebug(" Number of CPU's : %d\n", cpuFeatures.count);
|
||||
|
||||
//Initialize the IPC handler class
|
||||
bool firstInstance = false;
|
||||
IPC *ipc = new IPC();
|
||||
if(!ipc->initialize(firstInstance))
|
||||
{
|
||||
if(!firstInstance)
|
||||
{
|
||||
handleMultipleInstances(arguments, ipc);
|
||||
X264_DELETE(ipc);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning("IPC initialization has failed!");
|
||||
}
|
||||
|
||||
//Initialize Qt
|
||||
if(!x264_init_qt(argc, argv))
|
||||
{
|
||||
@ -106,6 +127,58 @@ static int x264_main(int argc, char* argv[])
|
||||
return ret;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Multi-instance handler
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void handleMultipleInstances(QStringList args, IPC *ipc)
|
||||
{
|
||||
bool commandSent = false;
|
||||
|
||||
//Process all command-line arguments
|
||||
while(!args.isEmpty())
|
||||
{
|
||||
const QString current = args.takeFirst();
|
||||
if((current.compare("--add", Qt::CaseInsensitive) == 0) || (current.compare("--add-file", Qt::CaseInsensitive) == 0))
|
||||
{
|
||||
if(!args.isEmpty())
|
||||
{
|
||||
commandSent = true;
|
||||
if(!ipc->sendAsync(IPC::IPC_OPCODE_ADD_FILE, QStringList() << args.takeFirst()))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning("Argument for '--add-file' is missing!");
|
||||
}
|
||||
}
|
||||
else if(current.compare("--add-job", Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(args.size() >= 3)
|
||||
{
|
||||
commandSent = true;
|
||||
if(!ipc->sendAsync(IPC::IPC_OPCODE_ADD_JOB, QStringList() << args.takeFirst() << args.takeFirst() << args.takeFirst()))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning("Argument(s) for '--add-job' are missing!");
|
||||
args.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If no argument has been sent yet, send a ping!
|
||||
if(!commandSent)
|
||||
{
|
||||
ipc->sendAsync(IPC::IPC_OPCODE_PING, QStringList());
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Applicaton entry point
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -26,7 +26,7 @@
|
||||
#define VER_X264_MAJOR 2
|
||||
#define VER_X264_MINOR 2
|
||||
#define VER_X264_PATCH 9
|
||||
#define VER_X264_BUILD 726
|
||||
#define VER_X264_BUILD 727
|
||||
|
||||
#define VER_X264_MINIMUM_REV 2363
|
||||
#define VER_X264_CURRENT_API 140
|
||||
|
Loading…
Reference in New Issue
Block a user