mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 15:43:50 +02:00
have QAudioOutput cleaned up with injector thread
This commit is contained in:
parent
0a6ffe3dbd
commit
47f86fac68
2 changed files with 7 additions and 18 deletions
|
@ -1378,10 +1378,14 @@ bool Audio::outputLocalInjector(bool isStereo, qreal volume, AudioInjector* inje
|
|||
localFormat, this);
|
||||
localOutput->setVolume(volume);
|
||||
|
||||
// add this to our list of local injected outputs, we will need to clean it up when the injector says it is done
|
||||
_injectedOutputInterfaces.insert(injector, localOutput);
|
||||
// move the localOutput to the same thread as the local injector buffer
|
||||
localOutput->moveToThread(injector->getLocalBuffer()->thread());
|
||||
|
||||
connect(injector, &AudioInjector::finished, this, &Audio::cleanupLocalOutputInterface);
|
||||
// have it be cleaned up when that thread is done
|
||||
connect(injector->thread(), &QThread::finished, localOutput, &QAudioOutput::stop);
|
||||
connect(injector->thread(), &QThread::finished, localOutput, &QAudioOutput::deleteLater);
|
||||
|
||||
qDebug() << "Starting QAudioOutput for local injector" << localOutput;
|
||||
|
||||
localOutput->start(injector->getLocalBuffer());
|
||||
return localOutput->state() == QAudio::ActiveState;
|
||||
|
@ -1390,16 +1394,6 @@ bool Audio::outputLocalInjector(bool isStereo, qreal volume, AudioInjector* inje
|
|||
return false;
|
||||
}
|
||||
|
||||
void Audio::cleanupLocalOutputInterface() {
|
||||
QAudioOutput* outputInterface = _injectedOutputInterfaces.value(sender());
|
||||
if (outputInterface) {
|
||||
qDebug() << "Stopping a QAudioOutput interface since injector" << sender() << "is finished";
|
||||
|
||||
outputInterface->stop();
|
||||
outputInterface->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void Audio::renderToolBox(int x, int y, bool boxed) {
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
|
|
@ -179,9 +179,6 @@ signals:
|
|||
void preProcessOriginalInboundAudio(unsigned int sampleTime, QByteArray& samples, const QAudioFormat& format);
|
||||
void processInboundAudio(unsigned int sampleTime, const QByteArray& samples, const QAudioFormat& format);
|
||||
void processLocalAudio(unsigned int sampleTime, const QByteArray& samples, const QAudioFormat& format);
|
||||
|
||||
private slots:
|
||||
void cleanupLocalOutputInterface();
|
||||
private:
|
||||
void outputFormatChanged();
|
||||
|
||||
|
@ -369,8 +366,6 @@ private:
|
|||
AudioOutputIODevice _audioOutputIODevice;
|
||||
|
||||
WeakRecorderPointer _recorder;
|
||||
|
||||
QHash<QObject*, QAudioOutput*> _injectedOutputInterfaces;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue