mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-16 11:13:52 +02:00
don't crash if there is no output
This commit is contained in:
parent
349b7b493b
commit
098010e099
1 changed files with 7 additions and 8 deletions
|
@ -142,15 +142,15 @@ void Audio::start() {
|
|||
|
||||
qDebug() << "The format for audio I/O is" << audioFormat << "\n";
|
||||
|
||||
QAudioDeviceInfo inputAudioDevice = defaultAudioDeviceForMode(QAudio::AudioInput);
|
||||
QAudioDeviceInfo inputDeviceInfo = defaultAudioDeviceForMode(QAudio::AudioInput);
|
||||
|
||||
qDebug() << "Audio input device is" << inputAudioDevice.deviceName() << "\n";
|
||||
if (!inputAudioDevice.isFormatSupported(audioFormat)) {
|
||||
qDebug() << "Audio input device is" << inputDeviceInfo.deviceName() << "\n";
|
||||
if (!inputDeviceInfo.isFormatSupported(audioFormat)) {
|
||||
qDebug() << "The desired audio input format is not supported by this device. Not starting audio input.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
_audioInput = new QAudioInput(inputAudioDevice, audioFormat, this);
|
||||
_audioInput = new QAudioInput(inputDeviceInfo, audioFormat, this);
|
||||
_audioInput->setBufferSize(CALLBACK_IO_BUFFER_SIZE);
|
||||
_inputDevice = _audioInput->start();
|
||||
|
||||
|
@ -158,8 +158,6 @@ void Audio::start() {
|
|||
|
||||
QAudioDeviceInfo outputDeviceInfo = defaultAudioDeviceForMode(QAudio::AudioOutput);
|
||||
|
||||
qDebug() << outputDeviceInfo.supportedSampleRates() << "\n";
|
||||
|
||||
qDebug() << "Audio output device is" << outputDeviceInfo.deviceName() << "\n";
|
||||
|
||||
if (!outputDeviceInfo.isFormatSupported(audioFormat)) {
|
||||
|
@ -350,8 +348,9 @@ void Audio::handleAudioInput() {
|
|||
}
|
||||
}
|
||||
|
||||
_outputDevice->write(stereoOutputBuffer);
|
||||
|
||||
if (_outputDevice) {
|
||||
_outputDevice->write(stereoOutputBuffer);
|
||||
}
|
||||
|
||||
// add output (@speakers) data just written to the scope
|
||||
QMetaObject::invokeMethod(_scope, "addStereoSamples", Qt::QueuedConnection,
|
||||
|
|
Loading…
Reference in a new issue