mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:25:52 +02:00
complete handling of local audio loopback
This commit is contained in:
parent
66949ee7a9
commit
bd8b71a02a
2 changed files with 18 additions and 8 deletions
|
@ -184,9 +184,9 @@ QAudioDeviceInfo getNamedAudioDeviceForMode(QAudio::Mode mode, const QString& de
|
||||||
QAudioDeviceInfo::defaultOutputDevice();
|
QAudioDeviceInfo::defaultOutputDevice();
|
||||||
#else
|
#else
|
||||||
foreach(QAudioDeviceInfo audioDevice, QAudioDeviceInfo::availableDevices(mode)) {
|
foreach(QAudioDeviceInfo audioDevice, QAudioDeviceInfo::availableDevices(mode)) {
|
||||||
qDebug() << audioDevice.deviceName() << " " << deviceName;
|
|
||||||
if (audioDevice.deviceName().trimmed() == deviceName.trimmed()) {
|
if (audioDevice.deviceName().trimmed() == deviceName.trimmed()) {
|
||||||
result = audioDevice;
|
result = audioDevice;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1332,9 +1332,21 @@ void Audio::startDrumSound(float volume, float frequency, float duration, float
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::handleAudioByteArray(const QByteArray& audioByteArray, const AudioInjectorOptions& injectorOptions) {
|
void Audio::handleAudioByteArray(const QByteArray& audioByteArray, const AudioInjectorOptions& injectorOptions) {
|
||||||
// TODO: either create a new audio device (up to the limit of the sound card or a hard limit)
|
if (audioByteArray.size() > 0) {
|
||||||
// or send to the mixer and use delayed loopback
|
QAudioFormat localFormat = _outputFormat;
|
||||||
|
|
||||||
|
if (!injectorOptions.isStereo()) {
|
||||||
|
localFormat.setChannelCount(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
QAudioOutput* localSoundOutput = new QAudioOutput(getNamedAudioDeviceForMode(QAudio::AudioOutput, _outputAudioDeviceName), localFormat, this);
|
||||||
|
|
||||||
|
QIODevice* localIODevice = localSoundOutput->start();
|
||||||
|
qDebug() << "Writing" << audioByteArray.size() << "to" << localIODevice;
|
||||||
|
localIODevice->write(audioByteArray);
|
||||||
|
} else {
|
||||||
|
qDebug() << "Audio::handleAudioByteArray called with an empty byte array. Sound is likely still downloading.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::renderToolBox(int x, int y, bool boxed) {
|
void Audio::renderToolBox(int x, int y, bool boxed) {
|
||||||
|
@ -1904,6 +1916,7 @@ bool Audio::switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceInfo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return supportedFormat;
|
return supportedFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1962,6 +1975,7 @@ bool Audio::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDeviceInfo)
|
||||||
supportedFormat = true;
|
supportedFormat = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return supportedFormat;
|
return supportedFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
#include "AudioInjector.h"
|
#include "AudioInjector.h"
|
||||||
#include "Sound.h"
|
#include "Sound.h"
|
||||||
|
|
||||||
class AbstractAudioInterface;
|
|
||||||
|
|
||||||
const AudioInjectorOptions DEFAULT_INJECTOR_OPTIONS;
|
const AudioInjectorOptions DEFAULT_INJECTOR_OPTIONS;
|
||||||
|
|
||||||
class AudioScriptingInterface : public QObject {
|
class AudioScriptingInterface : public QObject {
|
||||||
|
@ -46,7 +44,5 @@ private:
|
||||||
AudioScriptingInterface();
|
AudioScriptingInterface();
|
||||||
QList< QPointer<AudioInjector> > _activeInjectors;
|
QList< QPointer<AudioInjector> > _activeInjectors;
|
||||||
AbstractAudioInterface* _localLoopbackInterface;
|
AbstractAudioInterface* _localLoopbackInterface;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // hifi_AudioScriptingInterface_h
|
#endif // hifi_AudioScriptingInterface_h
|
||||||
|
|
Loading…
Reference in a new issue