mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 19:55:07 +02:00
Merge pull request #11976 from luiscuenca/fixLinuxAudioDLock
Fix getActiveDevice deadlocks on Linux
This commit is contained in:
commit
b1503f7c46
1 changed files with 8 additions and 7 deletions
|
@ -679,7 +679,9 @@ void OffscreenQmlSurface::create() {
|
|||
|
||||
// Setup the update of the QML media components with the current audio output device
|
||||
QObject::connect(&_audioOutputUpdateTimer, &QTimer::timeout, this, [this]() {
|
||||
new AudioHandler(sharedFromThis(), _currentAudioOutputDevice);
|
||||
if (_currentAudioOutputDevice.size() > 0) {
|
||||
new AudioHandler(sharedFromThis(), _currentAudioOutputDevice);
|
||||
}
|
||||
});
|
||||
int waitForAudioQmlMs = 200;
|
||||
_audioOutputUpdateTimer.setInterval(waitForAudioQmlMs);
|
||||
|
@ -695,6 +697,7 @@ void OffscreenQmlSurface::create() {
|
|||
}
|
||||
|
||||
void OffscreenQmlSurface::changeAudioOutputDevice(const QString& deviceName, bool isHtmlUpdate) {
|
||||
_currentAudioOutputDevice = deviceName;
|
||||
if (_rootItem != nullptr && !isHtmlUpdate) {
|
||||
QMetaObject::invokeMethod(this, "forceQmlAudioOutputDeviceUpdate", Qt::QueuedConnection);
|
||||
}
|
||||
|
@ -702,18 +705,16 @@ void OffscreenQmlSurface::changeAudioOutputDevice(const QString& deviceName, boo
|
|||
}
|
||||
|
||||
void OffscreenQmlSurface::forceHtmlAudioOutputDeviceUpdate() {
|
||||
auto audioIO = DependencyManager::get<AudioClient>();
|
||||
QString deviceName = audioIO->getActiveAudioDevice(QAudio::AudioOutput).deviceName();
|
||||
QMetaObject::invokeMethod(this, "changeAudioOutputDevice", Qt::QueuedConnection,
|
||||
Q_ARG(QString, deviceName), Q_ARG(bool, true));
|
||||
if (_currentAudioOutputDevice.size() > 0) {
|
||||
QMetaObject::invokeMethod(this, "changeAudioOutputDevice", Qt::QueuedConnection,
|
||||
Q_ARG(QString, _currentAudioOutputDevice), Q_ARG(bool, true));
|
||||
}
|
||||
}
|
||||
|
||||
void OffscreenQmlSurface::forceQmlAudioOutputDeviceUpdate() {
|
||||
if (QThread::currentThread() != qApp->thread()) {
|
||||
QMetaObject::invokeMethod(this, "forceQmlAudioOutputDeviceUpdate", Qt::QueuedConnection);
|
||||
} else {
|
||||
auto audioIO = DependencyManager::get<AudioClient>();
|
||||
_currentAudioOutputDevice = audioIO->getActiveAudioDevice(QAudio::AudioOutput).deviceName();
|
||||
if (_audioOutputUpdateTimer.isActive()) {
|
||||
_audioOutputUpdateTimer.stop();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue