mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-27 10:30:09 +02:00
wait on AudioInjectors when shutting down interface
This commit is contained in:
parent
f8874daab6
commit
663167d684
5 changed files with 23 additions and 8 deletions
|
@ -451,7 +451,7 @@ Application::~Application() {
|
||||||
_audio.thread()->wait();
|
_audio.thread()->wait();
|
||||||
|
|
||||||
// kill any audio injectors that are still around
|
// kill any audio injectors that are still around
|
||||||
|
AudioScriptingInterface::getInstance().stopAllInjectors();
|
||||||
|
|
||||||
_octreeProcessor.terminate();
|
_octreeProcessor.terminate();
|
||||||
_voxelHideShowThread.terminate();
|
_voxelHideShowThread.terminate();
|
||||||
|
|
|
@ -26,6 +26,7 @@ AudioInjector::AudioInjector(QObject* parent) :
|
||||||
_sound(NULL),
|
_sound(NULL),
|
||||||
_options(),
|
_options(),
|
||||||
_shouldStop(false),
|
_shouldStop(false),
|
||||||
|
_isFinished(false),
|
||||||
_currentSendPosition(0)
|
_currentSendPosition(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -34,6 +35,7 @@ AudioInjector::AudioInjector(Sound* sound, const AudioInjectorOptions& injectorO
|
||||||
_sound(sound),
|
_sound(sound),
|
||||||
_options(injectorOptions),
|
_options(injectorOptions),
|
||||||
_shouldStop(false),
|
_shouldStop(false),
|
||||||
|
_isFinished(false),
|
||||||
_currentSendPosition(0)
|
_currentSendPosition(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -161,5 +163,6 @@ void AudioInjector::injectAudio() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_isFinished = true;
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ public:
|
||||||
AudioInjector(QObject* parent);
|
AudioInjector(QObject* parent);
|
||||||
AudioInjector(Sound* sound, const AudioInjectorOptions& injectorOptions);
|
AudioInjector(Sound* sound, const AudioInjectorOptions& injectorOptions);
|
||||||
|
|
||||||
|
bool isFinished() const { return _isFinished; }
|
||||||
int getCurrentSendPosition() const { return _currentSendPosition; }
|
int getCurrentSendPosition() const { return _currentSendPosition; }
|
||||||
public slots:
|
public slots:
|
||||||
void injectAudio();
|
void injectAudio();
|
||||||
|
@ -39,6 +40,7 @@ private:
|
||||||
Sound* _sound;
|
Sound* _sound;
|
||||||
AudioInjectorOptions _options;
|
AudioInjectorOptions _options;
|
||||||
bool _shouldStop;
|
bool _shouldStop;
|
||||||
|
bool _isFinished;
|
||||||
int _currentSendPosition;
|
int _currentSendPosition;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,18 @@ AudioScriptingInterface& AudioScriptingInterface::getInstance() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioScriptingInterface::stopAllInjectors() {
|
void AudioScriptingInterface::stopAllInjectors() {
|
||||||
|
QList<QPointer<AudioInjector> >::iterator injector = _activeInjectors.begin();
|
||||||
|
while (injector != _activeInjectors.end()) {
|
||||||
|
if (!injector->isNull()) {
|
||||||
|
injector->data()->stop();
|
||||||
|
|
||||||
|
while (injector->data() && !injector->data()->isFinished()) {
|
||||||
|
// wait for this injector to go down
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
injector = _activeInjectors.erase(injector);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioInjector* AudioScriptingInterface::playSound(Sound* sound, const AudioInjectorOptions* injectorOptions) {
|
AudioInjector* AudioScriptingInterface::playSound(Sound* sound, const AudioInjectorOptions* injectorOptions) {
|
||||||
|
@ -42,7 +53,7 @@ AudioInjector* AudioScriptingInterface::playSound(Sound* sound, const AudioInjec
|
||||||
|
|
||||||
injectorThread->start();
|
injectorThread->start();
|
||||||
|
|
||||||
_activeInjectors.insert(injector);
|
_activeInjectors.append(QPointer<AudioInjector>(injector));
|
||||||
|
|
||||||
return injector;
|
return injector;
|
||||||
}
|
}
|
||||||
|
@ -58,8 +69,5 @@ bool AudioScriptingInterface::isInjectorPlaying(AudioInjector* injector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioScriptingInterface::injectorStopped() {
|
void AudioScriptingInterface::injectorStopped() {
|
||||||
qDebug() << "Removing" << sender() << "from active injectors";
|
_activeInjectors.removeAll(QPointer<AudioInjector>(reinterpret_cast<AudioInjector*>(sender())));
|
||||||
qDebug() << _activeInjectors.size();
|
|
||||||
_activeInjectors.remove(static_cast<AudioInjector*>(sender()));
|
|
||||||
qDebug() << _activeInjectors.size();
|
|
||||||
}
|
}
|
|
@ -12,6 +12,8 @@
|
||||||
#ifndef hifi_AudioScriptingInterface_h
|
#ifndef hifi_AudioScriptingInterface_h
|
||||||
#define hifi_AudioScriptingInterface_h
|
#define hifi_AudioScriptingInterface_h
|
||||||
|
|
||||||
|
#include <qpointer.h>
|
||||||
|
|
||||||
#include "AudioInjector.h"
|
#include "AudioInjector.h"
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
|
|
||||||
|
@ -32,7 +34,7 @@ public slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AudioScriptingInterface() {};
|
AudioScriptingInterface() {};
|
||||||
QSet<AudioInjector*> _activeInjectors;
|
QList< QPointer<AudioInjector> > _activeInjectors;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // hifi_AudioScriptingInterface_h
|
#endif // hifi_AudioScriptingInterface_h
|
||||||
|
|
Loading…
Reference in a new issue