Merge pull request #14073 from jherico/fix/18069_test

Working on Vive shutdown issues
This commit is contained in:
John Conklin II 2018-09-25 15:41:32 -07:00 committed by GitHub
commit 19438d143e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 12 deletions

View file

@ -1759,10 +1759,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
// Make sure we don't time out during slow operations at startup
updateHeartbeat();
QTimer* settingsTimer = new QTimer();
moveToNewNamedThread(settingsTimer, "Settings Thread", [this, settingsTimer]{
connect(qApp, &Application::beforeAboutToQuit, [this, settingsTimer]{
// This needs to run on the settings thread, so we need to pass the `settingsTimer` as the
// receiver object, otherwise it will run on the application thread and trigger a warning
// about trying to kill the timer on the main thread.
connect(qApp, &Application::beforeAboutToQuit, settingsTimer, [this, settingsTimer]{
// Disconnect the signal from the save settings
QObject::disconnect(settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
// Stop the settings timer

View file

@ -100,6 +100,13 @@ QList<QAudioDeviceInfo> getAvailableDevices(QAudio::Mode mode) {
// now called from a background thread, to keep blocking operations off the audio thread
void AudioClient::checkDevices() {
// Make sure we're not shutting down
Lock timerMutex(_checkDevicesMutex);
// If we HAVE shut down after we were queued, but prior to execution, early exit
if (nullptr == _checkDevicesTimer) {
return;
}
auto inputDevices = getAvailableDevices(QAudio::AudioInput);
auto outputDevices = getAvailableDevices(QAudio::AudioOutput);
@ -278,9 +285,6 @@ void AudioClient::customDeleter() {
_shouldRestartInputSetup = false;
#endif
stop();
_checkDevicesTimer->stop();
_checkPeakValuesTimer->stop();
deleteLater();
}
@ -653,12 +657,26 @@ void AudioClient::start() {
}
void AudioClient::stop() {
qCDebug(audioclient) << "AudioClient::stop(), requesting switchInputToAudioDevice() to shut down";
switchInputToAudioDevice(QAudioDeviceInfo(), true);
qCDebug(audioclient) << "AudioClient::stop(), requesting switchOutputToAudioDevice() to shut down";
switchOutputToAudioDevice(QAudioDeviceInfo(), true);
// Stop triggering the checks
QObject::disconnect(_checkPeakValuesTimer, &QTimer::timeout, nullptr, nullptr);
QObject::disconnect(_checkDevicesTimer, &QTimer::timeout, nullptr, nullptr);
// Destruction of the pointers will occur when the parent object (this) is destroyed)
{
Lock lock(_checkDevicesMutex);
_checkDevicesTimer = nullptr;
}
{
Lock lock(_checkPeakValuesMutex);
_checkPeakValuesTimer = nullptr;
}
#if defined(Q_OS_ANDROID)
_checkInputTimer.stop();
disconnect(&_checkInputTimer, &QTimer::timeout, 0, 0);

View file

@ -447,7 +447,9 @@ private:
bool _shouldRestartInputSetup { true }; // Should we restart the input device because of an unintended stop?
#endif
Mutex _checkDevicesMutex;
QTimer* _checkDevicesTimer { nullptr };
Mutex _checkPeakValuesMutex;
QTimer* _checkPeakValuesTimer { nullptr };
bool _isRecording { false };

View file

@ -40,6 +40,12 @@ void release(IAudioClient* audioClient) {
}
void AudioClient::checkPeakValues() {
// Guard against running during shutdown
Lock timerMutex(_checkPeakValuesMutex);
if (nullptr == _checkPeakValuesTimer) {
return;
}
// prepare the windows environment
CoInitialize(NULL);

View file

@ -43,8 +43,11 @@ void soundSharedPointerFromScriptValue(const QScriptValue& object, SharedSoundPo
}
}
SoundScriptingInterface::SoundScriptingInterface(SharedSoundPointer sound) : _sound(sound) {
QObject::connect(sound.data(), &Sound::ready, this, &SoundScriptingInterface::ready);
SoundScriptingInterface::SoundScriptingInterface(const SharedSoundPointer& sound) : _sound(sound) {
// During shutdown we can sometimes get an empty sound pointer back
if (_sound) {
QObject::connect(_sound.data(), &Sound::ready, this, &SoundScriptingInterface::ready);
}
}
Sound::Sound(const QUrl& url, bool isStereo, bool isAmbisonic) :

View file

@ -105,11 +105,11 @@ class SoundScriptingInterface : public QObject {
Q_PROPERTY(float duration READ getDuration)
public:
SoundScriptingInterface(SharedSoundPointer sound);
SharedSoundPointer getSound() { return _sound; }
SoundScriptingInterface(const SharedSoundPointer& sound);
const SharedSoundPointer& getSound() { return _sound; }
bool isReady() const { return _sound->isReady(); }
float getDuration() { return _sound->getDuration(); }
bool isReady() const { return _sound ? _sound->isReady() : false; }
float getDuration() { return _sound ? _sound->getDuration() : 0.0f; }
/**jsdoc
* Triggered when the sound has been downloaded and is ready to be played.