mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 03:40:20 +02:00
Merge pull request #14247 from sethalves/dont-let-checkdevices-swap-pool
don't let checkDevices swamp thread pool
This commit is contained in:
commit
77988e400e
1 changed files with 11 additions and 4 deletions
|
@ -247,10 +247,17 @@ AudioClient::AudioClient() :
|
||||||
|
|
||||||
// start a thread to detect any device changes
|
// start a thread to detect any device changes
|
||||||
_checkDevicesTimer = new QTimer(this);
|
_checkDevicesTimer = new QTimer(this);
|
||||||
connect(_checkDevicesTimer, &QTimer::timeout, this, [this] {
|
|
||||||
QtConcurrent::run(QThreadPool::globalInstance(), [this] { checkDevices(); });
|
|
||||||
});
|
|
||||||
const unsigned long DEVICE_CHECK_INTERVAL_MSECS = 2 * 1000;
|
const unsigned long DEVICE_CHECK_INTERVAL_MSECS = 2 * 1000;
|
||||||
|
connect(_checkDevicesTimer, &QTimer::timeout, this, [=] {
|
||||||
|
QtConcurrent::run(QThreadPool::globalInstance(), [=] {
|
||||||
|
checkDevices();
|
||||||
|
// On some systems (Ubuntu) checking all the audio devices can take more than 2 seconds. To
|
||||||
|
// avoid consuming all of the thread pool, don't start the check interval until the previous
|
||||||
|
// check has completed.
|
||||||
|
QMetaObject::invokeMethod(_checkDevicesTimer, "start", Q_ARG(int, DEVICE_CHECK_INTERVAL_MSECS));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
_checkDevicesTimer->setSingleShot(true);
|
||||||
_checkDevicesTimer->start(DEVICE_CHECK_INTERVAL_MSECS);
|
_checkDevicesTimer->start(DEVICE_CHECK_INTERVAL_MSECS);
|
||||||
|
|
||||||
// start a thread to detect peak value changes
|
// start a thread to detect peak value changes
|
||||||
|
|
Loading…
Reference in a new issue