mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 20:34:07 +02:00
add option to restart a local audio injector
This commit is contained in:
parent
e3c4ead323
commit
449719bc7c
3 changed files with 19 additions and 2 deletions
|
@ -980,6 +980,9 @@ bool AudioClient::outputLocalInjector(bool isStereo, qreal volume, AudioInjector
|
|||
// move the localOutput to the same thread as the local injector buffer
|
||||
localOutput->moveToThread(injector->getLocalBuffer()->thread());
|
||||
|
||||
// have it be cleaned up when that injector is done
|
||||
connect(injector, &AudioInjector::finished, localOutput, &QAudioOutput::stop);
|
||||
|
||||
qDebug() << "Starting QAudioOutput for local injector" << localOutput;
|
||||
|
||||
localOutput->start(injector->getLocalBuffer());
|
||||
|
|
|
@ -60,16 +60,19 @@ void AudioInjector::setIsFinished(bool isFinished) {
|
|||
|
||||
if (_localBuffer) {
|
||||
_localBuffer->stop();
|
||||
_localBuffer->deleteLater();
|
||||
_localBuffer = NULL;
|
||||
}
|
||||
|
||||
// cleanup the audio data so we aren't holding that memory unecessarily
|
||||
_audioData.resize(0);
|
||||
_isStarted = false;
|
||||
_shouldStop = false;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioInjector::injectAudio() {
|
||||
|
||||
if (!_isStarted) {
|
||||
|
||||
// check if we need to offset the sound by some number of seconds
|
||||
if (_options.secondOffset > 0.0f) {
|
||||
|
||||
|
@ -78,6 +81,8 @@ void AudioInjector::injectAudio() {
|
|||
byteOffset *= sizeof(int16_t);
|
||||
|
||||
_currentSendPosition = byteOffset;
|
||||
} else {
|
||||
_currentSendPosition = 0;
|
||||
}
|
||||
|
||||
if (_options.localOnly) {
|
||||
|
@ -90,6 +95,11 @@ void AudioInjector::injectAudio() {
|
|||
}
|
||||
}
|
||||
|
||||
void AudioInjector::restart() {
|
||||
stop();
|
||||
QMetaObject::invokeMethod(this, "injectAudio", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void AudioInjector::injectLocally() {
|
||||
bool success = false;
|
||||
if (_localAudioInterface) {
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
|
||||
class AbstractAudioInterface;
|
||||
|
||||
// In order to make scripting cleaner for the AudioInjector, the script now holds on to the AudioInjector object
|
||||
// until it dies.
|
||||
|
||||
class AudioInjector : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool isPlaying READ isPlaying)
|
||||
|
@ -44,6 +47,7 @@ public:
|
|||
void setLocalAudioInterface(AbstractAudioInterface* localAudioInterface) { _localAudioInterface = localAudioInterface; }
|
||||
public slots:
|
||||
void injectAudio();
|
||||
void restart();
|
||||
void stop();
|
||||
void setOptions(AudioInjectorOptions& options) { _options = options; }
|
||||
void setCurrentSendPosition(int currentSendPosition) { _currentSendPosition = currentSendPosition; }
|
||||
|
|
Loading…
Reference in a new issue