diff --git a/src/core/tagreaderclient.cpp b/src/core/tagreaderclient.cpp index 96434be52..853c2733e 100644 --- a/src/core/tagreaderclient.cpp +++ b/src/core/tagreaderclient.cpp @@ -18,6 +18,7 @@ along with Clementine. If not, see . */ +#include "player.h" #include "tagreaderclient.h" #include @@ -34,8 +35,14 @@ TagReaderClient::TagReaderClient(QObject* parent) : QObject(parent), worker_pool_(new WorkerPool(this)) { sInstance = this; + QSettings s; + s.beginGroup(Player::kSettingsGroup); + + int max_workers = QThread::idealThreadCount(); + int num_workers = s.value("max_numprocs_tagclients", max_workers).toInt(); + worker_pool_->SetExecutableName(kWorkerExecutableName); - worker_pool_->SetWorkerCount(QThread::idealThreadCount()); + worker_pool_->SetWorkerCount(num_workers); connect(worker_pool_, SIGNAL(WorkerFailedToStart()), SLOT(WorkerFailedToStart())); } diff --git a/src/ui/behavioursettingspage.cpp b/src/ui/behavioursettingspage.cpp index 62287b69d..b32816891 100644 --- a/src/ui/behavioursettingspage.cpp +++ b/src/ui/behavioursettingspage.cpp @@ -40,6 +40,15 @@ BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog* dialog) connect(ui_->b_show_tray_icon_, SIGNAL(toggled(bool)), SLOT(ShowTrayIconToggled(bool))); + connect(ui_->max_numprocs_tagclients, SIGNAL(valueChanged(int)), + SLOT(MaxNumProcsTagClientsChanged(int))); + ui_->max_numprocs_tagclients_value_label->setMinimumWidth( + QFontMetrics(ui_->max_numprocs_tagclients_value_label->font()) + .width("WWW")); + + // Limit max tag clients to number of CPU cores. + ui_->max_numprocs_tagclients->setMaximum(QThread::idealThreadCount()); + ui_->doubleclick_addmode->setItemData(0, MainWindow::AddBehaviour_Append); ui_->doubleclick_addmode->setItemData(1, MainWindow::AddBehaviour_Load); ui_->doubleclick_addmode->setItemData(2, MainWindow::AddBehaviour_OpenInNew); @@ -171,6 +180,12 @@ void BehaviourSettingsPage::Load() { .toInt())); ui_->seek_step_sec->setValue(s.value("seek_step_sec", 10).toInt()); + int max_numprocs_tagclients = + s.value("max_numprocs_tagclients", QThread::idealThreadCount()).toInt(); + ui_->max_numprocs_tagclients->setValue(max_numprocs_tagclients); + ui_->max_numprocs_tagclients_value_label->setText( + QString::number(max_numprocs_tagclients)); + if (s.value("play_count_short_duration", false).toBool()) { ui_->b_play_count_short_duration->setChecked(true); ui_->b_play_count_normal_duration->setChecked(false); @@ -283,6 +298,7 @@ void BehaviourSettingsPage::Save() { ui_->stop_play_if_fail_->isChecked()); s.setValue("menu_previousmode", menu_previousmode); s.setValue("seek_step_sec", ui_->seek_step_sec->value()); + s.setValue("max_numprocs_tagclients", ui_->max_numprocs_tagclients->value()); if (ui_->b_play_count_short_duration->isChecked()) { s.setValue("play_count_short_duration", true); @@ -321,3 +337,7 @@ void BehaviourSettingsPage::ShowTrayIconToggled(bool on) { ui_->b_keep_running_->setChecked(on); ui_->b_scroll_tray_icon_->setEnabled(on); } + +void BehaviourSettingsPage::MaxNumProcsTagClientsChanged(int value) { + ui_->max_numprocs_tagclients_value_label->setText(QString::number(value)); +} diff --git a/src/ui/behavioursettingspage.h b/src/ui/behavioursettingspage.h index 9f73c0f77..36be11880 100644 --- a/src/ui/behavioursettingspage.h +++ b/src/ui/behavioursettingspage.h @@ -36,6 +36,7 @@ class BehaviourSettingsPage : public SettingsPage { private slots: void ShowTrayIconToggled(bool on); + void MaxNumProcsTagClientsChanged(int value); private: Ui_BehaviourSettingsPage* ui_; diff --git a/src/ui/behavioursettingspage.ui b/src/ui/behavioursettingspage.ui index 2005d707c..88567d8dd 100644 --- a/src/ui/behavioursettingspage.ui +++ b/src/ui/behavioursettingspage.ui @@ -339,6 +339,48 @@ + + + + Maximum number of child processes for tag handling (requires restart) + + + + + + Number of processes: + + + + + + + + + + + + + + 1 + + + 32 + + + 4 + + + Qt::Horizontal + + + 1 + + + + + +