fix audio injector cleanup for local only injectors

This commit is contained in:
Stephen Birarda 2014-11-11 17:34:03 -08:00
parent 7f79f0946d
commit 9aa950e657
2 changed files with 15 additions and 17 deletions

View file

@ -132,7 +132,7 @@ function playRandomMusak() {
chosenSound = Math.random < 0.5 ? latinSound : elevatorSound;
} else if (latinSound.downloaded) {
chosenSound = latinSound;
} else if (elevator.downloaded) {
} else if (elevatorSound.downloaded) {
chosenSound = elevatorSound;
}
@ -148,15 +148,11 @@ function cleanupLobby() {
Overlays.deleteOverlay(orbShell);
Overlays.deleteOverlay(reticle);
if (currentDrone) {
currentDrone.stop();
currentDrone = null;
}
Audio.stopInjector(currentDrone);
currentDrone = null;
if (currentMusak) {
currentMusak.stop();
currentMusak = null;
}
Audio.stopInjector(currentMusak);
currentMusak = null;
panelWall = false;
orbShell = false;

View file

@ -75,26 +75,25 @@ void AudioInjector::injectAudio() {
}
void AudioInjector::injectLocally() {
bool success = false;
if (_localAudioInterface) {
const QByteArray& soundByteArray = _sound->getByteArray();
if (soundByteArray.size() > 0) {
bool successfulOutput = false;
_localBuffer = new AudioInjectorLocalBuffer(_sound->getByteArray(), this);
_localBuffer->open(QIODevice::ReadOnly);
_localBuffer->setShouldLoop(_options.loop);
QMetaObject::invokeMethod(_localAudioInterface, "outputLocalInjector",
Qt::BlockingQueuedConnection,
Q_RETURN_ARG(bool, successfulOutput),
Q_RETURN_ARG(bool, success),
Q_ARG(bool, _options.stereo),
Q_ARG(qreal, _options.volume),
Q_ARG(AudioInjector*, this));
if (!successfulOutput) {
if (!success) {
qDebug() << "AudioInjector::injectLocally could not output locally via _localAudioInterface";
}
} else {
@ -104,6 +103,12 @@ void AudioInjector::injectLocally() {
} else {
qDebug() << "AudioInjector::injectLocally cannot inject locally with no local audio interface present.";
}
if (!success) {
// we never started so we are finished, call our stop method
stop();
}
}
const uchar MAX_INJECTOR_VOLUME = 0xFF;
@ -235,11 +240,8 @@ void AudioInjector::injectToMixer() {
void AudioInjector::stop() {
_shouldStop = true;
if (_localBuffer) {
if (_options.localOnly) {
// we're only a local injector, so we can say we are finished right away too
_localBuffer->stop();
_isFinished = true;
emit finished();
}