mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 03:53:10 +02:00
Merge pull request #14073 from jherico/fix/18069_test
Working on Vive shutdown issues
This commit is contained in:
commit
19438d143e
6 changed files with 43 additions and 12 deletions
|
@ -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
|
// Make sure we don't time out during slow operations at startup
|
||||||
updateHeartbeat();
|
updateHeartbeat();
|
||||||
|
|
||||||
QTimer* settingsTimer = new QTimer();
|
QTimer* settingsTimer = new QTimer();
|
||||||
moveToNewNamedThread(settingsTimer, "Settings Thread", [this, settingsTimer]{
|
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
|
// Disconnect the signal from the save settings
|
||||||
QObject::disconnect(settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
|
QObject::disconnect(settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
|
||||||
// Stop the settings timer
|
// Stop the settings timer
|
||||||
|
|
|
@ -100,6 +100,13 @@ QList<QAudioDeviceInfo> getAvailableDevices(QAudio::Mode mode) {
|
||||||
|
|
||||||
// now called from a background thread, to keep blocking operations off the audio thread
|
// now called from a background thread, to keep blocking operations off the audio thread
|
||||||
void AudioClient::checkDevices() {
|
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 inputDevices = getAvailableDevices(QAudio::AudioInput);
|
||||||
auto outputDevices = getAvailableDevices(QAudio::AudioOutput);
|
auto outputDevices = getAvailableDevices(QAudio::AudioOutput);
|
||||||
|
|
||||||
|
@ -278,9 +285,6 @@ void AudioClient::customDeleter() {
|
||||||
_shouldRestartInputSetup = false;
|
_shouldRestartInputSetup = false;
|
||||||
#endif
|
#endif
|
||||||
stop();
|
stop();
|
||||||
_checkDevicesTimer->stop();
|
|
||||||
_checkPeakValuesTimer->stop();
|
|
||||||
|
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,12 +657,26 @@ void AudioClient::start() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioClient::stop() {
|
void AudioClient::stop() {
|
||||||
|
|
||||||
qCDebug(audioclient) << "AudioClient::stop(), requesting switchInputToAudioDevice() to shut down";
|
qCDebug(audioclient) << "AudioClient::stop(), requesting switchInputToAudioDevice() to shut down";
|
||||||
switchInputToAudioDevice(QAudioDeviceInfo(), true);
|
switchInputToAudioDevice(QAudioDeviceInfo(), true);
|
||||||
|
|
||||||
qCDebug(audioclient) << "AudioClient::stop(), requesting switchOutputToAudioDevice() to shut down";
|
qCDebug(audioclient) << "AudioClient::stop(), requesting switchOutputToAudioDevice() to shut down";
|
||||||
switchOutputToAudioDevice(QAudioDeviceInfo(), true);
|
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)
|
#if defined(Q_OS_ANDROID)
|
||||||
_checkInputTimer.stop();
|
_checkInputTimer.stop();
|
||||||
disconnect(&_checkInputTimer, &QTimer::timeout, 0, 0);
|
disconnect(&_checkInputTimer, &QTimer::timeout, 0, 0);
|
||||||
|
|
|
@ -447,7 +447,9 @@ private:
|
||||||
bool _shouldRestartInputSetup { true }; // Should we restart the input device because of an unintended stop?
|
bool _shouldRestartInputSetup { true }; // Should we restart the input device because of an unintended stop?
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Mutex _checkDevicesMutex;
|
||||||
QTimer* _checkDevicesTimer { nullptr };
|
QTimer* _checkDevicesTimer { nullptr };
|
||||||
|
Mutex _checkPeakValuesMutex;
|
||||||
QTimer* _checkPeakValuesTimer { nullptr };
|
QTimer* _checkPeakValuesTimer { nullptr };
|
||||||
|
|
||||||
bool _isRecording { false };
|
bool _isRecording { false };
|
||||||
|
|
|
@ -40,6 +40,12 @@ void release(IAudioClient* audioClient) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioClient::checkPeakValues() {
|
void AudioClient::checkPeakValues() {
|
||||||
|
// Guard against running during shutdown
|
||||||
|
Lock timerMutex(_checkPeakValuesMutex);
|
||||||
|
if (nullptr == _checkPeakValuesTimer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// prepare the windows environment
|
// prepare the windows environment
|
||||||
CoInitialize(NULL);
|
CoInitialize(NULL);
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,11 @@ void soundSharedPointerFromScriptValue(const QScriptValue& object, SharedSoundPo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundScriptingInterface::SoundScriptingInterface(SharedSoundPointer sound) : _sound(sound) {
|
SoundScriptingInterface::SoundScriptingInterface(const SharedSoundPointer& sound) : _sound(sound) {
|
||||||
QObject::connect(sound.data(), &Sound::ready, this, &SoundScriptingInterface::ready);
|
// 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) :
|
Sound::Sound(const QUrl& url, bool isStereo, bool isAmbisonic) :
|
||||||
|
|
|
@ -105,11 +105,11 @@ class SoundScriptingInterface : public QObject {
|
||||||
Q_PROPERTY(float duration READ getDuration)
|
Q_PROPERTY(float duration READ getDuration)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SoundScriptingInterface(SharedSoundPointer sound);
|
SoundScriptingInterface(const SharedSoundPointer& sound);
|
||||||
SharedSoundPointer getSound() { return _sound; }
|
const SharedSoundPointer& getSound() { return _sound; }
|
||||||
|
|
||||||
bool isReady() const { return _sound->isReady(); }
|
bool isReady() const { return _sound ? _sound->isReady() : false; }
|
||||||
float getDuration() { return _sound->getDuration(); }
|
float getDuration() { return _sound ? _sound->getDuration() : 0.0f; }
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Triggered when the sound has been downloaded and is ready to be played.
|
* Triggered when the sound has been downloaded and is ready to be played.
|
||||||
|
|
Loading…
Reference in a new issue