cleanup Audio bg threads in cleanupBeforeQuit

This commit is contained in:
Zach Pomerantz 2017-04-24 18:21:27 -04:00
parent cd2665fc55
commit 4a26785eda
3 changed files with 18 additions and 7 deletions
interface/src
libraries/audio-client/src

View file

@ -1785,7 +1785,8 @@ void Application::cleanupBeforeQuit() {
// FIXME: something else is holding a reference to AudioClient,
// so it must be explicitly synchronously stopped here
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "stop", Qt::BlockingQueuedConnection);
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
"cleanupBeforeQuit", Qt::BlockingQueuedConnection);
// destroy Audio so it and its threads have a chance to go down safely
// this must happen after QML, as there are unexplained audio crashes originating in qtwebengine

View file

@ -254,15 +254,24 @@ AudioClient::~AudioClient() {
}
void AudioClient::customDeleter() {
stop(); // synchronously
deleteLater();
}
static_cast<BackgroundThread*>(_checkDevicesThread)->join();
delete _checkDevicesThread;
void AudioClient::cleanupBeforeQuit() {
// FIXME: this should be put in customDeleter, but there is still a reference to this when it is called,
// so this must be explicitly, synchronously stopped
static_cast<BackgroundThread*>(_localInjectorsThread)->join();
delete _localInjectorsThread;
stop();
deleteLater(); // asynchronously
if (_checkDevicesThread) {
static_cast<BackgroundThread*>(_checkDevicesThread)->join();
delete _checkDevicesThread;
}
if (_localInjectorsThread) {
static_cast<BackgroundThread*>(_localInjectorsThread)->join();
delete _localInjectorsThread;
}
}
void AudioClient::handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec) {

View file

@ -158,6 +158,7 @@ public:
public slots:
void start();
void stop();
void cleanupBeforeQuit();
void handleAudioEnvironmentDataPacket(QSharedPointer<ReceivedMessage> message);
void handleAudioDataPacket(QSharedPointer<ReceivedMessage> message);