mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 10:37:35 +02:00
Merge pull request #5135 from howard-stearns/not-clipped-local-sounds
Don't clip local audio sounds
This commit is contained in:
commit
196a1546ab
5 changed files with 16 additions and 12 deletions
|
@ -1011,7 +1011,10 @@ bool AudioClient::outputLocalInjector(bool isStereo, AudioInjector* injector) {
|
||||||
localOutput->moveToThread(injector->getLocalBuffer()->thread());
|
localOutput->moveToThread(injector->getLocalBuffer()->thread());
|
||||||
|
|
||||||
// have it be stopped when that local buffer is about to close
|
// have it be stopped when that local buffer is about to close
|
||||||
connect(injector->getLocalBuffer(), &AudioInjectorLocalBuffer::bufferEmpty, localOutput, &QAudioOutput::stop);
|
connect(localOutput, &QAudioOutput::stateChanged, this, &AudioClient::audioStateChanged);
|
||||||
|
connect(this, &AudioClient::audioFinished, localOutput, &QAudioOutput::stop);
|
||||||
|
connect(this, &AudioClient::audioFinished, injector, &AudioInjector::stop);
|
||||||
|
|
||||||
connect(injector->getLocalBuffer(), &QIODevice::aboutToClose, localOutput, &QAudioOutput::stop);
|
connect(injector->getLocalBuffer(), &QIODevice::aboutToClose, localOutput, &QAudioOutput::stop);
|
||||||
|
|
||||||
qCDebug(audioclient) << "Starting QAudioOutput for local injector" << localOutput;
|
qCDebug(audioclient) << "Starting QAudioOutput for local injector" << localOutput;
|
||||||
|
@ -1329,3 +1332,9 @@ void AudioClient::saveSettings() {
|
||||||
windowSecondsForDesiredReduction.set(_receivedAudioStream.getWindowSecondsForDesiredReduction());
|
windowSecondsForDesiredReduction.set(_receivedAudioStream.getWindowSecondsForDesiredReduction());
|
||||||
repetitionWithFade.set(_receivedAudioStream.getRepetitionWithFade());
|
repetitionWithFade.set(_receivedAudioStream.getRepetitionWithFade());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioClient::audioStateChanged(QAudio::State state) {
|
||||||
|
if (state == QAudio::IdleState) {
|
||||||
|
emit audioFinished();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -188,6 +188,8 @@ signals:
|
||||||
void receivedFirstPacket();
|
void receivedFirstPacket();
|
||||||
void disconnected();
|
void disconnected();
|
||||||
|
|
||||||
|
void audioFinished();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AudioClient();
|
AudioClient();
|
||||||
~AudioClient();
|
~AudioClient();
|
||||||
|
@ -196,6 +198,9 @@ protected:
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void audioStateChanged(QAudio::State state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void outputFormatChanged();
|
void outputFormatChanged();
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,6 @@ void AudioInjector::setIsFinished(bool isFinished) {
|
||||||
|
|
||||||
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
|
||||||
qCDebug(audio) << "AudioInjector triggering delete from setIsFinished";
|
|
||||||
QMetaObject::invokeMethod(this, "deleteLater", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, "deleteLater", Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,9 +121,6 @@ void AudioInjector::injectLocally() {
|
||||||
|
|
||||||
success = _localAudioInterface->outputLocalInjector(_options.stereo, this);
|
success = _localAudioInterface->outputLocalInjector(_options.stereo, this);
|
||||||
|
|
||||||
// if we're not looping and the buffer tells us it is empty then emit finished
|
|
||||||
connect(_localBuffer, &AudioInjectorLocalBuffer::bufferEmpty, this, &AudioInjector::stop);
|
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
qCDebug(audio) << "AudioInjector::injectLocally could not output locally via _localAudioInterface";
|
qCDebug(audio) << "AudioInjector::injectLocally could not output locally via _localAudioInterface";
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,10 +69,7 @@ qint64 AudioInjectorLocalBuffer::readData(char* data, qint64 maxSize) {
|
||||||
_currentOffset += bytesRead;
|
_currentOffset += bytesRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_shouldLoop && bytesRead == bytesToEnd) {
|
if (_shouldLoop && _currentOffset == _rawAudioArray.size()) {
|
||||||
// we hit the end of the buffer, emit a signal
|
|
||||||
emit bufferEmpty();
|
|
||||||
} else if (_shouldLoop && _currentOffset == _rawAudioArray.size()) {
|
|
||||||
_currentOffset = 0;
|
_currentOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,6 @@ public:
|
||||||
void setCurrentOffset(int currentOffset) { _currentOffset = currentOffset; }
|
void setCurrentOffset(int currentOffset) { _currentOffset = currentOffset; }
|
||||||
void setVolume(float volume) { _volume = glm::clamp(volume, 0.0f, 1.0f); }
|
void setVolume(float volume) { _volume = glm::clamp(volume, 0.0f, 1.0f); }
|
||||||
|
|
||||||
signals:
|
|
||||||
void bufferEmpty();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qint64 recursiveReadFromFront(char* data, qint64 maxSize);
|
qint64 recursiveReadFromFront(char* data, qint64 maxSize);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue