mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
Formatting fixes.
This commit is contained in:
parent
a9097658ad
commit
c18d0ccf8f
2 changed files with 91 additions and 91 deletions
|
@ -298,95 +298,6 @@ QVector<QString> Audio::getDeviceNames(QAudio::Mode mode) {
|
|||
return deviceNames;
|
||||
}
|
||||
|
||||
bool Audio::switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceInfo) {
|
||||
bool supportedFormat = false;
|
||||
|
||||
// cleanup any previously initialized device
|
||||
if (_audioInput) {
|
||||
_audioInput->stop();
|
||||
disconnect(_inputDevice, 0, 0, 0);
|
||||
_inputDevice = NULL;
|
||||
|
||||
delete _audioInput;
|
||||
_audioInput = NULL;
|
||||
_numInputCallbackBytes = 0;
|
||||
|
||||
_inputAudioDeviceName = "";
|
||||
}
|
||||
|
||||
if (!inputDeviceInfo.isNull()) {
|
||||
qDebug() << "The audio input device " << inputDeviceInfo.deviceName() << "is available.";
|
||||
_inputAudioDeviceName = inputDeviceInfo.deviceName().trimmed();
|
||||
|
||||
if (adjustedFormatForAudioDevice(inputDeviceInfo, _desiredInputFormat, _inputFormat)) {
|
||||
qDebug() << "The format to be used for audio input is" << _inputFormat;
|
||||
|
||||
_audioInput = new QAudioInput(inputDeviceInfo, _inputFormat, this);
|
||||
_numInputCallbackBytes = NETWORK_BUFFER_LENGTH_BYTES_PER_CHANNEL * _inputFormat.channelCount()
|
||||
* (_inputFormat.sampleRate() / SAMPLE_RATE)
|
||||
/ CALLBACK_ACCELERATOR_RATIO;
|
||||
_audioInput->setBufferSize(_numInputCallbackBytes);
|
||||
|
||||
// how do we want to handle input working, but output not working?
|
||||
_inputRingBuffer.resizeForFrameSize(_numInputCallbackBytes * CALLBACK_ACCELERATOR_RATIO / sizeof(int16_t));
|
||||
_inputDevice = _audioInput->start();
|
||||
connect(_inputDevice, SIGNAL(readyRead()), this, SLOT(handleAudioInput()));
|
||||
|
||||
supportedFormat = true;
|
||||
}
|
||||
}
|
||||
return supportedFormat;
|
||||
}
|
||||
|
||||
bool Audio::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDeviceInfo) {
|
||||
bool supportedFormat = false;
|
||||
|
||||
// cleanup any previously initialized device
|
||||
if (_audioOutput) {
|
||||
_audioOutput->stop();
|
||||
disconnect(_outputDevice, 0, 0, 0);
|
||||
_outputDevice = NULL;
|
||||
|
||||
delete _audioOutput;
|
||||
_audioOutput = NULL;
|
||||
_numInputCallbackBytes = 0;
|
||||
|
||||
_loopbackOutputDevice = NULL;
|
||||
delete _loopbackAudioOutput;
|
||||
_loopbackAudioOutput = NULL;
|
||||
|
||||
_proceduralOutputDevice = NULL;
|
||||
delete _proceduralAudioOutput;
|
||||
_proceduralAudioOutput = NULL;
|
||||
_outputAudioDeviceName = "";
|
||||
}
|
||||
|
||||
if (!outputDeviceInfo.isNull()) {
|
||||
qDebug() << "The audio output device " << outputDeviceInfo.deviceName() << "is available.";
|
||||
_outputAudioDeviceName = outputDeviceInfo.deviceName().trimmed();
|
||||
|
||||
if (adjustedFormatForAudioDevice(outputDeviceInfo, _desiredOutputFormat, _outputFormat)) {
|
||||
qDebug() << "The format to be used for audio output is" << _outputFormat;
|
||||
|
||||
// setup our general output device for audio-mixer audio
|
||||
_audioOutput = new QAudioOutput(outputDeviceInfo, _outputFormat, this);
|
||||
_audioOutput->setBufferSize(_ringBuffer.getSampleCapacity() * sizeof(int16_t));
|
||||
qDebug() << "Ring Buffer capacity in samples: " << _ringBuffer.getSampleCapacity();
|
||||
_outputDevice = _audioOutput->start();
|
||||
|
||||
// setup a loopback audio output device
|
||||
_loopbackAudioOutput = new QAudioOutput(outputDeviceInfo, _outputFormat, this);
|
||||
|
||||
// setup a procedural audio output device
|
||||
_proceduralAudioOutput = new QAudioOutput(outputDeviceInfo, _outputFormat, this);
|
||||
|
||||
gettimeofday(&_lastReceiveTime, NULL);
|
||||
supportedFormat = true;
|
||||
}
|
||||
}
|
||||
return supportedFormat;
|
||||
}
|
||||
|
||||
bool Audio::switchInputToAudioDevice(const QString& inputDeviceName) {
|
||||
return switchInputToAudioDevice(getNamedAudioDeviceForMode(QAudio::AudioInput, inputDeviceName));
|
||||
}
|
||||
|
@ -882,3 +793,92 @@ void Audio::renderMuteIcon(int x, int y) {
|
|||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
bool Audio::switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceInfo) {
|
||||
bool supportedFormat = false;
|
||||
|
||||
// cleanup any previously initialized device
|
||||
if (_audioInput) {
|
||||
_audioInput->stop();
|
||||
disconnect(_inputDevice, 0, 0, 0);
|
||||
_inputDevice = NULL;
|
||||
|
||||
delete _audioInput;
|
||||
_audioInput = NULL;
|
||||
_numInputCallbackBytes = 0;
|
||||
|
||||
_inputAudioDeviceName = "";
|
||||
}
|
||||
|
||||
if (!inputDeviceInfo.isNull()) {
|
||||
qDebug() << "The audio input device " << inputDeviceInfo.deviceName() << "is available.";
|
||||
_inputAudioDeviceName = inputDeviceInfo.deviceName().trimmed();
|
||||
|
||||
if (adjustedFormatForAudioDevice(inputDeviceInfo, _desiredInputFormat, _inputFormat)) {
|
||||
qDebug() << "The format to be used for audio input is" << _inputFormat;
|
||||
|
||||
_audioInput = new QAudioInput(inputDeviceInfo, _inputFormat, this);
|
||||
_numInputCallbackBytes = NETWORK_BUFFER_LENGTH_BYTES_PER_CHANNEL * _inputFormat.channelCount()
|
||||
* (_inputFormat.sampleRate() / SAMPLE_RATE)
|
||||
/ CALLBACK_ACCELERATOR_RATIO;
|
||||
_audioInput->setBufferSize(_numInputCallbackBytes);
|
||||
|
||||
// how do we want to handle input working, but output not working?
|
||||
_inputRingBuffer.resizeForFrameSize(_numInputCallbackBytes * CALLBACK_ACCELERATOR_RATIO / sizeof(int16_t));
|
||||
_inputDevice = _audioInput->start();
|
||||
connect(_inputDevice, SIGNAL(readyRead()), this, SLOT(handleAudioInput()));
|
||||
|
||||
supportedFormat = true;
|
||||
}
|
||||
}
|
||||
return supportedFormat;
|
||||
}
|
||||
|
||||
bool Audio::switchOutputToAudioDevice(const QAudioDeviceInfo& outputDeviceInfo) {
|
||||
bool supportedFormat = false;
|
||||
|
||||
// cleanup any previously initialized device
|
||||
if (_audioOutput) {
|
||||
_audioOutput->stop();
|
||||
disconnect(_outputDevice, 0, 0, 0);
|
||||
_outputDevice = NULL;
|
||||
|
||||
delete _audioOutput;
|
||||
_audioOutput = NULL;
|
||||
_numInputCallbackBytes = 0;
|
||||
|
||||
_loopbackOutputDevice = NULL;
|
||||
delete _loopbackAudioOutput;
|
||||
_loopbackAudioOutput = NULL;
|
||||
|
||||
_proceduralOutputDevice = NULL;
|
||||
delete _proceduralAudioOutput;
|
||||
_proceduralAudioOutput = NULL;
|
||||
_outputAudioDeviceName = "";
|
||||
}
|
||||
|
||||
if (!outputDeviceInfo.isNull()) {
|
||||
qDebug() << "The audio output device " << outputDeviceInfo.deviceName() << "is available.";
|
||||
_outputAudioDeviceName = outputDeviceInfo.deviceName().trimmed();
|
||||
|
||||
if (adjustedFormatForAudioDevice(outputDeviceInfo, _desiredOutputFormat, _outputFormat)) {
|
||||
qDebug() << "The format to be used for audio output is" << _outputFormat;
|
||||
|
||||
// setup our general output device for audio-mixer audio
|
||||
_audioOutput = new QAudioOutput(outputDeviceInfo, _outputFormat, this);
|
||||
_audioOutput->setBufferSize(_ringBuffer.getSampleCapacity() * sizeof(int16_t));
|
||||
qDebug() << "Ring Buffer capacity in samples: " << _ringBuffer.getSampleCapacity();
|
||||
_outputDevice = _audioOutput->start();
|
||||
|
||||
// setup a loopback audio output device
|
||||
_loopbackAudioOutput = new QAudioOutput(outputDeviceInfo, _outputFormat, this);
|
||||
|
||||
// setup a procedural audio output device
|
||||
_proceduralAudioOutput = new QAudioOutput(outputDeviceInfo, _outputFormat, this);
|
||||
|
||||
gettimeofday(&_lastReceiveTime, NULL);
|
||||
supportedFormat = true;
|
||||
}
|
||||
}
|
||||
return supportedFormat;
|
||||
}
|
||||
|
|
|
@ -168,9 +168,9 @@ private:
|
|||
// Add sounds that we want the user to not hear themselves, by adding on top of mic input signal
|
||||
void addProceduralSounds(int16_t* monoInput, int numSamples);
|
||||
|
||||
bool switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceInfo);
|
||||
bool switchInputToAudioDevice(const QAudioDeviceInfo& inputDeviceInfo);
|
||||
bool switchOutputToAudioDevice(const QAudioDeviceInfo& outputDeviceInfo);
|
||||
};
|
||||
|
||||
|
||||
#endif /* defined(__interface__audio__) */
|
||||
#endif /* defined(__interface__audio__) */
|
||||
|
|
Loading…
Reference in a new issue