From 5dd5447095e05ea222fb3a2279e3f3ac50d74b75 Mon Sep 17 00:00:00 2001 From: amerhifi Date: Thu, 24 Oct 2019 15:03:55 -0700 Subject: [PATCH] moved call to hmd device name prior to locking device mutex --- libraries/audio-client/src/AudioClient.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libraries/audio-client/src/AudioClient.cpp b/libraries/audio-client/src/AudioClient.cpp index 995fe20886..18e8d11fc9 100644 --- a/libraries/audio-client/src/AudioClient.cpp +++ b/libraries/audio-client/src/AudioClient.cpp @@ -83,7 +83,6 @@ Mutex _recordMutex; HifiAudioDeviceInfo defaultAudioDeviceForMode(QAudio::Mode mode); - static QString getHmdAudioDeviceName(QAudio::Mode mode) { foreach(DisplayPluginPointer displayPlugin, PluginManager::getInstance()->getAllDisplayPlugins()) { if (displayPlugin && displayPlugin->isHmd()) { @@ -100,6 +99,10 @@ static QString getHmdAudioDeviceName(QAudio::Mode mode) { // thread-safe QList getAvailableDevices(QAudio::Mode mode) { + //get hmd device name prior to locking device mutex. in case of shutdown, this thread will be locked and audio client + //cannot properly shut down. + QString hmdDeviceName = getHmdAudioDeviceName(mode); + // NOTE: availableDevices() clobbers the Qt internal device list Lock lock(_deviceMutex); auto devices = QAudioDeviceInfo::availableDevices(mode); @@ -110,8 +113,7 @@ QList getAvailableDevices(QAudio::Mode mode) { } newDevices.push_front(defaultAudioDeviceForMode(mode)); - - QString hmdDeviceName = getHmdAudioDeviceName(mode); + if (!hmdDeviceName.isNull() && !hmdDeviceName.isEmpty()) { HifiAudioDeviceInfo hmdDevice; foreach(auto device, newDevices) { @@ -803,6 +805,7 @@ void AudioClient::stop() { // Destruction of the pointers will occur when the parent object (this) is destroyed) { Lock lock(_checkDevicesMutex); + _checkDevicesTimer->stop(); _checkDevicesTimer = nullptr; } {