mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
fix audio injector cleanup for local only injectors
This commit is contained in:
parent
7f79f0946d
commit
9aa950e657
2 changed files with 15 additions and 17 deletions
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue