mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 23:39:26 +02:00
Merge pull request #5074 from howard-stearns/restartable-non-local-sound
Fix AudioInjector::restart() for the non-local case.
This commit is contained in:
commit
c73ccba427
2 changed files with 13 additions and 2 deletions
|
@ -44,6 +44,8 @@ AudioInjector::AudioInjector(const QByteArray& audioData, const AudioInjectorOpt
|
||||||
|
|
||||||
void AudioInjector::setIsFinished(bool isFinished) {
|
void AudioInjector::setIsFinished(bool isFinished) {
|
||||||
_isFinished = isFinished;
|
_isFinished = isFinished;
|
||||||
|
// In all paths, regardless of isFinished argument. restart() passes false to prepare for new play, and injectToMixer() needs _shouldStop reset.
|
||||||
|
_shouldStop = false;
|
||||||
|
|
||||||
if (_isFinished) {
|
if (_isFinished) {
|
||||||
emit finished();
|
emit finished();
|
||||||
|
@ -55,7 +57,6 @@ void AudioInjector::setIsFinished(bool isFinished) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_isStarted = false;
|
_isStarted = false;
|
||||||
_shouldStop = false;
|
|
||||||
|
|
||||||
if (_shouldDeleteAfterFinish) {
|
if (_shouldDeleteAfterFinish) {
|
||||||
// we've been asked to delete after finishing, trigger a queued deleteLater here
|
// we've been asked to delete after finishing, trigger a queued deleteLater here
|
||||||
|
@ -67,6 +68,7 @@ void AudioInjector::setIsFinished(bool isFinished) {
|
||||||
|
|
||||||
void AudioInjector::injectAudio() {
|
void AudioInjector::injectAudio() {
|
||||||
if (!_isStarted) {
|
if (!_isStarted) {
|
||||||
|
_isStarted = true;
|
||||||
// check if we need to offset the sound by some number of seconds
|
// check if we need to offset the sound by some number of seconds
|
||||||
if (_options.secondOffset > 0.0f) {
|
if (_options.secondOffset > 0.0f) {
|
||||||
|
|
||||||
|
@ -91,7 +93,15 @@ void AudioInjector::injectAudio() {
|
||||||
|
|
||||||
void AudioInjector::restart() {
|
void AudioInjector::restart() {
|
||||||
qCDebug(audio) << "Restarting an AudioInjector by stopping and starting over.";
|
qCDebug(audio) << "Restarting an AudioInjector by stopping and starting over.";
|
||||||
stop();
|
connect(this, &AudioInjector::finished, this, &AudioInjector::restartPortionAfterFinished);
|
||||||
|
if (!_isStarted || _isFinished) {
|
||||||
|
emit finished();
|
||||||
|
} else {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void AudioInjector::restartPortionAfterFinished() {
|
||||||
|
disconnect(this, &AudioInjector::finished, this, &AudioInjector::restartPortionAfterFinished);
|
||||||
setIsFinished(false);
|
setIsFinished(false);
|
||||||
QMetaObject::invokeMethod(this, "injectAudio", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, "injectAudio", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ public slots:
|
||||||
void setCurrentSendPosition(int currentSendPosition) { _currentSendPosition = currentSendPosition; }
|
void setCurrentSendPosition(int currentSendPosition) { _currentSendPosition = currentSendPosition; }
|
||||||
float getLoudness() const { return _loudness; }
|
float getLoudness() const { return _loudness; }
|
||||||
bool isPlaying() const { return !_isFinished; }
|
bool isPlaying() const { return !_isFinished; }
|
||||||
|
void restartPortionAfterFinished();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished();
|
void finished();
|
||||||
|
|
Loading…
Reference in a new issue