mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-24 11:54:01 +00:00
Made the process priority selectable.
This commit is contained in:
parent
15ce684a73
commit
854203a7a5
@ -1,3 +1,8 @@
|
|||||||
|
2004-03-09 Moritz Bunkus <moritz@bunkus.org>
|
||||||
|
|
||||||
|
* mkvmerge/mmg: new feature: Made the process priority selectable
|
||||||
|
and default to 'normal' again (was 'lower' before).
|
||||||
|
|
||||||
2004-03-07 Moritz Bunkus <moritz@bunkus.org>
|
2004-03-07 Moritz Bunkus <moritz@bunkus.org>
|
||||||
|
|
||||||
* mmg: new feature: mmg will ask for confirmation before
|
* mmg: new feature: mmg will ask for confirmation before
|
||||||
|
@ -355,7 +355,7 @@ The default is 'zlib' compression.
|
|||||||
Other options:
|
Other options:
|
||||||
.TP
|
.TP
|
||||||
\fB\-i\fR, \fB\-\-identify\fR <\fIfilename\fR>
|
\fB\-i\fR, \fB\-\-identify\fR <\fIfilename\fR>
|
||||||
Will let mkvmerge probe the single file and report its type, the tracks
|
Will let \fBmkvmerge\fR probe the single file and report its type, the tracks
|
||||||
contained in the file and their track IDs. If this option is used then the
|
contained in the file and their track IDs. If this option is used then the
|
||||||
only other option allowed is the filename.
|
only other option allowed is the filename.
|
||||||
.TP
|
.TP
|
||||||
@ -366,6 +366,13 @@ Lists supported input file types.
|
|||||||
Lists all languages and their ISO639-2 code which can be used with the
|
Lists all languages and their ISO639-2 code which can be used with the
|
||||||
\fB\-\-language\fR option.
|
\fB\-\-language\fR option.
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-\-priority\fR <\fIpriority\fR>
|
||||||
|
Sets the process priority that \fBmkvmerge\fR runs with. Valid values are
|
||||||
|
"lowest", "lower", "normal", "higher" and "highest". If nothing is given then
|
||||||
|
"normal" is used. On Unix like systems \fBmkvmerge\fR will use the nice(2)
|
||||||
|
function. Therefore only the super user can use "higher" and "highest". On
|
||||||
|
Windows all values are useable for every user.
|
||||||
|
.TP
|
||||||
\fB\-h\fR, \fB\-\-help\fR
|
\fB\-h\fR, \fB\-\-help\fR
|
||||||
Show usage information.
|
Show usage information.
|
||||||
.TP
|
.TP
|
||||||
|
@ -334,6 +334,7 @@ usage() {
|
|||||||
" -l, --list-types Lists supported input file types.\n"
|
" -l, --list-types Lists supported input file types.\n"
|
||||||
" --list-languages Lists all ISO639 languages and their\n"
|
" --list-languages Lists all ISO639 languages and their\n"
|
||||||
" ISO639-2 codes.\n"
|
" ISO639-2 codes.\n"
|
||||||
|
" --priority <priority> Set the priority mkvmerge runs with.\n"
|
||||||
" -h, --help Show this help.\n"
|
" -h, --help Show this help.\n"
|
||||||
" -V, --version Show version information.\n"
|
" -V, --version Show version information.\n"
|
||||||
" @optionsfile Reads additional command line options from\n"
|
" @optionsfile Reads additional command line options from\n"
|
||||||
@ -1408,6 +1409,60 @@ identify(const char *filename) {
|
|||||||
file->reader->identify();
|
file->reader->identify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** \brief Sets the priority mkvmerge runs with
|
||||||
|
*
|
||||||
|
* Depending on the OS different functions are used. On Unix like systems
|
||||||
|
* the process is being nice'd if priority is negative ( = less important).
|
||||||
|
* Only the super user can increase the priority, but you shouldn't do
|
||||||
|
* such work as root anyway.
|
||||||
|
* On Windows SetPriorityClass is used.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
set_process_priority(int priority) {
|
||||||
|
#if defined(SYS_WINDOWS)
|
||||||
|
switch (priority) {
|
||||||
|
case -2:
|
||||||
|
SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS);
|
||||||
|
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE);
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS);
|
||||||
|
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL);
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS);
|
||||||
|
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS);
|
||||||
|
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
|
||||||
|
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
switch (priority) {
|
||||||
|
case -2:
|
||||||
|
nice(19);
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
nice(2);
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
nice(0);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
nice(-2);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
nice(-5);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/** \brief Parses and handles command line arguments
|
/** \brief Parses and handles command line arguments
|
||||||
*
|
*
|
||||||
* Also probes input files for their type and creates the appropriate
|
* Also probes input files for their type and creates the appropriate
|
||||||
@ -1424,6 +1479,8 @@ identify(const char *filename) {
|
|||||||
static void
|
static void
|
||||||
parse_args(int argc,
|
parse_args(int argc,
|
||||||
char **argv) {
|
char **argv) {
|
||||||
|
const char *process_priorities[5] = {"lowest", "lower", "normal", "higher",
|
||||||
|
"highest"};
|
||||||
track_info_c *ti;
|
track_info_c *ti;
|
||||||
int i, j;
|
int i, j;
|
||||||
filelist_t *file;
|
filelist_t *file;
|
||||||
@ -1544,6 +1601,22 @@ parse_args(int argc,
|
|||||||
engage_hacks(next_arg);
|
engage_hacks(next_arg);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
} else if (!strcmp(this_arg, "--priority")) {
|
||||||
|
bool found;
|
||||||
|
|
||||||
|
if (next_arg == NULL)
|
||||||
|
mxerror("'--priority' lacks its argument.\n");
|
||||||
|
found = false;
|
||||||
|
for (j = 0; j < 5; j++)
|
||||||
|
if (!strcmp(next_arg, process_priorities[j])) {
|
||||||
|
set_process_priority(j - 2);
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
mxerror("'%s' is not a valid priority class.\n", next_arg);
|
||||||
|
i++;
|
||||||
|
|
||||||
} else if (!strcmp(this_arg, "-q"))
|
} else if (!strcmp(this_arg, "-q"))
|
||||||
verbose = 0;
|
verbose = 0;
|
||||||
|
|
||||||
@ -2123,7 +2196,7 @@ handle_args(int argc,
|
|||||||
*
|
*
|
||||||
* Both platform dependant and independant initialization is done here.
|
* Both platform dependant and independant initialization is done here.
|
||||||
* For Unix like systems a signal handler is installed. The locale's
|
* For Unix like systems a signal handler is installed. The locale's
|
||||||
* \c LC_CTYPE is set and the process priority is decreased.
|
* \c LC_CTYPE is set.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
setup() {
|
setup() {
|
||||||
@ -2136,12 +2209,6 @@ setup() {
|
|||||||
#if defined(SYS_UNIX) || defined(COMP_CYGWIN) || defined(SYS_APPLE)
|
#if defined(SYS_UNIX) || defined(COMP_CYGWIN) || defined(SYS_APPLE)
|
||||||
signal(SIGUSR1, sighandler);
|
signal(SIGUSR1, sighandler);
|
||||||
signal(SIGINT, sighandler);
|
signal(SIGINT, sighandler);
|
||||||
|
|
||||||
nice(2);
|
|
||||||
#endif
|
|
||||||
#if defined(SYS_WINDOWS)
|
|
||||||
SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS);
|
|
||||||
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
@ -851,6 +851,11 @@ mmg_dialog::update_command_line() {
|
|||||||
clargs.Add(tc_output->GetValue());
|
clargs.Add(tc_output->GetValue());
|
||||||
args_start = clargs.Count();
|
args_start = clargs.Count();
|
||||||
|
|
||||||
|
if (settings_page->cob_priority->GetValue() != wxS("normal")) {
|
||||||
|
clargs.Add("--priority");
|
||||||
|
clargs.Add(settings_page->cob_priority->GetValue());
|
||||||
|
}
|
||||||
|
|
||||||
for (fidx = 0; fidx < files.size(); fidx++) {
|
for (fidx = 0; fidx < files.size(); fidx++) {
|
||||||
f = &files[fidx];
|
f = &files[fidx];
|
||||||
tracks_selected_here = false;
|
tracks_selected_here = false;
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
tab_settings::tab_settings(wxWindow *parent):
|
tab_settings::tab_settings(wxWindow *parent):
|
||||||
wxPanel(parent, -1, wxDefaultPosition, wxSize(100, 400),
|
wxPanel(parent, -1, wxDefaultPosition, wxSize(100, 400),
|
||||||
wxTAB_TRAVERSAL) {
|
wxTAB_TRAVERSAL) {
|
||||||
new wxStaticBox(this, -1, wxS("mkvmrge executable"), wxPoint(10, 5),
|
new wxStaticBox(this, -1, wxS("mkvmerge executable"), wxPoint(10, 5),
|
||||||
wxSize(475, 50));
|
wxSize(475, 50));
|
||||||
tc_mkvmerge =
|
tc_mkvmerge =
|
||||||
new wxTextCtrl(this, ID_TC_MKVMERGE, wxS(""), wxPoint(15, 25),
|
new wxTextCtrl(this, ID_TC_MKVMERGE, wxS(""), wxPoint(15, 25),
|
||||||
@ -44,6 +44,23 @@ tab_settings::tab_settings(wxWindow *parent):
|
|||||||
new wxButton(this, ID_B_BROWSEMKVMERGE, wxS("Browse"), wxPoint(395, 25),
|
new wxButton(this, ID_B_BROWSEMKVMERGE, wxS("Browse"), wxPoint(395, 25),
|
||||||
wxDefaultSize, 0);
|
wxDefaultSize, 0);
|
||||||
|
|
||||||
|
new wxStaticBox(this, -1, wxS("Miscellaneous options"), wxPoint(10, 65),
|
||||||
|
wxSize(475, 50));
|
||||||
|
new wxStaticText(this, -1, wxS("Process priority:"), wxPoint(15, 85));
|
||||||
|
cob_priority =
|
||||||
|
new wxComboBox(this, ID_COB_PRIORITY, wxS(""), wxPoint(120, 85 + YOFF),
|
||||||
|
wxSize(90, -1), 0, NULL, wxCB_DROPDOWN | wxCB_READONLY);
|
||||||
|
cob_priority->SetToolTip(wxS("Sets the priority that mkvmerge will run "
|
||||||
|
"with."));
|
||||||
|
#if defined(SYS_WINDOWS)
|
||||||
|
cob_priority->Append(wxS("highest"));
|
||||||
|
cob_priority->Append(wxS("higher"));
|
||||||
|
#endif
|
||||||
|
cob_priority->Append(wxS("normal"));
|
||||||
|
cob_priority->Append(wxS("lower"));
|
||||||
|
cob_priority->Append(wxS("lowest"));
|
||||||
|
|
||||||
|
|
||||||
new wxStaticBox(this, -1, wxS("About"), wxPoint(10, 350),
|
new wxStaticBox(this, -1, wxS("About"), wxPoint(10, 350),
|
||||||
wxSize(475, 104));
|
wxSize(475, 104));
|
||||||
new wxStaticBitmap(this, -1, wxBitmap(matroskalogo_big_xpm),
|
new wxStaticBitmap(this, -1, wxBitmap(matroskalogo_big_xpm),
|
||||||
@ -61,6 +78,7 @@ tab_settings::tab_settings(wxWindow *parent):
|
|||||||
}
|
}
|
||||||
|
|
||||||
tab_settings::~tab_settings() {
|
tab_settings::~tab_settings() {
|
||||||
|
save_preferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -81,21 +99,39 @@ tab_settings::on_browse(wxCommandEvent &evt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
tab_settings::on_priority_selected(wxCommandEvent &evt) {
|
||||||
|
save_preferences();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tab_settings::load_preferences() {
|
tab_settings::load_preferences() {
|
||||||
wxConfig *cfg = (wxConfig *)wxConfigBase::Get();
|
wxConfig *cfg = (wxConfig *)wxConfigBase::Get();
|
||||||
|
wxString priority;
|
||||||
|
int i;
|
||||||
|
|
||||||
cfg->SetPath(wxS("/GUI"));
|
cfg->SetPath(wxS("/GUI"));
|
||||||
if (!cfg->Read(wxS("mkvmerge_executable"), &mkvmerge_path))
|
if (!cfg->Read(wxS("mkvmerge_executable"), &mkvmerge_path))
|
||||||
mkvmerge_path = wxS("mkvmerge");
|
mkvmerge_path = wxS("mkvmerge");
|
||||||
tc_mkvmerge->SetValue(mkvmerge_path);
|
tc_mkvmerge->SetValue(mkvmerge_path);
|
||||||
query_mkvmerge_capabilities();
|
query_mkvmerge_capabilities();
|
||||||
|
|
||||||
|
if (!cfg->Read(wxS("process_priority"), &priority))
|
||||||
|
priority = wxS("normal");
|
||||||
|
cob_priority->SetSelection(0);
|
||||||
|
for (i = 0; i < cob_priority->GetCount(); i++)
|
||||||
|
if (priority == cob_priority->GetString(i)) {
|
||||||
|
cob_priority->SetSelection(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tab_settings::save_preferences() {
|
tab_settings::save_preferences() {
|
||||||
wxConfig *cfg = (wxConfig *)wxConfigBase::Get();
|
wxConfig *cfg = (wxConfig *)wxConfigBase::Get();
|
||||||
cfg->Write(wxS("/GUI/mkvmerge_executable"), tc_mkvmerge->GetValue());
|
cfg->SetPath(wxS("/GUI"));
|
||||||
|
cfg->Write(wxS("mkvmerge_executable"), tc_mkvmerge->GetValue());
|
||||||
|
cfg->Write(wxS("process_priority"), cob_priority->GetValue());
|
||||||
cfg->Flush();
|
cfg->Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,4 +174,5 @@ tab_settings::query_mkvmerge_capabilities() {
|
|||||||
IMPLEMENT_CLASS(tab_settings, wxPanel);
|
IMPLEMENT_CLASS(tab_settings, wxPanel);
|
||||||
BEGIN_EVENT_TABLE(tab_settings, wxPanel)
|
BEGIN_EVENT_TABLE(tab_settings, wxPanel)
|
||||||
EVT_BUTTON(ID_B_BROWSEMKVMERGE, tab_settings::on_browse)
|
EVT_BUTTON(ID_B_BROWSEMKVMERGE, tab_settings::on_browse)
|
||||||
|
EVT_COMBOBOX(ID_COB_PRIORITY, tab_settings::on_priority_selected)
|
||||||
END_EVENT_TABLE();
|
END_EVENT_TABLE();
|
||||||
|
@ -24,19 +24,22 @@
|
|||||||
|
|
||||||
#define ID_TC_MKVMERGE 15000
|
#define ID_TC_MKVMERGE 15000
|
||||||
#define ID_B_BROWSEMKVMERGE 15001
|
#define ID_B_BROWSEMKVMERGE 15001
|
||||||
|
#define ID_COB_PRIORITY 15002
|
||||||
|
|
||||||
class tab_settings: public wxPanel {
|
class tab_settings: public wxPanel {
|
||||||
DECLARE_CLASS(tab_settings);
|
DECLARE_CLASS(tab_settings);
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
protected:
|
public:
|
||||||
wxTextCtrl *tc_mkvmerge;
|
wxTextCtrl *tc_mkvmerge;
|
||||||
wxCheckBox *cb_show_commandline;
|
wxCheckBox *cb_show_commandline;
|
||||||
|
wxComboBox *cob_priority;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
tab_settings(wxWindow *parent);
|
tab_settings(wxWindow *parent);
|
||||||
virtual ~tab_settings();
|
virtual ~tab_settings();
|
||||||
|
|
||||||
void on_browse(wxCommandEvent &evt);
|
void on_browse(wxCommandEvent &evt);
|
||||||
|
void on_priority_selected(wxCommandEvent &evt);
|
||||||
|
|
||||||
void load_preferences();
|
void load_preferences();
|
||||||
void save_preferences();
|
void save_preferences();
|
||||||
|
Loading…
Reference in New Issue
Block a user