mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 20:33:09 +02:00
fix crash when no output audio device selected, add get/set volume support for input devices
This commit is contained in:
parent
7ef1fe3a74
commit
da763671fa
4 changed files with 19 additions and 3 deletions
|
@ -395,7 +395,7 @@ void Audio::handleAudioInput() {
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::EchoLocalAudio) && !_muted) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::EchoLocalAudio) && !_muted) {
|
||||||
// if this person wants local loopback add that to the locally injected audio
|
// if this person wants local loopback add that to the locally injected audio
|
||||||
|
|
||||||
if (!_loopbackOutputDevice) {
|
if (!_loopbackOutputDevice && _loopbackAudioOutput) {
|
||||||
// we didn't have the loopback output device going so set that up now
|
// we didn't have the loopback output device going so set that up now
|
||||||
_loopbackOutputDevice = _loopbackAudioOutput->start();
|
_loopbackOutputDevice = _loopbackAudioOutput->start();
|
||||||
}
|
}
|
||||||
|
@ -545,7 +545,7 @@ void Audio::handleAudioInput() {
|
||||||
addProceduralSounds(monoAudioSamples,
|
addProceduralSounds(monoAudioSamples,
|
||||||
NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL);
|
NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL);
|
||||||
|
|
||||||
if (!_proceduralOutputDevice) {
|
if (!_proceduralOutputDevice && _proceduralAudioOutput) {
|
||||||
_proceduralOutputDevice = _proceduralAudioOutput->start();
|
_proceduralOutputDevice = _proceduralAudioOutput->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,7 +645,7 @@ void Audio::addReceivedAudioToBuffer(const QByteArray& audioByteArray) {
|
||||||
static float networkOutputToOutputRatio = (_desiredOutputFormat.sampleRate() / (float) _outputFormat.sampleRate())
|
static float networkOutputToOutputRatio = (_desiredOutputFormat.sampleRate() / (float) _outputFormat.sampleRate())
|
||||||
* (_desiredOutputFormat.channelCount() / (float) _outputFormat.channelCount());
|
* (_desiredOutputFormat.channelCount() / (float) _outputFormat.channelCount());
|
||||||
|
|
||||||
if (!_ringBuffer.isStarved() && _audioOutput->bytesFree() == _audioOutput->bufferSize()) {
|
if (!_ringBuffer.isStarved() && _audioOutput && _audioOutput->bytesFree() == _audioOutput->bufferSize()) {
|
||||||
// we don't have any audio data left in the output buffer
|
// we don't have any audio data left in the output buffer
|
||||||
// we just starved
|
// we just starved
|
||||||
//qDebug() << "Audio output just starved.";
|
//qDebug() << "Audio output just starved.";
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "InterfaceConfig.h"
|
#include "InterfaceConfig.h"
|
||||||
|
|
||||||
#include <QAudio>
|
#include <QAudio>
|
||||||
|
#include <QAudioInput>
|
||||||
#include <QGLWidget>
|
#include <QGLWidget>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QVector>
|
#include <QtCore/QVector>
|
||||||
|
@ -92,6 +93,9 @@ public slots:
|
||||||
QString getDefaultDeviceName(QAudio::Mode mode);
|
QString getDefaultDeviceName(QAudio::Mode mode);
|
||||||
QVector<QString> getDeviceNames(QAudio::Mode mode);
|
QVector<QString> getDeviceNames(QAudio::Mode mode);
|
||||||
|
|
||||||
|
float getInputVolume() const { return (_audioInput) ? _audioInput->volume() : 0.0f; }
|
||||||
|
void setInputVolume(float volume) { if (_audioInput) _audioInput->setVolume(volume); }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
bool muteToggled();
|
bool muteToggled();
|
||||||
|
|
||||||
|
|
|
@ -58,3 +58,12 @@ QVector<QString> AudioDeviceScriptingInterface::getInputDevices() {
|
||||||
QVector<QString> AudioDeviceScriptingInterface::getOutputDevices() {
|
QVector<QString> AudioDeviceScriptingInterface::getOutputDevices() {
|
||||||
return Application::getInstance()->getAudio()->getDeviceNames(QAudio::AudioOutput);
|
return Application::getInstance()->getAudio()->getDeviceNames(QAudio::AudioOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float AudioDeviceScriptingInterface::getInputVolume() {
|
||||||
|
return Application::getInstance()->getAudio()->getInputVolume();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioDeviceScriptingInterface::setInputVolume(float volume) {
|
||||||
|
Application::getInstance()->getAudio()->setInputVolume(volume);
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,9 @@ public slots:
|
||||||
|
|
||||||
QVector<QString> getInputDevices();
|
QVector<QString> getInputDevices();
|
||||||
QVector<QString> getOutputDevices();
|
QVector<QString> getOutputDevices();
|
||||||
|
|
||||||
|
float getInputVolume();
|
||||||
|
void setInputVolume(float volume);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__hifi__AudioDeviceScriptingInterface__) */
|
#endif /* defined(__hifi__AudioDeviceScriptingInterface__) */
|
||||||
|
|
Loading…
Reference in a new issue